High severityNVD Advisory· Published Jul 28, 2026· Updated Jul 29, 2026
`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description
CVE-2026-54621
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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
datamodel-code-generatorPyPI | >= 0.25.0, < 0.60.1 | 0.60.1 |
Affected products
2- Range: <0.60.1
Patches
Vulnerability mechanics
References
4- github.com/advisories/GHSA-j884-q54q-mmx3ghsaADVISORY
- github.com/koxudaxi/datamodel-code-generator/commit/aec47bc414779f4a9992b3919c8f7663afd6c988mitrex_refsource_MISC
- github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.1ghsax_refsource_MISCWEB
- github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-j884-q54q-mmx3ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.