{"id":"CVE-2026-63345","aliases":["CVE-2026-63345","GHSA-3fhm-p725-h3g3"],"related":[],"kind":"vulnerability","state":"published","title":"Refitter: C# source injection through OpenAPI path keys","summary":"Refitter is a tool for generating a C# REST API client using the Refit library. Prior to 2.1.2, OpenAPI `paths`-object keys are emitted verbatim into Refit route attributes such as `[Get(\"<path>\")]` without escaping quotation marks or restricting characters. An attacker-influenced single-line, slash-prefixed path survives default validation without `--skip-validation` and can close the attribute string, interface, and namespace while introducing a top-level file class and reopening the generated structure to keep valid C#. A `[ModuleInitializer]` method executes attacker code when an application compiles and loads the generated assembly at startup, even without calling the generated client. The enum and default value sinks are escaped and are not the vulnerable path-emission sink. The behavior was verified on Refitter 2.0.0 with .NET 8. This issue is fixed in version 2.1.2.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Refitter is a tool for generating a C# REST API client using the Refit library. Prior to 2.1.2, OpenAPI `paths`-object keys are emitted verbatim into Refit route attributes such as `[Get(\"<path>\")]` without escaping quotation marks or restricting characters. An attacker-influenced single-line, slash-prefixed path survives default validation without `--skip-validation` and can close the attribute string, interface, and namespace while introducing a top-level file class and reopening the generated structure to keep valid C#. A `[ModuleInitializer]` method executes attacker code when an application compiles and loads the generated assembly at startup, even without calling the generated client. The enum and default value sinks are escaped and are not the vulnerable path-emission sink. The behavior was verified on Refitter 2.0.0 with .NET 8. This issue is fixed in version 2.1.2.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nRefitter emits each OpenAPI path (the paths-object key) verbatim into a Refit `[Get(\"<path>\")]`\nattribute string, without escaping `\"` or restricting characters. A crafted single-line, /-prefixed\npath survives Refitter's default OpenAPI validation yet closes the attribute string and the enclosing\ninterface + namespace, injects a top-level `file class` with a `[ModuleInitializer]` method, and\nreopens a namespace + interface so the file stays valid. .NET runs `[ModuleInitializer]` methods when\nthe generated assembly is loaded, so the attacker's code executes at application startup. Verified on\nRefitter 2.0.0 / .NET 8.\n\n### Details\n\n```\n[Get(\"/p\")] Task<string> Dummy(); } }\nfile class Evil { [System.Runtime.CompilerServices.ModuleInitializer]\n  internal static void Init(){ /* attacker code */ } }\nnamespace N2 { public partial interface I2 { [Get(\"/q\")]\n        Task<string> GetU(string id);\n    }\n}\n```\n\nNo `--skip-validation` is needed (the payload is a valid single-line path). The generated `.cs` is\ncompiled into the victim application; the module initializer runs at assembly load. This is distinct\nfrom the value sinks (enum/default), which are escaped; the path sink has no escaping. The\n`[Header(\"<name>\")]` attribute is likewise emitted raw (header parameter names), at minimum a\nbuild-breaking DoS.\n\n### PoC\n\n`reproduce.sh` (+ `make_spec.py`) attached: generates with default validation, compiles into a console\napp, runs it (Main does not touch the client), and shows a marker written at assembly load. Verified\non 2.0.0.\n\n### Impact\n\nCode execution at assembly load (process startup) in any application that compiles a Refitter client\ngenerated from an attacker-controlled or attacker-influenced OpenAPI description.\n\n### Suggested fix\n\nEscape the route template before emitting it into `[Get(\"…\")]` (escape `\"`, `\\`, reject newlines) and\nvalidate that paths contain only legal URI-template characters. Apply the same encoding to\n`[Header(…)]`, `[Post/Put/Delete(…)]`, and every attribute that embeds a spec-derived string.\n[maintainer-report.txt](https://github.com/user-attachments/files/29395228/maintainer-report.txt)\n[make_spec.py](https://github.com/user-attachments/files/29395229/make_spec.py)\n[reproduce.sh](https://github.com/user-attachments/files/29395230/reproduce.sh)","format":"markdown","source":"ghsa"}],"published":"2026-10-30T22:13:53.498Z","modified":"2026-11-20T00:15:05.538Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.6,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"CRITICAL"}],"cwes":["CWE-94","CWE-1116"],"affected":[{"ranges":[{"version":"< 2.1.2","status":"affected"}],"vendor":"christianhelle","product":"refitter","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.1.2"}],"ecosystem":"NuGet","package":"Refitter","purl":"pkg:nuget/Refitter","source":"ghsa"}],"references":[{"url":"https://github.com/christianhelle/refitter/security/advisories/GHSA-3fhm-p725-h3g3","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/christianhelle/refitter/pull/1178","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/christianhelle/refitter/commit/793d2632899c2022511dfc15e30725ef69073973","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/christianhelle/refitter/releases/tag/2.1.2","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/user-attachments/files/29395228/maintainer-report.txt","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/user-attachments/files/29395229/make_spec.py","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/user-attachments/files/29395230/reproduce.sh","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63345","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/christianhelle/refitter","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-11-02T17:09:18.405Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-63345","url":"https://www.cve.org/CVERecord?id=CVE-2026-63345","licence":"CVE Terms of Use","modified":"2026-11-02T17:58:04.730Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3fhm-p725-h3g3","url":"https://github.com/advisories/GHSA-3fhm-p725-h3g3","licence":"CC-BY-4.0","modified":"2026-11-20T00:15:05.538Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-63345","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63345","licence":"Public domain","modified":"2026-11-02T19:35:33.347Z"}],"updatedAt":"2026-11-25T22:59:48.042Z","epss":{"score":0.00568,"percentile":0.48433,"date":"2026-12-01T12:00:22.000Z"}}