# CVE-2026-54655: koxudaxi datamodel-code-generator code injection via x-python-type extension

Source: https://junglewise.ai/threats/cve-2026-54655-koxudaxi-datamodel-code-generator-code-injection-via-x-python  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-28. Updated: 2026-07-28  
License: CC BY 4.0 with a link back

CVE-2026-54655 · Severity: high · CVSS 7.8 · Published 2026-07-28

datamodel-code-generator is a tool used to automatically create Python code from data schemas like OpenAPI or JSON Schema. A security flaw allows a malicious schema to inject hidden Python code into the generated files. If a developer or automated system imports the resulting Python file, the injected code will automatically execute, potentially allowing an attacker to steal data, disrupt operations, or compromise the developer's workstation or CI/CD environment.

Technologies: [Koxudaxi Datamodel-Code-Generator](https://junglewise.ai/threats/technologies/datamodel-code-generator), [datamodel-code-generator (PyPI)](https://junglewise.ai/threats/technologies/pypi-datamodel-code-generator). Vendors: [Koxudaxi](https://junglewise.ai/threats/vendors/koxudaxi), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

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

**How severe is CVE-2026-54655?** High severity, with a CVSS score of 7.8, published 28 July 2026.

**Which products and versions are affected?** Koxudaxi Datamodel-Code-Generator >= 0.51.0, < 0.60.2, >= 0.51.0, <= 0.60.1; datamodel-code-generator (PyPI) ECOSYSTEM:introduced=0.51.0,fixed=0.60.2.

**Is there a fix for CVE-2026-54655?** Yes. datamodel-code-generator (PyPI): upgrade to 0.60.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-54655 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2026-54655?** Check whether you run Koxudaxi Datamodel-Code-Generator or datamodel-code-generator (PyPI) 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

- datamodel-code-generator (PyPI): upgrade to 0.60.2 or later

  ```sh
  pip install "datamodel-code-generator>=0.60.2"
  ```


## Technical details

A code injection vulnerability exists in datamodel-code-generator's JSON Schema parser within the `_get_python_type_override` method. The tool fails to sufficiently validate values provided in the `x-python-type` extension, forwarding them verbatim into generated Python field annotations. An attacker can craft a schema using specific syntax (e.g., using semicolons or brackets) to bypass the single sanitization check and embed arbitrary Python statements. These statements are executed at class-definition time when the generated module is imported. The vulnerability affects multiple output formats including Pydantic models, dataclasses, and TypedDicts. The issue is resolved in version 0.60.2 by implementing AST-based validation of type annotations.

## Affected products

- koxudaxi datamodel-code-generator >= 0.51.0, < 0.60.2

## Identifiers

- CVE-2026-54655
- GHSA-m34r-v34r-rf9q
- PYSEC-2026-3562

## Timeline

- 2026-06-08: patched: Fix included in version 0.60.2
- 2026-07-28: disclosed: CVE-2026-54655 published

## References

- [https://github.com/koxudaxi/datamodel-code-generator/commit/2c93c9b712f43391dcfa975a1e4aa0b7c93ccbba](https://github.com/koxudaxi/datamodel-code-generator/commit/2c93c9b712f43391dcfa975a1e4aa0b7c93ccbba)
- [https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2](https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2)
- [https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-m34r-v34r-rf9q](https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-m34r-v34r-rf9q)

## 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)
- [koxudaxi datamodel-code-generator code injection in generated imports](https://junglewise.ai/threats/cve-2026-55415-koxudaxi-datamodel-code-generator-code-injection-in-generated)
- [koxudaxi datamodel-code-generator credential leak in cross-origin redirects](https://junglewise.ai/threats/cve-2026-55403-koxudaxi-datamodel-code-generator-credential-leak-in-cross-origin)
- [koxudaxi datamodel-code-generator SSRF via DNS rebinding](https://junglewise.ai/threats/cve-2026-55391-koxudaxi-datamodel-code-generator-ssrf-via-dns-rebinding)
- [koxudaxi datamodel-code-generator path traversal in XML Schema parsing](https://junglewise.ai/threats/cve-2026-55390-koxudaxi-datamodel-code-generator-path-traversal-in-xml-schema)
