CVE-2026-63470

fastapi-code-generator: Call-time RCE via operation summary -> unescaped route-handler docstring

Published Nov 3, 2026 CVSS 4.0 · 9.3 Critical EPSS < 1% KEV · Not listed
Description
fastapi-code-generator creates FastAPI applications from OpenAPI files. Prior to 0.8.1, the generator inserts Operation.summary into a generated route-handler docstring as a triple-double-quoted string without escaping embedded triple quotes. An attacker-controlled or attacker-influenced operation summary can close the docstring and inject a valid Python expression statement into the handler body. Syntax-breaking input only causes generation to fail, but syntactically valid generated code executes with the server process's privileges when the affected route handler is called. This call-time route-handler docstring sink is distinct from the project's separate import-time route-path and additional-response-key sinks. This issue is fixed in version 0.8.1.

Analysis

AI-generated

Technical impact

The vulnerability arises when fastapi-code-generator inserts the operation.summary field from an OpenAPI specification directly into a generated route‑handler docstring without escaping embedded triple quotes. An attacker who can influence the operation.summary can terminate the docstring and inject a valid Python expression statement into the handler body. When the affected route handler is invoked, the injected code runs with the server process’s privileges, providing full remote code execution. This is a classic code‑injection flaw, classified as CWE‑94 and CWE‑116, with a CVSS score of 9.3 indicating critical severity.

Affected Systems

The flaw exists in the koxudaxi fastapi-code-generator product. All product releases prior to version 0.8.1 are affected. Any FastAPI application that was generated by this tool using an older version, especially when the OpenAPI specification’s operation summaries are under attacker control, could be vulnerable.

Risk and Exploitability

Without a patch, an attacker who can supply or modify the OpenAPI specification used to generate the application can embed arbitrary Python code. Because the exploitation occurs at runtime when the route is called, the attack requires the target server to host the generated application. The EPSS score is not available, and the vulnerability is not listed in CISA KEV. The CVSS score of 9.3 demonstrates high impact and potential for widespread exploitation if untrusted OpenAPI definitions are used.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade fastapi-code-generator to version 0.8.1 or later, which escapes operation summaries before inserting them into docstrings.
  • If upgrading is not immediately possible, sanitize or remove any operation summaries that originate from untrusted sources before feeding them to the generator; replace triple quotes or escape the string content.
  • Avoid using external or mutable OpenAPI specifications for code generation; prefer manually authored FastAPI code or a trusted source for schemas.
  • Consider disabling the automatic inclusion of operation.* fields in generated docstrings or removing the feature altogether if it is not needed for documentation purposes.

Generated by OpenCVE AI on November 3, 2026 at 20:38 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-h667-4jj2-cgv4 fastapi-code-generator: Call-time RCE via operation summary -> unescaped route-handler docstring
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description fastapi-code-generator creates FastAPI applications from OpenAPI files. Prior to 0.8.1, the generator inserts Operation.summary into a generated route-handler docstring as a triple-double-quoted string without escaping embedded triple quotes. An attacker-controlled or attacker-influenced operation summary can close the docstring and inject a valid Python expression statement into the handler body. Syntax-breaking input only causes generation to fail, but syntactically valid generated code executes with the server process's privileges when the affected route handler is called. This call-time route-handler docstring sink is distinct from the project's separate import-time route-path and additional-response-key sinks. This issue is fixed in version 0.8.1.
Title fastapi-code-generator: Call-time RCE via operation summary -> unescaped route-handler docstring
Weaknesses CWE-116
CWE-94
References
Metrics cvssV4_0

{'score': 9.3, 'vector': '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'}

Subscriptions

No data.

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

  • CWE-94

    Improper Control of Generation of Code ('Code Injection')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Nov 3, 2026, 7:34 PM
Reserved
Jul 16, 2026, 9:37 PM
Status
Deferred
Published
Nov 3, 2026, 8:18 PM
Modified
Nov 3, 2026, 8:31 PM