CVE-2026-127208 · Package
NO FIX YET · SEE WHAT TO DO
datamodel-code-generator before 0.84.0 fails to validate the x-python-type annotation in a JSON Schema, so a malicious schema can put Python expressions into generated models. When Pydantic v2 evaluates those strings during model_rebuild(), the attacker's code runs on the developer workstation, CI pipeline, or application that imports the models.
first public Nov 12, 2026 · 1 source
Check it with your coding agent
It reads this page and tells you if your code or app is affected.
Any team that runs datamodel-code-generator on JSON Schemas it does not fully control, or imports the generated models at runtime with Pydantic v2. Teams that only generate models from their own trusted schemas, in a sealed build, are less exposed but should still upgrade. The sources do not say whether a default configuration is exposed.
Not affected if no-runtime-model-import, trusted-schemas-only
Who cares ci-cd, datamodel-code-generator, pydantic, python
datamodel-code-generator --version or pip show datamodel-code-generator.x-python-type.model_rebuild().0.84.0 or later.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.
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
InfraStack checks it against your stack and answers on your report, with the evidence and the fix.
This page as .md · .json · CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.