Executive brief
datamodel-code-generator is a tool used by developers to automatically create Python code from data schemas like OpenAPI or JSON Schema. A security flaw in this tool allows a specially crafted schema file to read sensitive files from the computer or server running the generator. This is particularly dangerous for web-based services or automated build systems that process user-provided schema files, as it could lead to the theft of configuration files, credentials, or other private data.
Technical details
A path traversal and information disclosure vulnerability exists in datamodel-code-generator's JSON Schema parser. The root cause is located in `src/datamodel_code_generator/parser/jsonschema.py` within the `_get_ref_body` method, which fails to restrict `$ref` targets to the input directory. Specifically, the `is_url` check classifies `file://` URIs as URLs but then explicitly exempts them from the `allow_remote_refs` security gate. This allows an attacker to use absolute `file://` URIs or relative `../` traversal sequences to read any file accessible to the process user. The vulnerability is exploitable in any environment where the generator processes untrusted schemas, such as multi-tenant codegen platforms or CI/CD pipelines. The issue is fixed in version 0.62.0 by enforcing base-path containment and honoring the remote-reference block for local file URIs.
Affected products
- koxudaxi datamodel-code-generator < 0.62.0
Timeline
- 2026-06-10: patched: Version 0.62.0 released
- 2026-06-11: other: Fix commit merged to main branch
- 2026-06-12: advisory: GitHub Security Advisory GHSA-8359-h9fx-j6v9 published
- 2026-07-28: disclosed: CVE-2026-55389 published to NVD