fastapi-code-generator is vulnerable to Code Injection
93
CVE Score
Critical
Code Injection
Before the fix, parse_responses stored each non-primary response status-code key from the parsed raw_obj raw, and the generator wrote it into the route decorator's responses={...} dict as a single-quoted string without escaping. Anyone who controls or influences the OpenAPI document could close the key literal with a quote and inject a Python expression that ran when the generated module was imported by the application or CI. An operation needed a second response for the dict to be emitted, and syntax-breaking keys only aborted generation. The fix escapes every additional response status-code key with PythonEscapedString.single_quoted, blocking the injection.
Upgrade the fastapi-code-generator package to 0.8.1 or later.
You are affected if you are using a version that falls within the vulnerable range and generate apps from an OpenAPI document you do not fully control and import the generated code, with an operation declaring a second response.
0.3.1 - 0.8.0
Fixed in 0.8.1fastapi-code-generator is vulnerable to Code Injection in versions 0.3.1 - 0.8.0.
Secure your code, cloud, and runtime in one central system. Connect a repo to discover what the reasoning agents find in your codebase.
No credit card required | Scan results in 32 seconds.
I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant
ISO 42001Compliant© All Intel data is openly available and commercially licensed.