microsoft/semantic-kernel · critical · KernelException
The operation path resolves to '{requestAuthority}', which d
Error message
The operation path resolves to '{requestAuthority}', which does not match the configured server '{serverAuthority}'. What it means
SSRF-prevention guard in RestApiOperation.BuildOperationUrl. After combining the server URL with the operation path via new Uri(serverUrl, path), EnsureRequestTargetMatchesServer compares the authority (scheme://host:port) of the resulting request URL against the configured server's authority. If they differ, the operation path has redirected the request to another host, which is rejected so a credential-bearing request cannot be sent to an unintended target.
Source
Thrown at dotnet/src/Functions/Functions.OpenApi/Model/RestApiOperation.cs:195
/// <summary>
/// Verifies that URI construction did not move the request off the configured server. A selected
/// operation path must resolve to a request on the same scheme, host, and port and within the
/// server's base path. Otherwise an absolute or authority-changing operation path (for example
/// "https://another-host/admin") could redirect a credential-bearing request to an unintended
/// target even though it carries no dot-segment. This complements <see cref="ValidatePathSegments"/>
/// so operation selection, path validation, and request construction share one canonical target.
/// </summary>
/// <param name="serverUrl">The configured server URL.</param>
/// <param name="requestUrl">The request URL produced by combining the server URL and operation path.</param>
private static void EnsureRequestTargetMatchesServer(Uri serverUrl, Uri requestUrl)
{
var serverAuthority = serverUrl.GetLeftPart(UriPartial.Authority);
var requestAuthority = requestUrl.GetLeftPart(UriPartial.Authority);
if (!string.Equals(serverAuthority, requestAuthority, StringComparison.OrdinalIgnoreCase))
{
throw new KernelException($"The operation path resolves to '{requestAuthority}', which does not match the configured server '{serverAuthority}'.");
}
// GetServerUrl guarantees a trailing slash, so the server's base path always ends with '/'.
var basePath = serverUrl.AbsolutePath;
var requestPath = requestUrl.AbsolutePath;
if (!string.Equals(requestPath, basePath.TrimEnd('/'), StringComparison.Ordinal) &&
!requestPath.StartsWith(basePath, StringComparison.Ordinal))
{
throw new KernelException($"The operation path resolves to '{requestPath}', which is outside the configured server base path '{basePath}'.");
}
}
/// <summary>
/// Builds operation request headers.
/// </summary>
/// <param name="arguments">The operation arguments.</param>
/// <returns>The request headers.</returns>View on GitHub (pinned to c028a0c7dc)
Solutions
- Edit the OpenAPI document so operation paths are relative (start without a scheme/host), e.g. /users/{id} rather than https://host/users/{id}.
- If the operation legitimately targets a different host, declare that host in the document's servers array so the authority matches.
- Pre-validate the spec: reject any path where new Uri(serverUrl, path).Authority != serverUrl.Authority before importing.
- Confirm the spec is from a trusted source; this guard exists precisely because untrusted specs are dangerous.
Example fix
// before - absolute path in the spec redirects off the server
"paths": { "https://evil.com/admin": { } }
// after - relative path stays within the configured server
"servers": [ { "url": "https://api.example.com" } ],
"paths": { "/admin": { } } Defensive patterns
Strategy: validation
Validate before calling
foreach (var pathKey in doc.Paths.Keys)
{
var resolved = new Uri(serverUrl, pathKey.TrimStart('/'));
if (!string.Equals(resolved.GetLeftPart(UriPartial.Authority), serverUrl.GetLeftPart(UriPartial.Authority), StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException($"Path '{pathKey}' redirects off server authority.");
} Type guard
static bool PathStaysOnServer(Uri serverUrl, string opPath)
{
var resolved = new Uri(serverUrl, opPath.TrimStart('/'));
return string.Equals(resolved.GetLeftPart(UriPartial.Authority), serverUrl.GetLeftPart(UriPartial.Authority), StringComparison.OrdinalIgnoreCase);
} Try / catch
try { var url = operation.BuildOperationUrl(arguments, serverUrlOverride, apiHostUrl); }
catch (KernelException ex) when (ex.Message.Contains("does not match the configured server"))
{ logger.LogWarning("Operation path escapes server authority; rejecting spec path."); throw; } Prevention
- Only import OpenAPI documents from trusted sources.
- Keep operation paths relative, never absolute URLs.
- Pre-scan paths against the declared server authority.
When it happens
Trigger: An OpenAPI operation path that is itself an absolute URL (e.g. path 'https://evil.com/admin') or contains a scheme://host prefix that overrides the server base. Also a path beginning with '//' (protocol-relative) that a browser-style resolver would interpret against a different host. Any case where Uri(serverUrl, path) yields a different authority than serverUrl.
Common situations: An OpenAPI document authored with absolute paths instead of relative ones; a spec scraped/converted by a tool that emitted full URLs in the path field; a malicious or buggy spec whose paths escape the declared server.
Related errors
- The operation path resolves to '{requestPath}', which is out
- Path '{path}' contains a dot-segment, which could lead to pa
- No argument '{variable.Value.ArgumentName ?? variableName}'
- Server url is not defined for operation {this.Id}
- The operation path resolves to '{request.scheme}://{request.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/43a72ccd2626c15b.
Report an issue: GitHub.