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

High 8.6 Published Updated

A malicious JSON schema can inject Python code into generated models, executing arbitrary code on developer workstations or CI pipelines that import them.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Harmful if only installed
No
Needs a specific call
No
Fix
None listed

What is CVE-2026-127208?

CVE-2026-127208 is a high-severity code injection vulnerability in datamodel-code-generator, published on 12 Nov 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official 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.

Weakness: CWE-94

Which versions are affected by CVE-2026-127208?

1 open source package ship an affected version, including datamodel-code-generator.

An affected version is exposed as installed. No special setting or call is needed.

PackageAffectedFixed in
datamodel-code-generator PyPI
pkg:pypi/datamodel-code-generator
All versions0.84.0

How do I fix CVE-2026-127208?

Upgrade datamodel-code-generator to 0.84.0 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2026-127208 being exploited?

There is no known exploitation of CVE-2026-127208 in the wild and no public exploit code.

Sources

Also known as GHSA-5hqf-87jh-5c5q.

Is CVE-2026-127208 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free