CVE-2026-54653
Received Received - Intake

Remote Code Execution in datamodel-code-generator

Vulnerability report for CVE-2026-54653, including description, CVSS score, EPSS score, affected products, exploitability, helpful resources, and attack-flow context.

Publication date: 2026-07-28

Last updated on: 2026-07-28

Assigner: GitHub, Inc.

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.

CVSS Scores

EPSS Scores

Probability:
Percentile:

Meta Information

Published
2026-07-28
Last Modified
2026-07-28
Generated
2026-07-29
AI Q&A
2026-07-29
EPSS Evaluated
N/A
NVD

Affected Vendors & Products

Showing 1 associated CPE
Vendor Product Version / Range
datamodel-code-generator datamodel-code-generator to 0.60.2 (inc)

Helpful Resources

Exploitability

CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-94 The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
CWE-1336 The product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine.

Attack-Flow Graph

AI Quick Actions

Instant insights powered by AI
Executive Summary

The vulnerability in datamodel-code-generator allows attackers to inject malicious Python expressions into default_factory values. These values are preserved during model generation and executed when the generated model is imported, enabling arbitrary code execution.

Detection Guidance

Check if your system uses datamodel-code-generator versions between 0.17.0 and 0.60.2. Run: pip show datamodel-code-generator. If installed, verify the version matches the vulnerable range.

Impact Analysis

If you use affected versions (0.17.0 to 0.60.2) of datamodel-code-generator, an attacker could craft malicious input files that execute arbitrary code when you import the generated models. This could lead to data breaches, system compromise, or further attacks.

Compliance Impact

This vulnerability could violate GDPR and HIPAA by enabling unauthorized code execution, potentially leading to data exfiltration or system manipulation. Organizations using affected versions may face compliance violations and legal consequences.

Mitigation Strategies

Upgrade datamodel-code-generator to version 0.60.2 or later immediately. Run: pip install --upgrade datamodel-code-generator. Review generated code for suspicious default_factory values in Field or field definitions.

Chat Assistant

Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-54653. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70

EPSS Chart