Skip to main content

fastapi-code-generator CVE-2026-63471

| EUVDEUVD-2026-116147 CRITICAL
Code Injection (CWE-94)
2026-11-03 GitHub_M
9.3
CVSS 4.0 · Vendor: GitHub_M
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft OpenAPI spec with quote-breaking path
  2. Delivery
    Deliver spec into victim generation/CI pipeline
  3. Exploit
    Generator emits unescaped @app.get('...') decorator
  4. Execution
    Victim imports generated main.py
  5. Persist
    Decorator expression evaluated at import
  6. Impact
    Arbitrary code runs as process

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Initial Access

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Not a flaw reachable by hitting the running application - exploitation requires the full generation-and-import path: (1) fastapi-code-generator version < 0.8.1; (2) an attacker-controlled or attacker-influenced OpenAPI spec whose path field contains a single quote (the unescaped @app.get('...') sink, distinct from the operation-summary docstring and additional-response-key sinks); (3) the injected payload must be syntactically valid Python (a '+expr+' concatenation kept valid with '(… or "")'), because the generator post-processes with black/isort and a syntax-breaking path only aborts generation as a DoS; and (4) the generated main.py must actually be imported (ASGI server startup or a CI import step) so the decorator argument is evaluated. Limiting factors: if all specs are trusted/first-party there is no attacker input; purely syntax-breaking input yields only generation failure, not RCE; and the generated module must be imported for code to run. Models produced via datamodel-code-generator are repr-escaped and not a sink.

Impact

All severity signals point the same direction except exploitation telemetry, which is absent. The CVSS 4.0 vector (AV:N/AC:L/AT:N/PR:N/UI:N, VC:H/VI:H/VA:H) scores 9.3 Critical and reflects unauthenticated, low-complexity code execution with full confidentiality, integrity and availability loss on the vulnerable system (no scope change to downstream systems). The vuln.today Decision label is act_now and CWE-94 (code injection) is corroborated by the GHSA advisory and the fix commit, so the technical impact is genuine rather than a high-CVSS-but-low-risk inflation. However, the network vector is conditional on data flow, not on a listening service: there is NO attacker request to the running app - exploitation requires that an attacker-controlled or attacker-influenced OpenAPI spec is processed by fastapi-code-generator < 0.8.1 and the generated module is then imported. This is effectively a build/CI-time supply-chain sink, which tempers the 'network unauthenticated' framing even though the metrics are defensible for an automated CI pipeline that fetches untrusted specs. No EPSS score and no KEV status are provided in the input, so real-world exploitation probability cannot be quantified and there is no confirmation of active exploitation; the GHSA advisory ships a reproduction script (reproduce.sh/make_spec.py, verified on 0.8.0), so working trigger mechanics are publicly documented. Net: treat as a real, actionable priority for anyone who code-generates FastAPI apps from untrusted or third-party OpenAPI specs; lower urgency for teams that only generate from trusted first-party specs.

Exploit ScenarioDerived

An attacker supplies or influences an OpenAPI document (e.g., a third-party or vendor-provided spec pulled into a CI pipeline) whose path contains a single quote that closes the generated @app.get('...') string and concatenates a live Python expression such as (__import__("os").system('...') or ""). When fastapi-code-generator < 0.8.1 emits main.py and the ASGI server or CI imports that module, the decorator argument is evaluated and the injected code runs at import/startup with the process's privileges - no HTTP request to the app is needed. A public proof-of-concept (reproduce.sh + make_spec.py) is attached to the GHSA advisory and was verified on version 0.8.0.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Nov 03, 2026

Import-time code execution in fastapi-code-generator prior to 0.8.1: the tool writes an OpenAPI path verbatim into a single-quoted @app.get('...') route decorator, so a path containing a single quote closes the string literal and lets an attacker splice a live Python expression into the decorator argument. The payload is evaluated when the generated main.py is imported (for example when the ASGI server starts or a CI job imports the module), giving code execution with the generating application's or pipeline's privileges without the running service ever being remotely reachable. Any workflow that generates a FastAPI app from an attacker-controlled or attacker-influenced spec is affected; a public proof-of-concept harness (reproduce.sh and make_spec.py attached to the advisory) was verified against 0.8.0, and the issue is fixed in 0.8.1.

RemediationAI

Upgrade fastapi-code-generator to 0.8.1, the vendor-released fix (release tag 0.8.1, implementing commits 49301dbdb82170d7f50877419d994b05cb1fa2bc and b3b9bd66e0b0c4d8c686fda700258104615a1332, which escape the path with repr-style single-quote escaping and validate path characters); see GHSA-p2mm-64f6-gmpp for the advisory. If upgrading is not immediately possible, treat every OpenAPI document fed to the generator as untrusted code rather than data: reject or sanitize spec path values that contain single quotes, backslashes or newlines before generation (legitimate REST paths rarely need them, but this is a control applied outside the tool and must be enforced in your ingestion step), and diff or review the generated @app.get(...) decorator lines before the module is imported. Note that quote-bearing input that breaks Python syntax only causes generation to fail, so a build error is a signal of attempted injection, not of safety. Because execution occurs only when the generated main.py is imported, avoid importing or serving generated modules produced from unverified specs, and keep generation runs that must handle third-party specs isolated from production credentials. The maintainer's complete fix is the escaping change shipped in 0.8.1.

Affected VersionsENISA

fastapi-code-generator < 0.8.1

Affected Packages

euvd fastapi_code_generator fix: 0.8.1

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

CWE-94 (code injection) with a CWE-116 improper-encoding component. fastapi-code-generator's parser builds route registrations by emitting the raw OpenAPI path as a single-quoted Python string literal inside the generated @app.get(...) decorator; most other interpolated fields (info.description, tags, parameter defaults) are quote-escaped, but the path was not, making it the specific unescaped sink described in the advisory, distinct from the operation-summary docstring sink and the additional-response-key sink in the same product. Because the generator post-processes its output with black/isort, a path that breaks Python syntax simply aborts generation (denial of service of the build), whereas a syntactically valid concatenation such as @app.get('/u/'+(__import__("os").system('…') or "")+'/x') is written out and evaluated at decorator evaluation time - that is, when the generated module is imported, typically at ASGI startup. Models produced through datamodel-code-generator are repr-escaped and are not part of this sink. The upstream fix adds a PythonEscapedString type whose single_quoted helper escapes backslashes, single quotes, carriage returns and newlines (and a triple_double_quoted helper for summaries) before the path, tags, summary and additional-response keys are emitted. Exploitation is not a matter of reaching the running application: it requires generator version < 0.8.1, an attacker-influenced spec with a quote-bearing path, a payload that remains valid Python, and an import of the generated module; fully trusted first-party specs remove the attacker input, and the assessed CVSS 3.1 vector is AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (GitHub_M) PRIMARY 9.3 CRITICAL
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
vuln.today AI 9.8 CRITICAL

Attacker-influenced spec consumed and imported by automated CI needs no privileges or app auth (PR:N, AC:L), and import-time arbitrary code execution yields full C/I/A on the unchanged scope.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Primary rating from Vendor (GitHub_M).

CVSS VectorVendor: GitHub_M

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

2
Patch available
Nov 03, 2026 - 20:02 EUVD
CVE Published
Nov 03, 2026 - 19:18 cve.org
CRITICAL 9.3

DescriptionCVE.org

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.

Technical POC Analysis

CWE-94: Improper Control of Generation of Code, with CWE-116 as a secondary weakness.

Full technical POC analysis - root cause, step-by-step exploitation and patch breakdown - is part of the Pro and Business plans.

Executive ViewAI

Why It Matters

A critical vulnerability in the fastapi-code-generator tool (versions before 0.8.1) enables arbitrary code execution when generating FastAPI applications from attacker-controlled OpenAPI specifications. This could allow attackers to compromise build pipelines or production systems, leading to data breaches or service disruption. Leadership should prioritize remediation because development and CI/CD environments are at risk.

Business Impact: High
Compensating Controls

Apply vendor patch. If unable to patch immediately, avoid using fastapi-code-generator with untrusted OpenAPI specifications and manually review generated code before execution.

Threat Intelligence Overview

Prevalence
Low
niche developer/CI code-generation tool, limited production deployment footprint
Data Quality
4 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS N/A
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

46
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +46
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy