Skip to content
Exploit for CVE-2026

Exploit for CVE-2026

Sploitus • November 21, 2026

# CVE-2026-63345 — Refitter: unescaped route path in `[Get(...)]` attribute enables arbitrary code execution at application startup

[![License: MIT](

[![Research status: validated](

| **Component** | Refitter (`refitter` dotnet tool) — `InterfaceGenerator.cs` route-template emission |

| **Affected** | ")]` attribute string without escaping `"` or restricting characters. A crafted single-line, /-prefixed path survives Refitter's default OpenAPI validation, closes 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** | paths-object key: `/p")] Task Dummy(); } } file class Evil { [ModuleInitializer] ... } namespace N2 { public partial interface I2 { [Get("/q` |

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

// InterfaceGenerator.cs — pre-fix (2.1.1): the path key is embedded raw

[Get("")] // e.g. [Get("/p")] Task Dummy(); } } file class Evil ...

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

// the route template passes through ParameterShared.EscapeString before emission

[Get(EscapeString(path))] // "/p\")]" stays inside the attribute string literal

`InterfaceGenerator` wrote the paths-object key into the Refit `[Get("…")]`

attribute string without escaping and without restricting characters. C# string

literals inside attributes terminate at the first `"`, so a /-prefixed path

beginning with `/p")]` closes the attribute string, closes the enclosing

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

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

interface I2 { [Get("/q` so the remainder of the generated file compiles

unchanged. The payload is a valid single-line URI-template path, 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 application's process

The fix routes the route template through `ParameterShared.EscapeString`

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

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

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

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

The harness writes an OpenAPI spec whose paths-object key is the breakout

payload (writing the marker `/tmp/lab/ROUTE_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 # cve63345lab 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 `793d2632` / `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 3403 B, breakout present, app ran, marker = `pwned-via-route-path`** | generation **rejected** (0 bytes) |

| `--skip-validation` | **marker = `pwned-via-route-path`** | generated 3409 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 `cve63345lab`

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

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