What’s Vulnerable › Vulnerabilities

CVE-2026-54621: `datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description

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.

Affected products

References

Get alerted when CVE-2026-54621 or the next vulnerability affects your stack