CVE-2026-55389

datamodel-code-generator vulnerable to arbitrary local file read via JSON-Schema `$ref` (`file://` and `../` traversal), bypassing `--no-allow-remote-refs`

Published Jul 28, 2026 CVSS 3.1 · 7.5 High EPSS < 1% KEV · Not listed
Description
datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. Prior to 0.62.0, datamodel-code-generator resolves JSON Schema $ref targets in src/datamodel_code_generator/parser/jsonschema.py through is_url and _get_ref_body without containing file:// or ../ traversal references to the input directory and without honoring --no-allow-remote-refs, allowing arbitrary local file reads. This issue is fixed in version 0.62.0.

Analysis

AI-generated

Technical impact

An insecure reference resolution routine in datamodel-code-generator allows a malicious JSON Schema to specify local files to be read via file:// URLs or directory traversal (../). When the tool processes such a schema, it reads the referenced file without checking its location or honoring the --no-allow-remote-refs flag, exposing any file readable by the running process to disclosure of sensitive data such as configuration files, keys, or source code.

Affected Systems

The affected product is datamodel-code-generator from koxudaxi. All releases before version 0.62.0 are impacted, while 0.62.0 and newer contain the fix that removes the unsafe reference handling.

Risk and Exploitability

The CVSS score of 7.5 classifies the vulnerability as moderately high severity. The EPSS score of less than 1% indicates a low probability of exploitation at the time of assessment, and the vulnerability is not listed in CISA's KEV catalog. Based on the description, it is inferred that an attacker would need to supply a malicious JSON Schema to the tool, possibly through a local automation script or a compromised local service that processes user‑supplied schemas. The likely attack requires local execution or privileges that allow the attacker to influence the schema file; remote exploitation without additional compromise is unlikely. The flaw reduces confidentiality by permitting arbitrary local file reads, scoped to the permissions of the running process.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade datamodel-code-generator to version 0.62.0 or newer to eliminate the unsafe $ref handling.
  • If an upgrade is not immediately possible, evaluate whether the tool processes untrusted schema files and limit its use to trusted input sources, rejecting any $ref that contains file:// or .. components.
  • Apply filesystem permissions or sandboxing to restrict the process's read access to only the directories required for legitimate operation, reducing the impact of any remaining or future local file read weaknesses.

Generated by OpenCVE AI on August 4, 2026 at 12:46 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-8359-h9fx-j6v9 datamodel-code-generator vulnerable to arbitrary local file read via JSON-Schema `$ref` (`file://` and `../` traversal), bypassing `--no-allow-remote-refs`
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Koxudaxi
Koxudaxi datamodel-code-generator
Vendors & Products Koxudaxi
Koxudaxi datamodel-code-generator
Type Values Removed Values Added
Description datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. Prior to 0.62.0, datamodel-code-generator resolves JSON Schema $ref targets in src/datamodel_code_generator/parser/jsonschema.py through is_url and _get_ref_body without containing file:// or ../ traversal references to the input directory and without honoring --no-allow-remote-refs, allowing arbitrary local file reads. This issue is fixed in version 0.62.0.
Title datamodel-code-generator vulnerable to arbitrary local file read via JSON-Schema `$ref` (`file://` and `../` traversal), bypassing `--no-allow-remote-refs`
Weaknesses CWE-200
CWE-22
CWE-610
References
Metrics cvssV3_1

{'score': 7.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N'}

Weaknesses
  • CWE-200

    Exposure of Sensitive Information to an Unauthorized Actor

  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

  • CWE-610

    Externally Controlled Reference to a Resource in Another Sphere

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 29, 2026, 12:33 PM
Reserved
Jun 16, 2026, 6:57 PM
Status
Analyzed
Published
Jul 28, 2026, 10:17 PM
Modified
Oct 23, 2026, 11:10 PM