Skip to content
Exploit for CVE-2026

Exploit for CVE-2026

Sploitus • November 21, 2026

# CVE-2026-63346 — Refitter: unescaped header parameter name in `[Header(...)]` attribute enables arbitrary code execution at application startup

[![License: MIT](

[![Research status: validated](

| **Component** | Refitter (`refitter` dotnet tool) — `HeaderParameterExtractor.cs` header-name emission |

| **Affected** | ")]` attribute string without escaping `"`. A crafted name survives Refitter's default OpenAPI validation and, starting from a PARAMETER-LIST position, closes the parameters + method + interface + namespace, injects a top-level `file class` with a `[ModuleInitializer]` method, and reopens so the file stays valid. .NET runs `[ModuleInitializer]` methods at assembly load, so the attacker's code executes at application startup of any app that compiles the generated client |

| **Vector** | A malicious OpenAPI specification processed by Refitter (CI pipelines, client generators) |

| **Trigger** | header parameter name: `X")] string a); } } file class EvilH { [ModuleInitializer] ... } namespace NH { public partial interface IH { [Get("/z")] Task M([Header("Y` |

The vulnerable generator embedded the spec-derived media type raw:

// HeaderParameterExtractor.cs — pre-fix (2.1.1): the name is embedded raw

Task M([Header("")] string value); // a crafted name closes the

The fix routes every spec-derived media type through the shared encoder:

// the header name passes through ParameterShared.EscapeString before emission

[Header(EscapeString(name))] // the crafted quote stays inside the literal

`HeaderParameterExtractor` wrote the header parameter name into the Refit

`[Header("…")]` attribute string without escaping. C# string literals inside

attributes terminate at the first `"`, and this breakout starts from a

parameter-list position: the crafted name beginning with `X")]` closes the

attribute string and the parameter list (`string a);`), closes the method,

interface and namespace (`} }`), declares a top-level `file class` carrying a

`[ModuleInitializer]` method, and reopens `namespace NH { public partial

interface IH { [Get("/z")] Task M([Header("Y` so the remainder of the

generated file compiles unchanged. The payload is a valid single-line header

name, so Refitter's default OpenAPI validation accepts it and no

`--skip-validation` flag is needed. The compiled initializer runs before

`Main` — at assembly load — giving the attacker code execution in the victim

The fix routes the header name through `ParameterShared.EscapeString`

(escapes `\` and `"`, rejects newlines) before emission.

| `refitter-vuln` | `cve-2026-63346:vuln` | real Refitter **2.1.1** |

| `refitter-fixed` | `cve-2026-63346:fixed` | real Refitter **2.1.2** (vendor fix) |

| `poc` | `cve-2026-63346-poc:local` | stdlib-only Python driver |

The harness writes an OpenAPI spec whose header parameter name is the breakout

payload (writing the marker `/tmp/lab/HEADER_PWNED`), runs the real

`refitter` tool with default validation, compiles the generated `Client.cs`

into a console app (Refit 8.0.0, `Main` touches nothing), runs it, and checks

whether the marker file was written. A second mode (`--skip-validation`)

isolates the escape fix from the validation layer. Both sides differ only in

./run-lab.sh build # installs refitter 2.1.1 / 2.1.2 (dotnet SDK 8.0)

./run-lab.sh up # cve63346lab network: refitter-vuln / refitter-fixed

* **check** — exit 1 when the `[ModuleInitializer]` fired at assembly load, 0

when generation is rejected or the payload is escaped; 3 no worker, 2

* **exploit** — narrated chain: crafted spec → generation with default

validation → compile into the victim app → startup execution (marker).

* **probe** — mode matrix: default validation vs `--skip-validation`

(generated bytes, escaped quotes, run exit, marker).

* **mitigation** — 2.1.2 / commit `63a19b03` / `ParameterShared.EscapeString`.

A standalone full-chain exploit ships at `exploit/exploit.py`:

python3 exploit/exploit.py --host=refitter-vuln

# exit 1 on confirmed startup code execution, 0 on a safe target

| generation mode | `refitter-vuln` (2.1.1) | `refitter-fixed` (2.1.2) |

| default validation | **generated 3711 B, breakout present, app ran, marker = `pwned-via-header-name`** | generation **rejected** (0 bytes) |

| `--skip-validation` | **marker = `pwned-via-header-name`** | generated 3719 B, quotes **escaped** (`escaped_quotes=true`), compiles clean, no marker |

Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`,

`evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`,

`evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`,

`evidence/versions.txt`, `evidence/0day-sweep.txt`.

* Podman (or Docker); bounded containers on the isolated `cve63346lab`

network; .NET SDK 8.0 in the lab images (Refit 8.0.0 for the victim app).

* Real-world exploitation requires a victim to generate a Refit client with

Refitter from an attacker-controlled or attacker-influenced OpenAPI

description and to compile the generated code into an application.

## 7. Additional findings (0-day sweep on the fixed line)

The same release batch fixes the two sibling attribute sinks with dedicated

commits (verified in the upstream 2.1.1..2.1.2 log): `ab4d8e43` escapes the

spec-derived media types emitted into `[Headers("…")]` (CVE-2026-63344) and

`793d2632` escapes route templates emitted into `[Get("…")]`

(CVE-2026-63345). Value sinks (enum, default, query `AliasAs`) were already

escaped per the advisory. On the fixed build, the crafted header name is

rejected by default validation outright, and bypassing validation the quotes

are escaped so the generated file compiles cleanly with no injected

initializer — both layers verified in this lab. No attribute-injection path

run-lab.sh environment driver (build / up / sweep / down)

Makefile convenience targets

poc/poc.py the PoC (check / exploit / probe / mitigation)

exploit/exploit.py standalone full-chain exploit

lab/lab.Dockerfile installs both Refitter versions + warm victim template

lab/harness.py crafted header-name spec -> generation -> compile -> run -> marker

lab/service.py HTTP wrapper (POST /generate)

evidence/ captured runs of every mode on both sides

TRACKING.md excluded (working record)

* CVE record —

* GitHub advisory —

* Fix commit —

Extracted Entities