Skip to content
Exploit for CVE-2026

Exploit for CVE-2026

Sploitus • November 21, 2026

# CVE-2026-63344 — Refitter: unescaped content-type key in `[Headers(...)]` attribute enables arbitrary code execution at application startup

[![License: MIT](

[![Research status: validated](

| **Component** | Refitter (`refitter` dotnet tool) — `MethodAttributeGenerator.cs` media-type emission |

| **Affected** | ")]` attribute string without escaping `"`. A crafted key survives Refitter's default OpenAPI validation, breaks out of the attribute and the enclosing 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** | response `content` key: `json")] Task Dummy(); } } file class EvilCT { [ModuleInitializer] ... } namespace N3 { public partial interface I3 { [Headers("Accept: application/` |

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

// MethodAttributeGenerator.cs — pre-fix (2.1.1)

headers.Add($"\"Accept: {string.Join(", ", uniqueContentTypes)}\"");

headers.Add($"\"Content-Type: {contentType}\"");

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

headers.Add($"\"Accept: {string.Join(", ", uniqueContentTypes.Select(ParameterShared.EscapeString))}\"");

headers.Add($"\"Content-Type: {ParameterShared.EscapeString(contentType)}\"");

`MethodAttributeGenerator` wrote the response content-type key into the Refit

`[Headers(...)]` attribute string without escaping. C# string literals inside

attributes terminate at the first `"`, so a media-type value beginning with

`json")]` closes the attribute string, closes the enclosing interface and

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

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

interface I3 { [Headers("Accept: application/` so the remainder of the

generated file compiles unchanged. `ParameterShared.EscapeString` did not exist

on this sink. Because Refitter's default OpenAPI validation accepts the crafted

media-type key, no `--skip-validation` flag is needed. The compiled initializer

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

the victim application's process at startup.

The fix adds `ParameterShared.EscapeString` (escapes `\` and `"`, rejects

newlines) at every attribute emission point that embeds spec-derived values.

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

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

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

The harness writes an OpenAPI spec whose response content-type key is the

breakout payload (writing the marker `/tmp/lab/CT_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 # cve63344lab 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 `ab4d8e43` / `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 3414 B, breakout present, app ran, marker = `pwned-via-content-type`** | generation **rejected** (0 bytes) |

| `--skip-validation` | **marker = `pwned-via-content-type`** | generated 3420 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 `cve63344lab`

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): `793d2632` escapes the

OpenAPI path emitted into `[Get("…")]` (CVE-2026-63345) and `63a19b03` escapes

header parameter names emitted into `[Header("…")]` (CVE-2026-63346). Value

sinks (enum, default, query `AliasAs`) were already escaped per the advisory.

On the fixed build, the crafted content-type key 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 remains on the 2.1.2 line.

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 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