datamodel-code-generator < 0.84.0 Code Injection via x-python-type Annotation
- State
- Published
- Severity
- 8.6 High
- Published
- Nov 12, 2026
- Updated
- Nov 13, 2026
- Reserved
- Nov 12, 2026
Description
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.
| Product | Versions |
|---|---|
| datamodel-code-generator datamodel-code-generator | before 0.84.0 Affected |
| CVSS | Score | How It's Reached | Source |
|---|---|---|---|
| 4.0 | 8.6 High | VulnCheck | |
| 3.1 | 8.8 High | VulnCheck |
Weaknesses
- CWE-94 Improper Control of Generation of Code ('Code Injection')
References
- Release NotesRelease Notes
- Patch CommitPatchIssue Tracker
- VulnCheck Advisory: datamodel-code-generator < 0.84.0 Code Injection via x-python-type AnnotationThird-Party Advisory
Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.