CVE-2026-127208: datamodel-code-generator < 0.84.0 Code Injection via x-python-type Annotation

Published Nov 12, 2026
·
Updated

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 parsepythontypeannotation and pythontypeexprfromast. 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 modelrebuild(), resulting in arbitrary code execution on developer workstations, CI/CD pipelines, or applications that generate and import the produced models at runtime.

Event History

Nov 12, 2026
CVE Published
via MITRE·08:58 PM
Data Sourced
via MITRE·08:58 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Who is exposed to this issue?

Developer workstations, CI/CD pipelines, and applications are exposed when they process an attacker-supplied JSON Schema with datamodel-code-generator and then import the generated models or rebuild them at runtime.

2

What does an attacker need to exploit it?

An attacker needs to supply a malicious JSON Schema containing a crafted x-python-type annotation. Exploitation also requires user interaction in the form of generating and importing the resulting models, or otherwise invoking Pydantic v2 model_rebuild() on them.

3

What versions should be remediated?

Versions of datamodel-code-generator earlier than 0.84.0 are affected. Upgrade to version 0.84.0 or later.

4

How can teams identify potentially affected generated code?

Review schemas and generated model source for x-python-type annotations and suspicious quoted Python expressions, particularly expressions containing __import__ calls. Treat generated models derived from untrusted schemas as potentially unsafe if they were imported or rebuilt with Pydantic v2.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203