CVE-2026-54653: CWE-94: Improper Control of Generation of Code ('Code Injection') in koxudaxi datamodel-code-generator
CVE-2026-54653 is a high severity code injection vulnerability in koxudaxi's datamodel-code-generator affecting versions from 0.17.0 up to but not including 0.60.2. The tool generates Python models from various schema formats and improperly preserves attacker-controlled default_factory values, which are emitted into generated code. This allows execution of arbitrary Python expressions when the generated model is imported. The issue is fixed in version 0.60.2.
AI Analysis
Technical Summary
The datamodel-code-generator tool versions >=0.17.0 and <0.60.2 improperly handle default_factory values derived from input schemas. Specifically, in src/datamodel_code_generator/parser/jsonschema.py, the JsonSchemaObject.init and get_field_extras methods preserve and emit these values directly into Field(default_factory=...) or field(default_factory=...) constructs. Because these values can be attacker-controlled, this leads to code injection allowing arbitrary Python expression execution upon importing the generated model. This vulnerability is tracked as CVE-2026-54653 and is fixed in version 0.60.2.
Potential Impact
An attacker able to influence the input schema to datamodel-code-generator can inject arbitrary Python code that will execute when the generated model is imported. This can lead to full compromise of the environment running the generated code, including confidentiality, integrity, and availability impacts. The CVSS 3.1 score is 8.8 (high), reflecting network attack vector, low attack complexity, no privileges required, user interaction required, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
Upgrade datamodel-code-generator to version 0.60.2 or later, where this code injection vulnerability is fixed. Until upgrading, avoid processing untrusted or attacker-controlled input schemas with affected versions. Patch status is confirmed fixed in 0.60.2.
CVE-2026-54653: CWE-94: Improper Control of Generation of Code ('Code Injection') in koxudaxi datamodel-code-generator
Description
CVE-2026-54653 is a high severity code injection vulnerability in koxudaxi's datamodel-code-generator affecting versions from 0.17.0 up to but not including 0.60.2. The tool generates Python models from various schema formats and improperly preserves attacker-controlled default_factory values, which are emitted into generated code. This allows execution of arbitrary Python expressions when the generated model is imported. The issue is fixed in version 0.60.2.
CVSS v3.1
Score 8.8high
Affected software
koxudaxi
datamodel-code-generator
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The datamodel-code-generator tool versions >=0.17.0 and <0.60.2 improperly handle default_factory values derived from input schemas. Specifically, in src/datamodel_code_generator/parser/jsonschema.py, the JsonSchemaObject.init and get_field_extras methods preserve and emit these values directly into Field(default_factory=...) or field(default_factory=...) constructs. Because these values can be attacker-controlled, this leads to code injection allowing arbitrary Python expression execution upon importing the generated model. This vulnerability is tracked as CVE-2026-54653 and is fixed in version 0.60.2.
Potential Impact
An attacker able to influence the input schema to datamodel-code-generator can inject arbitrary Python code that will execute when the generated model is imported. This can lead to full compromise of the environment running the generated code, including confidentiality, integrity, and availability impacts. The CVSS 3.1 score is 8.8 (high), reflecting network attack vector, low attack complexity, no privileges required, user interaction required, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
Upgrade datamodel-code-generator to version 0.60.2 or later, where this code injection vulnerability is fixed. Until upgrading, avoid processing untrusted or attacker-controlled input schemas with affected versions. Patch status is confirmed fixed in 0.60.2.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-06-15T20:16:46.199Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 6a6924a99c2644c7f8425663
Added to database: 07/28/2026, 21:52:41 UTC
Last enriched: 08/05/2026, 15:09:29 UTC
Last updated: 09/10/2026, 22:28:08 UTC
Views: 60
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.