Skip to content
OpenAdvisories
High · 7.8 CVE-2026-54621 EUVD-2026-50072GHSA-j884-q54q-mmx3PYSEC-2026-3561

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

Published Jul 28, 2026 · Updated Jul 29, 2026 · Assigned by GitHub_M

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

VendorProductAffectedFixed
koxudaxi datamodel-code-generator >= 0.25.0, < 0.60.1 —

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI datamodel-code-generator >= 0.25.0, < 0.60.1 0.60.1 GHSA-j884-q54q-mmx3

References