datamodel-code-generator is vulnerable to Code Injection
75
High Risk
datamodel-code-generator builds Python import statements from the x-python-import and customTypePath schema extensions without checking that the values are dotted Python identifiers. A crafted OpenAPI or JSON Schema can embed a newline in these extension values to break out of the generated from ... import ... line and inject an attacker-controlled statement at module scope. Importing the generated model then runs that Python code with the importing process's privileges, allowing arbitrary file read and remote code execution under default settings. The fix validates x-python-import and customTypePath values as dotted Python identifier paths before they reach the import generator.
You are affected if you are using a version that falls within the vulnerable range and you generate models from untrusted OpenAPI or JSON Schema input.
datamodel-code-generator is vulnerable to Code Injection in versions 0.11.6 - 0.63.0.
Upgrade the datamodel-code-generator library to the patch version.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant