Security Digest · Vulnerability record

CVE-2026-63471: fastapi-code-generator: Import-time RCE via route path -> unescaped @app.get('...') decorator

fastapi-code-generator creates FastAPI applications from OpenAPI files.

CVSS 9.3 Critical EPSS 0.5% · p41

Should you act?

Critical and remotely reachable

No known exploitation yet, but it is network-reachable without credentials. This signal is computed from CISA KEV, EPSS and CVSS data; it is not an editorial verdict.

  • Not in CISA KEV, but CISA’s SSVC assessment records a public proof-of-concept, so attack code exists.
  • EPSS 0.5%, percentile 41: FIRST’s model estimates a 0.5% chance of exploitation activity in the next 30 days, higher than 41% of all scored CVEs (low). EPSS is a probability, not a verdict.
  • Remotely reachable with no login and no user interaction. If the vulnerable service is exposed to the internet, prioritize it.
  • Only applies if your dependency tree includes fastapi-code-generator (PyPI) < 0.8.1, fixed in 0.8.1. Check your lockfile, including transitive dependencies.

What it is

fastapi-code-generator creates FastAPI applications from OpenAPI files. Prior to 0.8.1, the generator inserts an OpenAPI path into a generated @app.get(...) route decorator as a single-quoted generated route string without escaping embedded quotes. An attacker-controlled or attacker-influenced OpenAPI path can close the string and inject a valid Python expression into the decorator argument. Syntax-breaking input only causes generation to fail, but syntactically valid generated code executes with the application's or CI process's privileges when the generated module is imported and the decorator is evaluated. This OpenAPI path sink is distinct from the project's separate operation-summary docstring and additional-response-key sinks. This issue is fixed in version 0.8.1.

From the GitHub advisory

Summary

fastapi-code-generator (koxudaxi) emits the OpenAPI path into the generated main.py route decorator as a single-quoted string literal (@app.get('/u/ /x')) without escaping the '. A ' in the path closes the decorator string and, via concatenation, injects a live expression that the decorator argument evaluates when main.py is imported (the ASGI server imports it at startup) -- code execution, no request needed. The path is a pure data field. Verified on fastapi-code-generator 0.8.0 / Python 3 / FastAPI.

Details

The generator post-processes output with black/isort, so a syntax-breaking payload aborts generation (DoS); a valid-Python concat ('+expr+', kept valid with (… or "")) is written and runs at import. info.description (description='…'), tags, and parameter defaults are '-escaped; the path in @app.get('…') is the unescaped sink. Models come from datamodel-code-generator (repr-escaped, no RCE).

Not a duplicate: distinct product from OpenAPI Generator's python-fastapi backend (different codebase/template/decorator); and distinct from the operation-summary docstring sink in the same product.

Weakness type: CWE-94, CWE-116.

Product: fastapi-code-generator (PyPI) · Assigned by: GitHub_M · Published: 2026-11-03

Affected and fixed versions

EcosystemPackageVulnerableFirst fixed
PyPIfastapi-code-generator< 0.8.10.8.1
VendorProductAffected versions (per CVE record)
koxudaxifastapi-code-generator< 0.8.1

Severity scores

Scored byCVSSScoreVector
GitHub_M4.09.3 CriticalCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
GitHub4.09.3 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
  • Attack vector: network (remotely reachable)
  • Attack complexity: low
  • Attack requirements: none
  • Privileges required: none (no login)
  • User interaction: none

CVSS measures how bad a flaw is if exploited, not how likely exploitation is. Read it next to the exploitation data below.

Exploitation and urgency

  • CISA KEV: not listed (no confirmed in-the-wild exploitation known to CISA).
  • CISA SSVC assessment: exploitation poc, automatable yes, technical impact total.
  • FIRST EPSS (model of 2026-11-21): 0.47% probability of exploitation activity in the next 30 days; percentile 41.

Timeline

  • — CVE record published by GitHub_M
  • — CVE record last updated
  • — GitHub-reviewed advisory GHSA-p2mm-64f6-gmpp published (critical)

Sources and references

Original sources first. Version and fix details should always be confirmed against the vendor or project advisory.

Vulnerability records

  1. GitHub Advisory GHSA-p2mm-64f6-gmpp github.com
  2. CVE.org record CVE-2026-63471 cve.org
  3. NVD entry CVE-2026-63471 nvd.nist.gov

Other references from the CVE record and advisory

  1. github.com github.com
  2. github.com github.com
  3. github.com github.com
  4. github.com github.com

Critical PyPI advisories · Today’s Security Digest