Path Traversal in datamodel-code-generator (CVE-2026-55389)
Summary
Path traversal in datamodel-code-generator (CVE-2026-55389). Confidential information can be exposed externally. Exploitable via _get_ref_body. Mitigation: upgrade to 0.62.0 or later.
Original description
The description as published by the source.
Summary
datamodel-code-generator resolves JSON-Schema $ref targets that point at the local filesystem without restricting them to the input/base directory and without honoring the remote-reference security control. In the default configuration, an attacker who controls an input schema (a "paste your OpenAPI/JSON-Schema" service, a CI job that generates models from a submitted spec, or any multi-tenant codegen platform) can read any file the process user can read and map the host filesystem. This works via either a file:// absolute URI or a ../-escaped relative reference, and it succeeds even when --no-allow-remote-refs is set.
This is an unauthenticated path-traversal / information-disclosure issue (CWE-22 / CWE-200) plus a bypass of a documented security control.
Details
is_url() classifies file:// as a URL (reference.py:1249):
def is_url(ref: str) -> bool:
return ref.startswith(("https://", "http://", "file://"))
The remote-ref gate then explicitly exempts file://, so --no-allow-remote-refs never applies to it (parser/jsonschema.py, _get_ref_body):
if is_url(resolved_ref):
if not resolved_ref.startswith("file://") and self.http_local_ref_path is None:
if self.allow_remote_refs is False:
raise Error(...) # <-- skipped for file://
...
return self._get_ref_body_from_url(resolved_ref)
return self._get_ref_body_from_remote(resolved_ref)
Both local-file branches read…
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-55389 has been found in datamodel-code-generator.
Attackers can target a specific entry point like _get_ref_body over the network to misuse the product.
Confidential information can be exposed externally. CVSS score: 7.5/10.
What to do: upgrade datamodel-code-generator to 0.62.0 or later.
If unsure, ask your IT team or search "datamodel-code-generator CVE-2026-55389" on the vendor's site.
CVE-2026-55389 (datamodel-code-generator) — CWE-22 / CVSS v3 7.5
Attack vector: remote (network-reachable) / unauthenticated / no user interaction
Attack surface: _get_ref_body / _get_ref_body_from_local_http_path / http.py / const
Patched: 0.62.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.
Path traversal (CWE-22) exists in datamodel-code-generator. Attackers reach the vulnerable code path via _get_ref_body without authentication.
Check the vendor advisory for the affected versions of datamodel-code-generator. Attack surface: _get_ref_body / _get_ref_body_from_local_http_path / http.py / const.
Severity: High (CVSS 7.5/10). Confidential information can be exposed externally.
Update to 0.62.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.62.0ステージング環境で 0.62.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