Track vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
9.9
CVE-2026-127208: datamodel-code-generator can run malicious code
CVE-2026-127208 · published 6 days ago
Summary
The datamodel-code-generator tool (versions before 0.84.0) can be tricked into inserting and running harmful Python code when it processes a specially crafted JSON schema. This could let an attacker execute commands on a developer's computer, build servers, or any system that automatically creates and loads the generated models. Update the tool to version 0.84.0 or later, and avoid using untrusted schemas for code generation.
What to do
- Update datamodel-code-generator datamodel-code-generator to version 0.84.0 or later.
Affected software
| Vendor | Product | Affected versions |
|---|---|---|
| datamodel-code-generator | datamodel-code-generator | < 0.84.0 |
Original advisory text
datamodel-code-generator < 0.84.0 Code Injection via x-python-type Annotation
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.
References
- https://github.com/datamodel-code-generator/datamodel-code-generator/commit/ebfc... Patch
- https://github.com/datamodel-code-generator/datamodel-code-generator/releases/ta... Vendor Advisory
- https://www.vulncheck.com/advisories/datamodel-code-generator-code-injection-via... Vendor Advisory
- https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/127xxx/CVE-2026-1272... Vendor Advisory
- https://github.com/datamodel-code-generator/datamodel-code-generator Product
- https://nvd.nist.gov/vuln/detail/CVE-2026-127208 Vendor Advisory
Internet-facing
14 days
Internal
At next upgrade
- Not known to be exploited
- Needs hands-on effort to exploit
- Gives an attacker full control
Severity
9.9
Critical
Type
CWE-94Code Injection
Timeline
Published12 Nov 2026
Updated19 Nov 2026
First seen12 Nov 2026
Track software like this
Free during beta