CVE-2026-55415: datamodel-code-generator vulnerable to code injection via `x-python-import` / `customTypePath` in generated import statements
A malicious input schema (OpenAPI / JSON Schema) can execute arbitrary Python code on the machine that imports the generated model. The x-python-import and customTypePath schema extensions flow, unsanitized, into the import statements datamodel-code-generator emits. A newline embedded in the extension value breaks out of the from … import … line and injects an attacker-controlled statement at module scope, which runs at import time. This is an unauthenticated, schema-content–driven remote code execution against any consumer of the generated code (e.g. arbitrary file read,the PoC exfiltrates /etc/passwd). It survives the v0.61.0 security release that fixed the related x-python-type, default_factory, GraphQL-union-description, and validators sinks those fixes did not cover this sibling path.
References
- github.com/advisories/GHSA-5578-w22f-pfx9
- github.com/koxudaxi/datamodel-code-generator/commit/577d49569c2254c371a97e495020ae2238a73b84
- github.com/koxudaxi/datamodel-code-generator/releases/tag/0.64.0
- github.com/koxudaxi/datamodel-code-generator/security/advisories/GHSA-5578-w22f-pfx9
- nvd.nist.gov/vuln/detail/CVE-2026-55415
Code Behaviors & Features
Detect and mitigate CVE-2026-55415 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 →