CVE-2026-127208 Details
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.
A code injection vulnerability has been identified in datamodel-code-generator versions prior to 0.84.0. This vulnerability allows attackers to execute arbitrary code by sending a malicious JSON Schema that includes a crafted x-python-type annotation. The annotation can contain a string ast.Constant node positioned in a subscript slice, which evades validation and is processed in a way that executes embedded Python expressions, such as __import__ calls. This exploitation occurs when the generated code is used with Pydantic v2, which evaluates the injected expressions during model rebuilding, leading to code execution on developer workstations, CI/CD pipelines, or within applications that dynamically generate and import models at runtime.
Users are advised to upgrade to datamodel-code-generator version 0.84.0 or later, where this vulnerability has been patched.
Metrics
CVSS 4.0 Severity and Vector Strings:
CVSS 3.x Severity and Vector Strings:
No data available for CVSS Version 2.0 on this CVE.
Volerion
Assessed Nov 12, 2026CISA-ADP
Assessed Nov 13, 2026References to Advisories, Solutions, and Tools
By selecting these links, you will be leaving this site. These are references gathered from the official CVE record and are not endorsed by Volerion.
Weakness Enumeration
| CWE-ID | CWE Name | Source |
|---|---|---|
| CWE-94 | Improper Control of Generation of Code ('Code Injection') | [email protected] |
Affected Products
| Product | Versions |
|---|---|
| datamodel-code-generator | < 0.84.0 (semver) |
CPE
Remediation
| |
Change History
2 change records found show changes
| Date | Action | Recorded By |
|---|---|---|
| Nov 13, 2026 | CVE Modified | CISA-ADP |
| Nov 12, 2026 | New CVE Received | [email protected] |
Volerion