ZeroHour

CVE-2026-55415

PoC large

Python code injection in datamodel-code-generator via malicious schema imports

CVSS 3.1
7.5 high
EPSS
<1%p35
Published
()
Modified
AI analysis

datamodel-code-generator versions 0.11.6 up to (but not including) 0.64.0 fail to neutralize the attacker-controllable x-python-import and customTypePath schema extensions when building import statements for generated Python models. An attacker who can influence an OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, or raw JSON/YAML/CSV input used for code generation can embed a newline character in one of these extensions, breaking out of the import statement written into the generated file. When a developer or application later imports the generated model, the injected statements execute as Python code in that process, giving the attacker arbitrary code execution with high confidentiality and integrity impact. Anyone who runs the generator on schemas they do not fully control — including CI pipelines and services that consume third-party API specifications — is affected; the flaw is in generated code, so the execution occurs wherever the generated module is imported, not necessarily on the machine that ran the generator. No in-the-wild exploitation is currently known: EPSS is low (0.4%, 35th percentile), the CVE is not in CISA KEV, and the issue is documented in a public GitHub security advisory (GHSA-5578-w22f-pfx9).

What to do: Upgrade datamodel-code-generator to version 0.64.0 or later and regenerate any models that were produced from schemas you do not fully control. Audit previously committed generated files for suspicious import lines (e.g., extra code following an import) traceable to x-python-import or customTypePath values, and treat those schema extensions in third-party specs as untrusted input until upgraded.

Affected
koxudaxi datamodel-code-generator>= 0.11.6 and < 0.64.0 (fixed in 0.64.0)
Estimated exposure
largeorder of ~100,000+ developer/CI users (widely adopted Pydantic-ecosystem generator); exact install count unknown — datamodel-code-generator is the de facto standard open-source tool for generating Pydantic v2 models from OpenAPI/JSON Schema and is broadly used in developer workflows, but the supplied data contains no install or download counts, and…

Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.

Description

datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. From 0.11.6 until 0.64.0, datamodel-code-generator allows attacker-controlled x-python-import or customTypePath schema extensions to reach src/datamodel_code_generator/parser/jsonschema.py and generated import handling through Import.from_full_path and Imports.create_line in src/datamodel_code_generator/imports.py, allowing a newline to break out of an import statement and execute Python code when the generated model is imported. This issue is fixed in version 0.64.0.

Vendors
koxudaxi
Products
datamodel-code-generator
Weakness
CWE-94, CWE-95
Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H

In the news

No ingested article mentions this CVE yet.