CVE-2026-55415: datamodel-code-generator vulnerable to code injection via `x-python-import` / `customTypePath` in generated import statements
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.
Security readout for executives and security teams
Plain-English summary
A malicious schema can insert Python code into generated models. That code executes when the model is imported, potentially compromising developer workstations, build systems, or applications. Exploitation requires a vulnerable generator, attacker-controlled schema content, and a user or process importing the generated output.
Executive priority
Prioritize remediation where external schemas enter automated build or code-generation workflows. Compromise could affect confidentiality, integrity, and availability with the permissions of the importing process. Environments using only trusted schemas remain affected by version, but have lower practical exposure.
Technical view
Versions 0.11.6 through 0.63.x insufficiently constrain x-python-import or customTypePath values. A newline can escape generated import syntax through Import.from_full_path and Imports.create_line, producing attacker-controlled Python statements. The vulnerability is classified as CWE-94/CWE-95 and fixed in version 0.64.0.
Likely exposure
Highest exposure exists where CI/CD pipelines, developer tooling, or services generate models from externally supplied or insufficiently trusted schemas, then import those models. Installations below 0.64.0 are affected, but package presence alone does not prove an exploitable data flow.
Exploitation context
The supplied sources do not report active exploitation, and this CVE is not identified as KEV. Exploitation has high complexity and requires user interaction because malicious schema input must reach generation and the resulting Python model must subsequently be imported.
Researcher notes
The relevant trust boundary is schema content reaching generated Python imports. Assessment should trace schema provenance, extension handling, artifact review, and subsequent imports. The supplied bundle identifies the vulnerable functions and fixing commit, but provides no evidence of exploitation in the wild.
Mitigation direction
Upgrade datamodel-code-generator to version 0.64.0 or later.
Regenerate models previously created from untrusted or externally supplied schemas.
Review generated Python files before importing or deploying them.
Restrict schema ingestion to trusted sources until upgrades and artifact reviews are complete.
Validation and detection
Inventory datamodel-code-generator versions across developer, CI/CD, and production environments.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-94: Code execution behavior lookup
Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Code execution and unsafe deserialization weaknesses often justify reviewing execution behavior and process telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
1ADP providers
4Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: pocAutomatable: noTechnical Impact: total
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-94 · source CWE mapping
Improper Control of Generation of Code ('Code Injection')
Improper Control of Generation of Code ('Code Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')
Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.