Skip to main content

fastapi-code-generator EUVDEUVD-2026-116146

| CVE-2026-63469 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
    Supply attacker-influenced OpenAPI spec
  2. Delivery
    Add malicious non-primary response status-code key
  3. Exploit
    Victim/CI runs fastapi-code-generator
  4. Execution
    Import evaluates responses={} decorator args
  5. Impact
    Arbitrary 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.

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 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

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

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

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

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.

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:15 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 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.

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

Why It Matters

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.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

Prevalence
Low
niche Python code-generation dev/CI tool, not broadly production-deployed
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