Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSupply attacker-influenced OpenAPI spec
-
DeliveryAdd malicious non-primary response status-code key
-
ExploitVictim/CI runs fastapi-code-generator
-
ExecutionImport evaluates responses={} decorator args
-
ImpactArbitrary code executes with app/CI privileges
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 | Requires fastapi-code-generator prior to 0.8.1 processing an OpenAPI operation that defines MULTIPLE responses - the responses={...} decorator dict is only emitted when a second (non-primary) response exists, so single-response operations are not a sink. The attacker must control or influence that secondary response's status-code key, and the payload must be syntactically valid Python kept valid via concatenation (e.g. ('+expr+' with (... or "")); a syntax-breaking payload only aborts generation at the black/isort post-process step (DoS, not RCE). Execution occurs when the generated main.py is imported or served (ASGI startup imports it) in the victim or CI environment, with no HTTP request needed. Limiting factors: the attacker must be able to inject into the OpenAPI spec that the victim generates from, the operation must be multi-response, and the victim must actually run the generator and import/serve the output - related sinks (content-type key normalized to 'model', info.* repr-escaped, operationId fails closed) are not exploitable. |
| Impact | This is a genuine high-priority issue for the population that uses it, but its blast radius is narrow. The signals are mostly aligned: CVSS 4.0 base is 9.3 (Critical) with AV:N/AC:L/AT:N/PR:N/UI:N and full VC:H/VI:H/VA:H, CWE-94 code injection, and the vuln.today decision label is act_now - all pointing to a deterministic, high-impact code-execution flaw. A verified PoC (reproduce.sh/make_spec.py) is attached to the GHSA advisory and a fix exists (0.8.1), so there is no ambiguity about reality or mechanism. However, two risk-dampening facts must be stated explicitly: the input contains NO EPSS score and NO CISA KEV listing, so there is no evidence of active or widespread exploitation - this is not a confirmed in-the-wild threat, and real exposure depends entirely on whether a deployment feeds attacker-influenced OpenAPI specs into the generator. Also note a tension with the CVSS vector: it is scored AV:N/PR:N/UI:N as if remotely triggerable, but exploitation actually requires a victim or CI pipeline to run the code generator on the malicious spec and then import the generated module - the 'network, no interaction' rating reflects the data-injection framing (processing an attacker-supplied spec), not a direct unauthenticated network request. Net: treat as urgent patch for anyone generating FastAPI apps from untrusted/third-party OpenAPI specs in CI or at startup; lower practical urgency for teams that only generate from fully trusted, internally-authored specs. |
| Exploit ScenarioDerived | An attacker who can influence an OpenAPI spec consumed by a victim's build/CI pipeline (e.g., a third-party or user-submitted API definition) adds a multi-response operation whose non-primary response status-code key embeds a valid Python expression such as '404' + (__import__("os").system('...') or "") + 'x'. When fastapi-code-generator (< 0.8.1) emits the responses={...} decorator dict, the unescaped single-quoted key injects the live expression, which executes the moment the generated main.py is imported - for example at ASGI server startup or during CI - requiring no HTTP request. A working PoC verified against 0.8.0 is attached to the advisory. |
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 lets an attacker who controls or influences an OpenAPI specification place a crafted secondary response status-code key that is emitted verbatim into the generated route decorator's responses={...} dictionary; because the key is written as a single-quoted Python literal without escaping embedded quotes, a valid expression can be concatenated into the decorator argument and runs as soon as the generated module is imported or served by the ASGI server, requiring no HTTP request. Only multi-response operations are a sink, since the responses dictionary is emitted solely when a second non-primary response exists, and remote, unauthenticated conditions apply (CVSS:4.0 AV:N/AC:L/PR:N/UI:N, all impact metrics High). It is not in CISA KEV and no exploitation in the wild is reported; a proof-of-concept reproducer is attached to the GitHub advisory and was verified against version 0.8.0, and the priority decision label is act_now. Patch status: Vendor-released patch: 0.8.1.
RemediationAI
Upgrade fastapi-code-generator to version 0.8.1, the vendor-released fix; the escape helper and the application of PythonEscapedString to path, summary, tags and each additional response status-code key are in commits 49301dbdb82170d7f50877419d994b05cb1fa2bc and b3b9bd66e0b0c4d8c686fda700258104615a1332, and the release is published at https://github.com/koxudaxi/fastapi-code-generator/releases/tag/0.8.1 with full details in the advisory at https://github.com/koxudaxi/fastapi-code-generator/security/advisories/GHSA-6xmv-cjr5-w3q8. Where an immediate upgrade is not possible, the exposure window can be narrowed by refusing to generate from OpenAPI documents that define additional non-primary responses, or by pre-validating every status-code key against a strictly numeric pattern and rejecting any key containing quotes, backslashes or newlines before generation - with the trade-off that multi-response operations must then be modelled outside the generated app. Because the payload executes at import time rather than at request time, run generation only inside disposable, least-privilege build containers that hold no production secrets and have no outbound network access, and review generated decorators before serving them; disabling the black/isort post-processing step is not a mitigation, since it only changes whether a malformed payload fails generation or is emitted.
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
fastapi-code-generator (koxudaxi) turns OpenAPI documents into FastAPI source code. The defect is CWE-94 code injection amplified by CWE-116 improper encoding/escaping: when an operation declares more than one response, the generator writes each additional status code as a single-quoted dictionary key inside the @app.get(..., responses={...}) decorator - for example '404': {'model': Thing} - without escaping an embedded apostrophe. A status-code key containing a quote therefore terminates the string literal, and a payload kept syntactically valid through concatenation such as '404' + (__import__("os").system('...') or "") + 'x' is emitted as live Python; the generator post-processes output with black and isort, so a payload that breaks syntax only aborts generation (denial of service) while a valid one is preserved and evaluated at decorator-evaluation time when main.py is imported, including at ASGI startup. This is a distinct sink from the project's route-path to @app.get('...') and operation-summary to handler-docstring findings: the affected field is the additional response status-code key and the position is the responses={...} decorator dictionary key. Related fields are not exploitable - the response content-type key is normalized to 'model', info.* values are repr-escaped, operationId to function_name fails closed, and models come from datamodel-code-generator and are repr-escaped. The upstream fix introduces a PythonEscapedString wrapper that escapes backslashes, single quotes, carriage returns and newlines for single-quoted emission (and triple-quote escaping for summaries) and applies it to paths, summaries, tags and additional response keys, with the advisory recommending validation that status-code keys are numeric or match a known pattern.
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
Deterministic unescaped-dict-key injection in an attacker-influenced spec needs no auth and runs code at import with full C/I/A impact, so AC:L/PR:N and S:U.
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 additional response status-code key into the generated responses={...} route-decorator dictionary as a single-quoted Python string without escaping embedded quotes. A multi-response OpenAPI operation with an attacker-controlled or attacker-influenced second non-primary response key can close the dictionary-key literal and inject a valid Python expression. 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 its decorator arguments are evaluated. This additional-response-key sink is distinct from the project's separate route-path and operation-summary sinks. This issue is fixed in version 0.8.1.
Articles & Coverage 2
Technical POC Analysis
Primary bug class: CWE-94, Improper Control of Generation of Code; advisory also lists CWE-116.
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 fastapi-code-generator (versions before 0.8.1) allows arbitrary code execution during import of generated code, enabling attackers who influence OpenAPI specifications to execute malicious code without any HTTP request. This affects development teams using the tool, potentially compromising build servers and production environments that deploy generated APIs. Leadership should prioritize this due to the high severity and the potential for significant business disruption if exploited.
Apply vendor patch.
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-116146
NVD
CVE.org
GitHub
Exploit-DB