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.
Published: 2026-07-28
Score: 7.5 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

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.

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

Remediation

No vendor fix or workaround currently provided.

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

Wed, 29 Jul 2026 13:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Tue, 28 Jul 2026 23:45:00 +0000

Type Values Removed Values Added
First Time appeared Koxudaxi
Koxudaxi datamodel-code-generator
Vendors & Products Koxudaxi
Koxudaxi datamodel-code-generator

Tue, 28 Jul 2026 22:00:00 +0000

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'}


Subscriptions

Koxudaxi Datamodel-code-generator
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-29T12:33:45.388Z

Reserved: 2026-06-16T18:57:40.183Z

Link: CVE-2026-55389

cve-icon Vulnrichment

Updated: 2026-07-29T12:33:33.679Z

cve-icon NVD

Status : Analyzed

Published: 2026-07-28T22:17:48.400

Modified: 2026-08-06T19:44:40.270

Link: CVE-2026-55389

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-04T13:00:11Z

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