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

CVE-2026-54653: `datamodel-code-generator` vulnerable to code injection in via attacker-controlled `default_factory` schema field

July 28, 2026

datamodel-code-generator is vulnerable to code injection when generating Python models from an attacker-controlled JSON Schema, OpenAPI, YAML, JSON, Avro, Protobuf, or XSD schema. When a property carries a "default_factory" key, its value is interpolated verbatim — as a raw Python expression — into the generated Field(default_factory=...) / field(default_factory=...) call. Because this assignment is evaluated at class-definition time (i.e. on import of the generated module), an attacker who controls the schema controls a Python expression that runs in the consumer’s process. No special CLI flags are required.

References

  • github.com/advisories/GHSA-386q-5hp3-95m9
  • github.com/koxudaxi/datamodel-code-generator/commit/17fc235e234cbcfaaadef8c74cb72c9687db0d1d
  • github.com/koxudaxi/datamodel-code-generator/releases/tag/0.60.2
  • github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-386q-5hp3-95m9
  • nvd.nist.gov/vuln/detail/CVE-2026-54653

Code Behaviors & Features

Detect and mitigate CVE-2026-54653 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.17.0 before 0.60.2

Fixed versions

  • 0.60.2

Solution

Upgrade to version 0.60.2 or above.

Impact 8.8 HIGH

CVSS:3.1/AV:N/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-54653.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:32 +0000.