CVE-2026-54653CWE-1336CWE-94code-injection

CVE-2026-54653

High · published July 29, 2026

CVSS v3.1
8.8
EPSS
1%
Percentile
53.0
In the wild
Unconfirmed
What it is

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.17.0 until 0.60.2, datamodel-code-generator preserves attacker-controlled default_factory values in src/datamodel_code_generator/parser/jsonschema.py through JsonSchemaObject.init and get_field_extras and emits them into Field(default_factory=...) or field(default_factory=...), allowing Python expression execution when the generated model is imported. This issue is fixed in version 0.60.2.

The record
Technical detail
CVSS v3.1
8.8 · HIGH
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
CVSS v4.0
Not supplied
EPSS
0.00711 · 53.0th percentile
Weaknesses
CWE-1336 · Improper Neutralization of Special Elements Used in a Template Engine; CWE-94 · Improper Control of Generation of Code ('Code Injection')
Published
2026-07-29T02:17Z
Affected products (1)
ProductVersionsFixed in
koxudaxi/datamodel-code-generator≥ 0.17.0, < 0.60.20.60.2
References (4)
EPSS history
Timeline
  • 28 JUL 21:48Z
    `datamodel-code-generator` vulnerable to code injection in via attacker-controlled `default_factory` schema field
    cvelistv5