CVE-2026-127208 datamodel-code-generator < 0.84.0 Code Injection via x-python-type Annotation
- Published
- Updated
- Exploit status
- No public exploit known
- CISA SSVC
- No known exploitation · automatable: no · technical impact: total
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.
Upgrade path
1 package: 1 fixed.
| Package | Affected | Fixed in | Status |
|---|---|---|---|
| pypi datamodel-code-generator | < 0.84.0 | 0.84.0 | Fixed |
Affected products
| Product | Affected versions | Fixed in |
|---|---|---|
| pypi datamodel-code-generator | < 0.84.0 | 0.84.0 |
References
- Release Notes release-notes
- Patch Commit issue-tracking patch
- VulnCheck Advisory: datamodel-code-generator < 0.84.0 Code Injection via x-python-type Annotation third-party-advisory
- ENISA EUVD EUVD-2026-124714 third-party-advisory