Code injection in datamodel-code-generator via x-python-type annotation
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- Active
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA. Impact type from CWE-94.
Summary
datamodel-code-generator before 0.84.0 contains a code injection flaw in how it handles crafted x-python-type annotations in JSON Schema input, tied to CWE-94. An attacker who supplies a malicious JSON Schema can run arbitrary code, because Pydantic v2 evaluates the injected expressions during model_rebuild(). The impact reaches developer workstations, CI/CD pipelines, and applications that generate and import the produced models at runtime.
Written with Claude Haiku 5.5 from the sources below · 2026-11-13
Description from the CNA
datamodel-code-generator before 0.84.0 contains a code injection vulnerability that allows attackers to achieve arbitrary code execution by supplying a malicious JSON Schema with a crafted x-python-type annotation containing a string ast.Constant node in a subscript slice position, which bypasses validation in parse_python_type_annotation and _python_type_expr_from_ast. Attackers can embed malicious Python expressions such as __import__ calls within quoted string literals in the generated source code, which Pydantic v2 evaluates as a ForwardRef via eval() during model_rebuild(), resulting in arbitrary code execution on developer workstations, CI/CD pipelines, or applications that generate and import the produced models at runtime.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| datamodel-code-generator | datamodel-code-generator | before 0.84.0 | 0.84.0 | Patch available | CNA |
- datamodel-code-generator Vendordatamodel-code-generator Affected before 0.84.0 Fixed in 0.84.0 Patch available CNA
Remediation
Upgrade datamodel-code-generator to version 0.84.0 or later, which fixes this issue.
Written with Claude Haiku 5.5 from the sources below · 2026-11-13
- Fix · CNA datamodel-code-generator (datamodel-code-generator) Fixed in 0.84.0
Timeline
- 2026-11-12 Threatist record created from CVE-2026-127208
- 2026-11-12 Alias added: GHSA-5hqf-87jh-5c5q
- 2026-11-13 CISA SSVC decision points changed
References
Patch 1
Other 1
More datamodel-code-generator vulnerabilities
- TI-2026-69604 Path traversal in datamodel-code-generator lets attackers write files CVSS 3.1HIGH 7.5
Sources
- CVE-2026-127208 · CVE Program
- CVE-2026-127208 · NVD
- FIRST EPSS
- GHSA-5hqf-87jh-5c5q · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences