# CVE-2026-127208: datamodel-code-generator code injection in type annotation parsing

Source: https://junglewise.ai/threats/cve-2026-127208-datamodel-code-generator-before-0-84-0-contains-a-code-injection  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-11-12. Updated: 2026-11-12  
License: CC BY 4.0 with a link back

CVE-2026-127208 · Severity: high · CVSS 8.8 · Published 2026-11-12

datamodel-code-generator is a tool that generates Python data model code from schemas like JSON Schema and OpenAPI. Before version 0.84.0, attackers can inject arbitrary Python code by crafting a malicious JSON Schema with specially formatted type annotations; the generated code then executes this malicious Python when imported into applications or CI/CD pipelines. This allows complete compromise of developer workstations and build systems that process untrusted schemas.

## Quick answers

**Is CVE-2026-127208 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-127208 being exploited in the wild.

**How severe is CVE-2026-127208?** High severity, with a CVSS score of 8.8, published 12 November 2026.

**Which products and versions are affected?** Datamodel-Code-Generator before 0.84.0.

**Is there a fix for CVE-2026-127208?** Yes: fixed in 0.84.0. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-127208 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-127208?** Check whether you run Datamodel-Code-Generator at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Fixed in 0.84.0

## Technical details

The vulnerability is a code injection flaw in parse_python_type_annotation and _python_type_expr_from_ast functions that fail to validate string constants in subscript slice positions. An attacker supplies a JSON Schema with a crafted x-python-type annotation containing a quoted string (ast.Constant node) in a subscript, which bypasses validation and renders as a forward reference in generated Python code. When Pydantic v2 evaluates this generated code via eval() during model_rebuild(), arbitrary Python expressions embedded in the string literals are executed, granting arbitrary code execution to any system processing the schema.

## Affected products

- datamodel-code-generator datamodel-code-generator before 0.84.0

## Timeline

- 2026-11-12: disclosed

## References

- [https://github.com/datamodel-code-generator/datamodel-code-generator/commit/ebfc11d0644d37a71374b28aac06d98748e584ec](https://github.com/datamodel-code-generator/datamodel-code-generator/commit/ebfc11d0644d37a71374b28aac06d98748e584ec)
- [https://github.com/datamodel-code-generator/datamodel-code-generator/releases/tag/0.84.0](https://github.com/datamodel-code-generator/datamodel-code-generator/releases/tag/0.84.0)

## Related threats

- [datamodel-code-generator Protobuf path traversal allows files to be written outside directory](https://junglewise.ai/threats/cve-2026-107377-datamodel-code-generator-protobuf-weak-import-path-traversal)
