CVE-2026-54653
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.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.
Weakness
- CWE-94: Improper Control of Generation of Code
- CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine
CISA SSVC decision points
| Exploitation | none |
|---|---|
| Automatable | no |
| Technical impact | total |
| Scored | 2026-07-29 |
Timeline
- 2026-07-28Published by the CNA21:48 UTC
- 2026-07-28GitHub advisory published (GHSA-386q-5hp3-95m9)same day
- 2026-07-29CISA SSVC decision recorded1 day after publication
Exploit and advisory records
GitHub advisory GHSA-386q-5hp3-95m9, affected packages:
| Package | Vulnerable versions | Fixed in |
|---|---|---|
| PyPI datamodel-code-generator | from 0.17.0 before 0.60.2 | 0.60.2 |
Affected products
Products listed as vulnerable. Upgrade to the version under "Fixed in", or a later one.
| Product | Vulnerable versions | Fixed in |
|---|---|---|
| koxudaxi datamodel-code-generator | from 0.17.0 before 0.60.2fixed in 0.60.2 | 0.60.2 |
References
- https://github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d
- https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-386q-5hp3-95m9
- https://gist.github.com/thegr1ffyn/9648b0fe4fcf7d569ac8e61dd11eebaf
- https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
Get more CVE data from the API.
curl 'https://api.contrastcyber.com/cve_lookup/CVE-2026-54653'curl 'https://api.contrastcyber.com/cve_risk_score/CVE-2026-54653'curl 'https://api.contrastcyber.com/cve_exploit/CVE-2026-54653'curl 'https://api.contrastcyber.com/cve_products/CVE-2026-54653'
Sources
- Vulnerability data from the National Vulnerability Database (NIST) and the CVE Program. CVE records: Copyright © 1999-2026, The MITRE Corporation, used under the CVE Program Terms of Use. CVE® is a registered trademark of The MITRE Corporation.
- CWE definitions: Copyright © 2006-2026, The MITRE Corporation, used under the CWE Terms of Use. CWE is a trademark of The MITRE Corporation.
- OWASP Top 10 categories by the OWASP Foundation (CC BY 3.0).
- EPSS scores by FIRST.org EPSS, used with attribution.
- KEV catalog and SSVC decisions by CISA.
- Advisory data from the GitHub Advisory Database through OSV.dev (CC BY 4.0).
- Exploit metadata from the Exploit Database (GPL-2.0-only, metadata only).
- Nuclei template names from nuclei-templates (MIT).