CVE-2026-55415
PoC largePython code injection in datamodel-code-generator via malicious schema imports
datamodel-code-generator versions 0.11.6 up to (but not including) 0.64.0 fail to neutralize the attacker-controllable x-python-import and customTypePath schema extensions when building import statements for generated Python models. An attacker who can influence an OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, or raw JSON/YAML/CSV input used for code generation can embed a newline character in one of these extensions, breaking out of the import statement written into the generated file. When a developer or application later imports the generated model, the injected statements execute as Python code in that process, giving the attacker arbitrary code execution with high confidentiality and integrity impact. Anyone who runs the generator on schemas they do not fully control — including CI pipelines and services that consume third-party API specifications — is affected; the flaw is in generated code, so the execution occurs wherever the generated module is imported, not necessarily on the machine that ran the generator. No in-the-wild exploitation is currently known: EPSS is low (0.4%, 35th percentile), the CVE is not in CISA KEV, and the issue is documented in a public GitHub security advisory (GHSA-5578-w22f-pfx9).
What to do: Upgrade datamodel-code-generator to version 0.64.0 or later and regenerate any models that were produced from schemas you do not fully control. Audit previously committed generated files for suspicious import lines (e.g., extra code following an import) traceable to x-python-import or customTypePath values, and treat those schema extensions in third-party specs as untrusted input until upgraded.
| koxudaxi datamodel-code-generator | >= 0.11.6 and < 0.64.0 (fixed in 0.64.0) |
Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.
datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. From 0.11.6 until 0.64.0, datamodel-code-generator allows attacker-controlled x-python-import or customTypePath schema extensions to reach src/datamodel_code_generator/parser/jsonschema.py and generated import handling through Import.from_full_path and Imports.create_line in src/datamodel_code_generator/imports.py, allowing a newline to break out of an import statement and execute Python code when the generated model is imported. This issue is fixed in version 0.64.0.
- Vendors
- koxudaxi
- Products
- datamodel-code-generator
- Weakness
- CWE-94, CWE-95
- Vector
- CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
In the news0 stories
No ingested article mentions this CVE yet.