Jul 29, 2026·4 min read·3 visits
Unauthenticated path traversal and local file read vulnerability in datamodel-code-generator prior to 0.62.0 allowed attackers to bypass --no-allow-remote-refs using the file:// scheme or relative pathing, revealing host system file structure and secrets.
An arbitrary local file read and path traversal bypass vulnerability in datamodel-code-generator before version 0.62.0 allows unauthenticated remote attackers to read arbitrary files via crafted JSON-Schema $ref references using the file:// scheme or directory traversal sequences.
The Python package datamodel-code-generator parses structured schemas like JSON Schema, OpenAPI, and GraphQL to automatically generate Pydantic models, dataclasses, or TypedDict implementations.
To facilitate modular schema design, the package supports the $ref keyword, allowing references to external definitions located either locally or remotely.
Security controls like the --no-allow-remote-refs command-line flag were designed to restrict the parser from retrieving external resources.
However, a directory traversal and security bypass flaw in the reference resolution subsystem allowed attackers to access local files readable by the process user.
The vulnerability originates from two design flaws within the reference parser found in src/datamodel_code_generator/parser/jsonschema.py.
First, the validator functions defined in reference.py improperly categorized the file:// scheme as a valid URL via the is_url helper function.
Due to this classification, absolute file paths using the file:// scheme bypassed remote reference verification mechanisms even when --no-allow-remote-refs was enabled.
Second, the local file resolver failed to enforce strict directory sandboxing. This omission allowed absolute paths and relative directory traversal paths containing ../ to resolve outside the intended root directory.
Prior to the patch, the is_url validator evaluated references using a simple prefix match:
# Vulnerable implementation of is_url in reference.py
def is_url(ref: str) -> bool:
return ref.startswith(("https://", "http://", "file://"))In _get_ref_body, the parser evaluated the reference, granting an exception to the file:// prefix when applying remote-ref blocks:
# Vulnerable path in jsonschema.py
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(...) # Bypassed for file:// schemesBecause of this logic, file:// schemas completely bypassed security boundaries and reached the underlying file retrieval handler. Additionally, relative references were concatenated directly without standard verification:
# Relative traversal without containment check
full_path = self.base_path / resolved_refThe patch in commit 2ff4a72b4550a2b2069754c5b075b1655067e5fb remediates this by introducing _resolve_local_ref_path, which uses Python's pathlib.Path.resolve and is_relative_to to enforce a strict boundary check.
An attacker can exploit this flaw by submitting a crafted JSON Schema containing standard $ref pointers. If the application exposes code-generation capabilities through an API endpoint, exploitation can be performed remotely and without credentials.
An attacker can use the parser as a file-system oracle to identify valid system paths. If a target file exists, the parser attempts to parse it and returns a TypeError: Expected dict, got str error, whereas a missing file triggers a FileNotFoundError.
If the targeted files contain structured YAML or JSON definitions, such as internal configurations or keys, the generator includes the extracted data directly in the output models.
The vulnerability has been assigned a CVSS v3.1 score of 7.5, indicating high severity due to high confidentiality exposure. Successful exploitation allows unauthorized access to sensitive application source code, container configurations, and local credentials.
Because the component is frequently executed within build pipelines or automated backends, this compromise can lead to broader access to deployment environments.
There is no integrity or availability impact, as the attacker cannot write to or alter local filesystem contents via this vector.
Users should update datamodel-code-generator to version 0.62.0 or higher immediately to resolve this security control bypass.
In version 0.62.0, the generator implements a strict boundary validator _resolve_local_ref_path that denies requests targeting paths outside the initialized input base path.
If upgrading is not immediately possible, validate input schemas before processing to remove $ref statements pointing to external URLs or paths with directory traversal sequences.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
datamodel-code-generator koxudaxi | < 0.62.0 | 0.62.0 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-55389 |
| Vulnerability Type | Directory Traversal (CWE-22) / Security Control Bypass |
| CVSS Base Score | 7.5 (High) |
| Attack Vector | Network (AV:N) |
| Affected Component | jsonschema parser (jsonschema.py) |
| Exploit Status | Proof-of-Concept (PoC) documented |
| CISA KEV Status | Not Listed |
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize elements within the pathname that can cause the pathname to resolve to a location outside of the restricted directory.
A critical code injection vulnerability exists in datamodel-code-generator from version 0.17.0 up to 0.60.1. The vulnerability allows remote attackers who supply a malicious JSON schema to execute arbitrary Python code. This occurs when the schema specifies a payload inside the 'default_factory' field extra, which is rendered directly into generated code without sanitization. When downstream processes load or import the output code, the evaluation of the class definition immediately triggers the execution of the injected code.
A vulnerability in the datamodel-code-generator library allows for unauthenticated remote code execution when generating code from malicious or untrusted schema specifications. By embedding special physical line terminators, such as carriage returns, vertical tabs, or form feeds, within template values, an attacker can break out of inline Python comment boundaries. The generated output file subsequently contains un-commented python instructions that execute automatically during module import.
A critical authentication bypass vulnerability in the SFTP server module of goshs version 2.1.3 allows remote, unauthenticated attackers to read, write, modify, or delete files on the target hosting environment. This vulnerability is caused by an incomplete logic check during initialization that falls back to a password-less configuration when an empty password string is specified.
An access control bypass vulnerability in goshs prior to version 2.1.4 allows unauthenticated remote attackers to bypass security flags intended to prevent file deletion and unauthorized modification. By exploiting the server's incorrect classification of WebDAV MOVE and overwriting COPY methods, attackers can execute arbitrary file deletion and data manipulation on the host system.
CVE-2026-66063 is an unauthenticated directory traversal and arbitrary file write vulnerability in goshs before version 2.1.5. Due to improper sanitization of file upload names, an unauthenticated attacker can write files outside the served web root. A related trailing slash bypass in the same version allows unauthorized file retrieval.
An unauthenticated remote Denial of Service (DoS) vulnerability exists in the plaintext message parsing implementation of gotd/td, a Go-based Telegram MTProto client and server library. The security flaw is located within the unencrypted message decoding pipeline, where the parser reads an untrusted length header and immediately performs a heap-based memory allocation without checking if the buffer contains the corresponding bytes. An attacker can exploit this behavior by sending a single crafted 20-byte packet containing an extremely large length value, leading to immediate memory exhaustion and process termination by the operating system Out-Of-Memory (OOM) killer.