Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessCraft OpenAPI spec with quote-breaking path
-
DeliveryDeliver spec into victim generation/CI pipeline
-
ExploitGenerator emits unescaped @app.get('...') decorator
-
ExecutionVictim imports generated main.py
-
PersistDecorator expression evaluated at import
-
ImpactArbitrary 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. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – 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
Affected Packages
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
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
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.
Primary rating from Vendor (GitHub_M).
CVSS VectorVendor: GitHub_M
Lifecycle Timeline
2DescriptionCVE.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.
Articles & Coverage 2
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
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.
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
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.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
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.
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
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
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
EUVD-2026-116147
NVD
CVE.org
GitHub
Exploit-DB