Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. datamodel-code-generator
  4. ›
  5. CVE-2026-54654

CVE-2026-54654: `datamodel-code-generator` vulnerable to code injection via unescaped carriage return in `--extra-template-data` `comment` field

July 28, 2026

datamodel-code-generator is vulnerable to code injection when a developer passes an --extra-template-data file whose comment value contains a literal \r (carriage return). The comment variable is rendered into a Python # comment in six built-in templates with no line-terminator escaping. Python’s tokenizer treats a bare CR as a physical-line terminator (see Python language reference — Physical lines), so the comment ends at the \r and the text after it is parsed as Python, including, when the CR is followed by suitable indentation, as a statement within the class body that follows on the next template line.

References

  • github.com/advisories/GHSA-wjv6-jcfj-mf9r
  • github.com/koxudaxi/datamodel-code-generator/commit/b73abb5cd703a50471b8950bbd3bd0b82ad71de7
  • github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
  • github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-wjv6-jcfj-mf9r
  • nvd.nist.gov/vuln/detail/CVE-2026-54654

Code Behaviors & Features

Detect and mitigate CVE-2026-54654 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 0.14.1 before 0.60.2

Fixed versions

  • 0.60.2

Solution

Upgrade to version 0.60.2 or above.

Impact 7.8 HIGH

CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine
  • CWE-94: Improper Control of Generation of Code ('Code Injection')

Source file

pypi/datamodel-code-generator/CVE-2026-54654.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:16:05 +0000.