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

CVE-2026-54656: `datamodel-code-generator` vulnerable to code execution on import via unescaped `validators` entries in --extra-template-data

July 28, 2026

When the Pydantic v2 output mode is in use, datamodel-code-generator reads a validators array from each model entry in the --extra-template-data file and synthesises a Pydantic @field_validator(...) decorator from each entry. The field names and the validator mode are interpolated into the decorator call wrapped in unescaped single quotes. A value containing ' breaks out of the string literal, letting an attacker emit an arbitrary positional Python expression into the decorator. The expression is evaluated at class-definition time, i.e. the moment the developer imports the generated module. This is the same trust model as the recently-published GHSA-wjv6-jcfj-mf9r (extras-file comment injection) but the impact is full RCE rather than a docstring leak.

References

  • github.com/advisories/GHSA-8m8r-38jm-f355
  • github.com/koxudaxi/datamodel-code-generator/commit/a43d02906111a2fdcaf13ee5b62eb2da85376f19
  • github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
  • github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-8m8r-38jm-f355
  • nvd.nist.gov/vuln/detail/CVE-2026-54656

Code Behaviors & Features

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

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 0.52.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-94: Improper Control of Generation of Code ('Code Injection')

Source file

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

Spotted a mistake? Edit the file on GitLab.

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

Page generated Sat, 08 Aug 2026 00:17:42 +0000.