Intel

AIKIDO-2026-156743

datamodel-code-generator is vulnerable to Code Injection

Code InjectionCVE-2026-55415 Published 3 days ago

75

High Risk

This Affects:

PYTHONdatamodel-code-generator
0.11.6 - 0.63.0
Fixed in 0.64.0
Are you affected? Scan for Free

TL;DR

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.

Who does this affect?

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.

Background info

datamodel-code-generator is vulnerable to Code Injection in versions 0.11.6 - 0.63.0.

How to fix this

Upgrade the datamodel-code-generator library to the patch version.