PT-2026-65608 · Pypi · Datamodel-Code-Generator

CVE-2026-54621

·

Published

2026-07-28

·

Updated

2026-07-28

CVSS v3.1

7.8

High

VectorAV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Name of the Vulnerable Software and Affected Versions datamodel-code-generator versions 0.25.0 through 0.60.0
Description Code injection occurs when generating Python models from an attacker-controlled GraphQL schema. The issue stems from how GraphQL Union description values are rendered into Python comments within the templates src/datamodel code generator/model/template/UnionTypeStatement.jinja2, src/datamodel code generator/model/template/UnionTypeAliasAnnotation.jinja2, and src/datamodel code generator/model/template/UnionTypeAliasType.jinja2.
A Jinja2 filter only handles characters, failing to neutralize carriage returns (r). Because Python's tokenizer treats a bare carriage return as a physical-line terminator, the comment is terminated prematurely, allowing subsequent text to be parsed and executed as module-level Python code when the generated model is imported. This affects regular-string form descriptions where r escapes are preserved by graphql-core and passed to the description variable.
Recommendations Update datamodel-code-generator to version 0.60.1 or later.

Fix

Code Injection

Found an issue in the description? Have something to add? Feel free to write us 👾

Weakness Enumeration

Related Identifiers

CVE-2026-54621
GHSA-J884-Q54Q-MMX3

Affected Products

Datamodel-Code-Generator