Technical impact
fastapi-code-generator builds a FastAPI application from an OpenAPI file. When the generator creates the @app.get('…') decorator, it embeds the OpenAPI path directly into a single‑quoted string without escaping embedded quotes. An attacker who can influence the OpenAPI path can close the string and insert arbitrary Python code. Syntax‑breaking payloads merely break the generation process, but any syntactically valid payload results in the inserted code being executed at import time, which runs with the privileges of the application or CI pipeline that imports the generated module.
Affected Systems
The vulnerable library is koxudaxi:fastapi-code-generator. All releases prior to version 0.8.1 contain the flaw. Updating to 0.8.1 or newer removes the unsafe string construction.
Risk and Exploitability
The CVSS score of 9.3 indicates a high‑severity local or remote code execution risk. The EPSS score is unavailable, so it is unclear how frequently the flaw is exploited, but the vulnerability is actively listed in the vendor security advisory and has not yet been added to CISA’s KEV catalog. The attack vector is the generation of a route string from a user‑controlled OpenAPI file; the vulnerability is exploitable when the generated module is imported, such as during normal application startup or continuous‑integration builds. An attacker who can supply a malicious OpenAPI file and trigger import of the generated code can execute arbitrary code with the process’s privileges.
Github GHSA