Koxudaxi datamodel-code-generator
`datamodel-code-generator` vulnerable to code injection in via attacker-controlled `default_factory` schema field
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.
Affected versions and mitigation
From the CVE record and the vendor's references.Affected
- >= 0.17.0, < 0.60.2
Fixed in 0.60.2
Mitigation
Upgrade datamodel-code-generator to 0.60.2 or later.
References
- Vendor advisory github.com/koxudaxi/datamodel-code-generator/s…
- Patch github.com/koxudaxi/datamodel-code-generator/c…
- Release notes github.com/koxudaxi/datamodel-code-generator/r…
Timeline
Days relative to CVE publicationNo public PoC found yet; not in CISA KEV.
PoC repositories
Found on GitHub.No PoC repositories found yet.
Other public exploits
Exploit-DB, Metasploit and nuclei count as public PoCs. Exploit-tagged references from the CVE record and NVD are links only. None of these are analysed by us.| Source | Title | Published | Found by us |
|---|---|---|---|
| CVE record (tagged exploit) | https://gist.github.com/thegr1ffyn/9648b0fe4fcf7d569ac8e61dd11eebaf | unknown | 14 Nov 2026 |