CVE-2026-54621
Received Received - Intake

GraphQL Union Comment Injection in datamodel-code-generator

Vulnerability report for CVE-2026-54621, 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 Python data models from schema definitions. Prior to 0.60.1, GraphQL Union description values in src/datamodel_code_generator/model/template/UnionTypeStatement.jinja2 and src/datamodel_code_generator/model/template/UnionTypeStatement.py312.jinja2 are rendered into Python comments without neutralizing carriage returns in Python # comments, allowing attacker-controlled GraphQL schema content to inject Python code into generated models that runs when imported. This issue is fixed in version 0.60.1.

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.1 (exc)

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 versions before 0.60.1 allows GraphQL Union description values to inject Python code into generated models through Python comments. This happens because carriage returns in these descriptions are not neutralized, enabling attackers to control the schema content and execute arbitrary code when the generated models are imported.

Detection Guidance

Check the version of datamodel-code-generator installed on your system. If it is below 0.60.1, the system is vulnerable. Run: pip show datamodel-code-generator or pip list | grep datamodel-code-generator.

Impact Analysis

If you use a vulnerable version of datamodel-code-generator and process a malicious GraphQL schema, the generated Python models could contain hidden malicious code. When you import these models, the injected code may execute, potentially leading to unauthorized access, data theft, or system compromise.

Compliance Impact

This vulnerability could lead to unauthorized code execution, potentially causing data breaches or unauthorized access to sensitive information. This may violate compliance requirements under GDPR (data protection) and HIPAA (healthcare data privacy), leading to legal penalties, reputational damage, and loss of trust.

Mitigation Strategies

Upgrade datamodel-code-generator to version 0.60.1 or later. Run: pip install --upgrade datamodel-code-generator. Review generated Python models for unexpected code in comments if using GraphQL schemas.

Chat Assistant

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

EPSS Chart