On this page (7 sections)
A critical flaw in fastapi-code-generator, the tool that turns OpenAPI files into FastAPI applications, lets a crafted API specification put attacker-chosen Python into the generated code. That code runs as soon as the generated module is imported, which for a web service means at server startup. The issue is tracked as CVE-2026-63469 and is fixed in version 0.8.1.
If you generate server code from OpenAPI files you did not write yourself, or run the generator inside CI pipelines, this one is for you. Our research found only the project's GitHub advisory (a primary source) and the CVE record text supplied with it, with no independent reporting yet. The advisory and the CVE record are not independent confirmation of each other, so treat the details below as coming from a single line of reporting.
What happened
fastapi-code-generator reads an OpenAPI document and writes a Python FastAPI app. For each operation that has more than one response, it emits a responses={...} dictionary in the route decorator. According to the GitHub advisory, the extra response status-code keys were written into that dictionary as single-quoted Python strings without escaping embedded quote characters.
That means a status-code key containing a quote can close the string early and continue as live Python. Because decorator arguments are evaluated when the module loads, the injected expression runs on import, with no incoming request needed. The project's GitHub security advisory describes the same behavior. The CVE description (the record text supplied with the research, not a separate investigation) adds that syntactically valid generated code executes with the privileges of the application or CI process.
Technical details
This is a classic output-encoding failure. The status-code key in an OpenAPI file looks like pure data, usually a number such as an HTTP status. The generator treated it as trusted text and pasted it into source code. Anything that builds code from data has to escape or validate that data for the target language, and here it did neither for this field.
The advisory adds several details worth knowing:
- The
responses={...}dictionary is only emitted when an operation has a second, non-primary response, so the dangerous key is any additional response status. - The generator post-processes output with black and isort. Input that breaks Python syntax makes generation fail, which is a denial of service at most. Input that stays valid Python is written out and runs at import.
- The response content-type key is not a sink, because it is normalized. Fields under
infoare escaped with repr, andoperationIdfails closed when used as a function name. - The advisory says this is distinct from the project's separate route-path and operation-summary findings. It is a different field in a different position.
The advisory reports verification on version 0.8.0 with Python 3 and FastAPI, and says it attaches a proof of concept that generates an app and only imports it. We are not reproducing any payload here. The suggested fix is to escape each status-code key for a Python string literal and to validate that keys are numeric or follow a known pattern.
Who is affected
The generator is a build-time tool, so your running API is not vulnerable to a stranger simply sending requests. The risk sits in the pipeline that creates the code. You are realistically exposed if any of these apply:
- You generate FastAPI apps from OpenAPI files supplied by partners, customers, third-party vendors or public repositories.
- Your specs live in a repository where many contributors or automated tools can change them, and generation runs automatically on every change.
- CI runners that generate and then import the app hold deploy keys, cloud credentials or package-publishing tokens.
- You pull specs from a remote URL at build time.
If only your own team writes the specs and reviews every change, the practical risk is lower, but upgrading is still cheap and the right move.
How to check your exposure
First find out whether the package is installed and which version. This read-only command, run in the Python environment you use for generation (including CI images), prints the installed version. Anything below 0.8.1 is affected.
pip show fastapi-code-generatorThen search your repositories and lockfiles for pinned versions. This read-only grep lists files that mention the package so you can check each pin.
grep -rn "fastapi-code-generator" --include="requirements*.txt" --include="pyproject.toml" --include="Pipfile*" --include="poetry.lock" .Also review your specs. Response keys under each operation's responses should be plain HTTP status codes such as 200 or 404, or the literal default. Anything containing quotes, parentheses or other punctuation in that position deserves immediate review and should be treated as suspicious.
What to do now
- Upgrade fastapi-code-generator to 0.8.1 or later everywhere it is installed: developer machines, CI images and build containers.
- Pin the fixed version in requirements or lockfiles so older builds do not creep back in.
- Review OpenAPI specs from outside sources before generating code, and look for unusual characters in response status-code keys.
- Check recently generated
main.pyfiles and any code generated before the upgrade for unexpected expressions insideresponses={...}dictionaries. - If a suspicious spec was ever generated and imported, treat that machine or runner as potentially compromised and rotate the secrets it could reach.
- Run generation in an isolated, low-privilege environment without production credentials, and avoid importing generated code on a machine that holds secrets until it has been reviewed.
This command upgrades the package to the fixed release. Run it in each affected Python environment, then re-run the version check above to confirm it shows 0.8.1 or later.
pip install --upgrade "fastapi-code-generator>=0.8.1"The advisory also refers to separate route-path and operation-summary findings in the same project. The research does not say which version fixed those two, and the CVE record states only that the response status-code key issue is fixed in 0.8.1. Check the project's security advisories and the 0.8.1 release page for those findings directly, rather than assuming 0.8.1 covers them.
Detection and monitoring
Because the flaw triggers at import, signs of abuse would show up around service startup or CI job runs rather than in web traffic. Useful things to watch:
- Unexpected outbound connections or new processes spawned by CI jobs during the generate and import steps.
- Code review diffs on generated files that include imports of system-level modules or function calls inside decorator arguments.
- Changes to OpenAPI files from new contributors or external sources, flagged for manual review before generation runs.
- Unexplained use of CI secrets, deploy tokens or cloud credentials.
For the deployed side, keep an eye on what your public site and APIs expose. A security scan of your verified sites and change monitoring can help you notice unexpected changes, though neither can see inside your build pipeline. For wider habits, see our guide to small business website security.
Timeline
| Date | Event as reported |
|---|---|
| Jul 1, 2026 | Shown in the advisory header as "Published ... in koxudaxi/fastapi-code-generator" |
| Nov 3, 2026 | Published by the National Vulnerability Database |
| Nov 9, 2026 | Published to the GitHub Advisory Database, reviewed and last updated |
The Jul 1, 2026 date comes only from the advisory header. The sources do not explain the gap between it and the NVD publication on Nov 3, 2026, so we are listing the dates as reported and not inferring a disclosure sequence from them.
The fix is available in release 0.8.1, with the code changes in two commits (49301db and b3b9bd6). The sources do not report active exploitation.
Sources
This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.
