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

- Severity: High 7.8 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.14%, higher than 3% of CVEs (2026-12-01)
- Published: 2026-07-28T21:35:27.863Z
- Modified: 2026-10-23T23:10:00.157Z
- Also known as: GHSA-j884-q54q-mmx3, PYSEC-2026-3561
- Weaknesses: CWE-94, CWE-1336
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact total
- 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.

(As written by CVE List.)

## Affected

- koxudaxi datamodel-code-generator: >= 0.25.0, < 0.60.1
- datamodel-code-generator (PyPI): from 0.25.0 before 0.60.1

## Every score

- GitHub_M: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- GitHub: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- PyPA Advisory Database: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`

## References

- <https://github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-j884-q54q-mmx3> (web)
- <https://github.com/koxudaxi/datamodel-code-generator/commit/aec47bc414779f4a9992b3919c8f7663afd6c988>
- <https://github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.1> (web)
- <https://github.com/koxudaxi/datamodel-code-generator> (package)
- <https://pypi.org/project/datamodel-code-generator> (package)
- <https://github.com/advisories/GHSA-j884-q54q-mmx3> (advisory)
- <https://nvd.nist.gov/vuln/detail/CVE-2026-54621> (advisory)

## Sources

- CVE List: [CVE-2026-54621](https://www.cve.org/CVERecord?id=CVE-2026-54621), CVE Terms of Use, modified 2026-07-29
- GitHub Advisory Database: [GHSA-j884-q54q-mmx3](https://github.com/advisories/GHSA-j884-q54q-mmx3), CC-BY-4.0, modified 2026-09-10
- NVD: [CVE-2026-54621](https://nvd.nist.gov/vuln/detail/CVE-2026-54621), Public domain, modified 2026-10-23
- PyPA Advisory Database: [PYSEC-2026-3561](https://osv.dev/vulnerability/PYSEC-2026-3561), CC-BY-4.0, modified 2026-08-04

---

Page: https://cve.day/CVE-2026-54621 · Whole record: https://cve.day/CVE-2026-54621.json · Rebuilt by cve.day 2026-11-25T22:59:30.384Z
