{"id":"CVE-2026-54621","published":"2026-07-28T21:35:27Z","modified":"2026-07-29T12:34:35Z","title":"`datamodel-code-generator` vulnerable to code injection via unescaped carriage return in GraphQL Union description","vendor":"koxudaxi","product":"datamodel-code-generator","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.8,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.0021,"percentile":0.11421,"provenance":"source"},"cwes":[{"id":"CWE-94","name":"Improper Control of Generation of Code"},{"id":"CWE-1336","name":"Improper Neutralization of Special Elements Used in a Template Engine"}],"references":[{"url":"https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-j884-q54q-mmx3","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/koxudaxi/datamodel-code-generator/commit/aec47bc414779f4a9992b3919c8f7663afd6c988","tags":["x_refsource_MISC"]},{"url":"https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.1","tags":["x_refsource_MISC"]}],"priority":{"score":7.7,"factors":[{"name":"EPSS percentile","points":2.28},{"name":"CVSS severity","points":5.46}]},"vendorSlug":"koxudaxi","affectedVersions":[{"vendor":"koxudaxi","product":"datamodel-code-generator","versions":[">= 0.25.0, < 0.60.1"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"total","timestamp":"2026-07-29T12:34:28.223250Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"PyPI","package":"datamodel-code-generator","vulnerableRanges":[">=0.25.0, <0.60.1"],"patched":["0.60.1"],"from":["GHSA-j884-q54q-mmx3","PYSEC-2026-3561"],"provenance":"source"}],"summary":{"text":"A flaw in the datamodel-code-generator product's GraphQL Union description handling, located in its UnionTypeStatement Jinja2 templates, fails to neutralize carriage returns when rendering descriptions into Python comments. An attacker who can supply a crafted GraphQL schema, with a user needing to generate and then import the resulting models, can inject arbitrary Python code that executes when those generated models are imported.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:11:35Z"},"euvd":{"id":"EUVD-2026-50072","exploited":false,"provenance":"source"}}