CVE-2026-54655 `datamodel-code-generator` vulnerable to code execution on import via `x-python-type` JSON-Schema extension in datamodel-code-generator

High 7.8 Published Updated

Attacker-controlled JSON Schema content can execute Python code when generated modules are imported, affecting users of datamodel-code-generator.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Local or same network only
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2026-54655?

CVE-2026-54655 is a high-severity code injection vulnerability in koxudaxi datamodel-code-generator, published on 28 Jul 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

Official description

datamodel-code-generator generates Python data models from schema definitions. From 0.51.0 until 0.60.2, x-python-type values parsed by src/datamodel_code_generator/parser/jsonschema.py in _get_python_type_override are inserted into generated field annotations without sufficient validation, allowing attacker-controlled JSON Schema content to execute Python code when the generated module is imported. This issue is fixed in version 0.60.2.

Weakness: CWE-94

Which versions are affected by CVE-2026-54655?

3 open source packages ship an affected version, including datamodel-code-generator.

PackageAffectedFixed in
datamodel-code-generator PyPIFrom 0.51.00.60.2
datamodel-code-generator PyPIFrom 0.51.00.60.2
datamodel-code-generator PyPIFrom 0.51.00.60.2

How do I fix CVE-2026-54655?

Upgrade datamodel-code-generator to 0.60.2 or later.

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

Is CVE-2026-54655 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-54655 exists.

Sources

Also known as GHSA-m34r-v34r-rf9q, PYSEC-2026-3562.

Is CVE-2026-54655 in your software?

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

Check your SBOMs for free