


Perceptive Security
SOC/SIEM Consultancy

datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JS…
Published:
28 juli 2026 om 00:00:00
Alert date:
29 juli 2026 om 01:04:30
Source:
nvd.nist.gov
Supply Chain & Dependencies, Web Technologies
CVE-2026-54653 affects datamodel-code-generator versions 0.17.0 through 0.60.2, a tool that generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from various schema formats. The vulnerability exists in src/datamodel_code_generator/parser/jsonschema.py where attacker-controlled default_factory values are preserved through JsonSchemaObject.init and get_field_extras. These values are then emitted into Field(default_factory=...) or field(default_factory=...) calls in the generated code. When a user imports the generated model, the malicious Python expressions are executed, leading to arbitrary code execution. The attack vector requires an attacker to supply a crafted schema input to the code generator. The issue has been patched in version 0.60.2, and users are advised to upgrade immediately.
Technical details
Mitigation steps:
Affected products:
datamodel-code-generator 0.17.0 - 0.60.1
Related links:
https://nvd.nist.gov/vuln/detail/CVE-2026-54653
https://github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d
https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-386q-5hp3-95m9
Related CVE's:
Related threat actors:
IOC's:
This article was created with the assistance of AI technology by Perceptive.
