Code Injection in datamodel-code-generator (CVE-2026-55415)
Summary
Code injection in datamodel-code-generator (CVE-2026-55415). Successful exploitation can lead to full system takeover. Exploitable via customTypePath. Mitigation: upgrade to 0.63.0 or later.
Original description
The description as published by the source.
Summary
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.
Details
The sink is Import.from_full_path and Imports.create_line:
src/datamodel_code_generator/imports.py:35—from_full_path()only doesclass_path.split(".")and preserves every other character, including newlines:@classmethod @lru_cache def from_full_path(cls, class_path: str) -> Import: split_class_path: list[str] = class_path.split(".") return cls(import_=split_class_path[-1], from_=".".join(split_class_path[:-1]) or None)src/datamodel_code_generator/imports.py:64—create_line()renders the result verbatim:def create_line(self, from_: str | None, imports: set[str]) ->…
Source: GitHub Security Advisories (Global) NVD GitHub Advisory
Auto-generated summary
Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.
A vulnerability tracked as CVE-2026-55415 has been found in datamodel-code-generator.
Attackers can target a specific entry point like customTypePath over the network to misuse the product.
Successful exploitation can lead to full system takeover. CVSS score: 7.5/10.
What to do: upgrade datamodel-code-generator to 0.63.0 or later.
If unsure, ask your IT team or search "datamodel-code-generator CVE-2026-55415" on the vendor's site.
CVE-2026-55415 (datamodel-code-generator) — CWE-94 / CVSS v3 7.5
Attack vector: remote (network-reachable) / unauthenticated
Attack surface: customTypePath / import / default_factory / validators
Patched: 0.63.0 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.
Arbitrary code execution (CWE-94) exists in datamodel-code-generator. Attackers reach the vulnerable code path via customTypePath without authentication.
Check the vendor advisory for the affected versions of datamodel-code-generator. Attack surface: customTypePath / import / default_factory / validators.
Severity: High (CVSS 7.5/10). Successful exploitation can lead to full system takeover.
Update to 0.63.0.
Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.
Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'datamodel-code-generator' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.
Response actions
Concrete steps and command examples for SOC/SRE teams to execute in order
-
1Identify exposure identify
grep -r 'datamodel-code-generator' . | grep -v node_modulesリポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で
datamodel-code-generatorを grep し、稼働しているサービス・バージョンを把握する。 -
2Apply patch patch
Upgrade datamodel-code-generator to 0.63.0ステージング環境で 0.63.0 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。
-
3Post-deployment verification verify
Confirm patched version is live in productionパッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。
Affected packages
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- package pypi.org
- web github.com
- web github.com
- web github.com