On this page (7 sections)

Refitter, a tool that generates C# REST API clients for the Refit library from OpenAPI descriptions, has a code injection flaw tracked as CVE-2026-63346. A crafted header parameter name in an OpenAPI file can break out of the generated code and add attacker-written C# that runs as soon as the compiled application starts, even if the client is never called.

If your team generates clients from OpenAPI files that you did not write yourself (partner APIs, third-party specs, files from a public repository), this affects your build pipeline and anything you ship from it. The fix is in Refitter 2.1.2.

What happened

According to the GitHub advisory, Refitter writes the name of a header parameter (the name field of a parameter with in: header) straight into a Refit [Header("<name>")] attribute string. Quotation marks in that name are not escaped. A specially built value therefore closes the string and the surrounding C# structures and lets the spec author write code of their own into the generated file.

The advisory reports the behavior was verified with Refitter 2.0.0 and .NET 8. The fix shipped in release 2.1.2, with the change described in pull request 1178.

Technical details in plain terms

This is a classic injection problem: data from an untrusted file is placed into code without being encoded for the place it lands. Here the data is a header name and the destination is a C# string literal inside an attribute. Without escaping the double quote character, the data can end the string early and everything after it is read as code.

Several details from the advisory explain why it is more serious than a cosmetic bug:

  • The breakout starts from a parameter-list position, so the crafted value first closes the parameters and the method, then the attribute, interface and namespace.
  • The generated file can stay valid C#, so compilation succeeds and nothing looks broken.
  • The injected code can use a [ModuleInitializer] method in a top-level file class. .NET runs module initializers when the assembly loads, so the code executes at application startup without any call to the generated client.
  • The crafted value passes Refitter's default OpenAPI validation. Using --skip-validation is not required.
  • Other inputs, such as the query AliasAs value and enum or default values, are already escaped. The gap is specific to header-name attribute emission.

The advisory describes the impact as code execution at assembly load in any application that compiles a Refitter client generated from an attacker-controlled or attacker-influenced OpenAPI description.

How severe is it, and is it exploited?

The sources give different scores, so treat the rating as high to critical. The CVE record lists CVSS 8.6 (high). The GitHub advisory page displays Critical with a CVSS v4 overall score of 9.3. The advisory body itself gives an estimated Critical rating and notes that the CNA sets the final score.

The research does not report any exploitation. A proof of concept (a spec generator and a reproduction script) is attached to the advisory, so do not assume low risk just because no attacks are reported. Only one independent publisher covers this story so far, and the primary source is the project's own advisory.

Who is realistically exposed

The attacker needs a way to influence the OpenAPI file you feed to Refitter. That is not a flaw in a running website; it is a build-time and supply chain risk. Consider yourself exposed if any of these apply:

  • You generate clients from specs published by third parties or downloaded automatically at build time.
  • Contributors or customers can submit or change OpenAPI files in a repository your CI builds.
  • You regenerate clients in CI with an unpinned or outdated Refitter version.
  • You built and shipped an application from a client generated by an affected version using an untrusted spec.

Because the code runs at startup of the compiled application, the impact lands wherever that application runs: a developer machine, a build agent, or a production server, with the privileges of that process.

What to do now

  1. Find every place Refitter is used: project files, tool manifests, CI scripts and Docker images.
  2. Upgrade Refitter to 2.1.2 or later and rebuild.
  3. Regenerate clients from your OpenAPI files with the fixed version instead of reusing previously generated code.
  4. Review the OpenAPI files used so far. Look for header parameter names that contain quotation marks, backslashes, newlines or anything that is not a normal header name.
  5. Search previously generated client files for unexpected classes or ModuleInitializer attributes that you did not write.
  6. Pin the Refitter version in CI and run generation in a sandboxed job with no production secrets.
  7. If a build used an untrusted spec with an affected version, treat that build output as suspect, rebuild from clean sources and rotate any secrets the build or app could reach.

This command lists Refitter package references in your solution's projects so you can see the version in use. Run it from the solution folder with the .NET SDK installed; look for any version below 2.1.2:

List NuGet packages referenced by a solution (.NET SDK)Shell
dotnet list package | grep -i refitter

If Refitter is installed as a .NET tool rather than a package reference, this lists installed tools and their versions. Check that the Refitter entry shows 2.1.2 or higher:

List installed .NET tools and versionsShell
dotnet tool list --global

This command updates a globally installed Refitter tool to the latest published version. Run it on developer machines and build agents, then confirm the version with the previous command:

Update a globally installed Refitter toolShell
dotnet tool update --global Refitter

This searches your repository for C# files containing module initializers, which are rare in client code. Run it from the repository root; any hit in a generated client file deserves a manual look:

Search a repository for ModuleInitializer usageShell
grep -rn "ModuleInitializer" --include="*.cs" .
Tip. If you reference Refitter as a package, update the version in the project file or with your usual NuGet workflow, and commit a lock file or fixed version so CI cannot silently fall back to an older release.

Detection and monitoring afterwards

Because the injected code sits in generated source, code review is your best detector. Make generated clients visible in pull requests rather than hiding them from diffs, and flag any new type, attribute or method in those files that is not a Refit interface or model.

  • Add a CI check that fails if generated files contain ModuleInitializer or unexpected top-level classes.
  • Validate OpenAPI files against an allowlist of header name characters before generation.
  • Keep a record of which spec version produced which build, so you can trace affected releases if a spec turns out to be malicious.
  • Watch the Refitter security advisory for updates, including any final score change.

The advisory's suggested hardening is broader than this one field: escape every spec-derived string before it is emitted into a Refit attribute, reject newlines, and use one shared encoder for all such emissions. If you wrap code generators in your own tooling, the same principle applies there.

For general guidance on keeping dependencies and sites in good shape, see the small business website security guide.

Timeline

  • Jun 30, 2026: advisory published in the christianhelle/refitter repository, per the GitHub advisory page.
  • Oct 30, 2026: published by the National Vulnerability Database (CVE record date).
  • Nov 20, 2026: published to the GitHub Advisory Database and reviewed.
These dates come from the GitHub advisory page and the CVE record. The sources do not explain the gap between the repository advisory date and the NVD publication date, and they do not say when the maintainers first received the report or exactly when 2.1.2 was released, so no further dates are given here.

Sources

This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.

  1. CVE-2026-63346 - GitHub Advisory Databasegithub.com
  • Refitter
  • CVE-2026-63346
  • NuGet
  • OpenAPI
  • code injection
  • supply chain