Oct 8, 2026·5 min read·18 visits
Unsafe pathname concatenation using python's pathlib division (/) operator allows unauthenticated remote attackers to write or overwrite files outside the sandbox by supplying a crafted Protobuf schema.
A path traversal vulnerability in datamodel-code-generator allows remote attackers to write or overwrite arbitrary files on the local host filesystem via a manipulated Protobuf schema containing malicious weak import paths.
datamodel-code-generator is a utility designed to automate the creation of Python data representations. The module supports a broad range of ingestion formats including JSON Schema, OpenAPI, and Protocol Buffers. It translates these schemas into fully structured Pydantic models or dataclasses.
From version 0.59.0 up to 0.80.0, the library exhibits a significant vulnerability within its Protocol Buffer parsing engine. The vulnerability is located inside the file src/datamodel_code_generator/parser/protobuf.py which is responsible for managing missing dependencies during compilation. Unsanitized user inputs processed through this parser can result in severe file system manipulation.
The attack surface is exposed whenever the engine accepts untrusted .proto schemas from external actors. If an ingestion service utilizes this package without robust input filtering, remote attackers can compromise file system integrity. This vulnerability is tracked as CVE-2026-107377 and GHSA-77xj-x4rm-935c.
The underlying flaw resides in how the ProtobufParser class prepares weak import structures for the Protocol Compiler (protoc). To allow compilation to succeed even when imported models are missing, the parser extracts dependencies declared via import weak statements. It identifies these paths using a regular expression and attempts to generate dummy files within an isolated sandbox.
During file system path generation, the parser leverages Python's pathlib.Path class and its / division operator to concatenate the sandbox path with the extracted import path. However, the parser fails to validate whether the resulting pathname points inside the designated directory boundaries. The division operator behaves unsafely when combined with absolute paths or relative path climbing sequences.
If the import weak statement contains an absolute path, the pathlib engine completely discards the prefix representing the temporary sandbox directory. If the import path contains relative elements such as ../../, the operator appends them literally, allowing the resulting path to climb above the sandbox. The application then automatically invokes mkdir(parents=True, exist_ok=True) and write_text() on the resolved path, leading to arbitrary directory generation and file writes.
Reviewing the vulnerable code in _write_missing_weak_imports highlights the precise execution path leading to the flaw. The original implementation extracted the matched paths and performed a simple check before creating the stub files.
# Vulnerable implementation snippet
for import_path in WEAK_IMPORT_PATTERN.findall(text):
if any((include_path / import_path).exists() for include_path in include_paths):
continue
stub = self.weak_import_dir / import_path
stub.parent.mkdir(parents=True, exist_ok=True)
stub.write_text(syntax, encoding=self.parser.encoding)In this logic, if import_path contains directory climbing directives, the resulting stub object points to an arbitrary location outside self.weak_import_dir. Additionally, the existing file validation check uses include_path / import_path. Because this check evaluates a different destination than the one actually written to, it fails to flag and prevent the overwrite of sensitive destination targets.
The remediation introduces a defensive check using resolve() alongside is_relative_to(). The resolution step normalizes the relative segments, and the subsequent check guarantees that the path resides strictly inside the temporary workspace.
# Patched implementation snippet
weak_import_dir = self.weak_import_dir.resolve()
for import_path in WEAK_IMPORT_PATTERN.findall(text):
stub = (weak_import_dir / import_path).resolve()
if not stub.is_relative_to(weak_import_dir):
msg = f"Invalid Protocol Buffers weak import path: {import_path!r}"
raise SchemaParseError(msg)
# Remaining safe write logic continues...An attacker can trigger this vulnerability by submitting a Protocol Buffer schema containing a specifically formatted weak import path. The attack does not require any specialized tools or complex configuration flags. A standard .proto schema file is sufficient to execute the traversal.
syntax = "proto3";
import weak "../../../../tmp/target_configuration.json";
message TraversalMessage {
string payload = 1;
}When the parser ingests this file, it extracts ../../../../tmp/target_configuration.json and evaluates it against the base directory. The file system creates any intermediate directories that do not exist, and subsequently executes a write command. It populates the targeted file with the text string syntax = "proto3";.
The write operation persists even if the overall compilation fails. Because the parser prepares these dummy files prior to running the actual protoc compiler, any subsequent syntax errors within the schema do not revert the file modification. This behavior allows attackers to manipulate configuration files, overwrite script files, or crash running processes by corrupting their data formats.
The direct impact of CVE-2026-107377 is classified as a high integrity compromise. An unauthenticated remote attacker can corrupt or overwrite files across any directory where the process owns write permissions. Since the generator often operates as part of an automated pipeline, it may possess privileges to modify application resources.
While the vulnerability does not directly expose contents of the filesystem, it represents a significant vector for service disruption. By overwriting configuration assets, an attacker can trigger application instability or denial of service. Under specific conditions, writing arbitrary content into executable directories can facilitate remote execution.
The severity of this flaw is compounded by the ease of exploitation. The attack complexity is low, requiring nothing more than a standard schema submission. Systems that process third-party schemas automatically are highly vulnerable to this exploitation strategy.
The primary remediation strategy is upgrading datamodel-code-generator to version 0.81.0 or higher. This release integrates the validation checks that prevent paths from escaping the temporary boundary. It also introduces automatic cleanup routines that remove the temporary directory if validation fails during parser execution.
If upgrading is not immediately feasible, teams must implement alternative defensive configurations. Schema ingestion endpoints should be restricted to authenticated users. Input validators should check incoming files for the presence of the import weak directive and block any files containing path traversal sequences.
As a general security practice, running the generator inside an isolated sandbox container minimizes the overall blast radius. Configuring the execution environment with a read-only root file system prevents the parser from writing outside designated workspace folders. These multi-layered boundaries ensure that directory traversal attempts do not affect system resources.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
datamodel-code-generator datamodel-code-generator | >= 0.59.0, < 0.81.0 | 0.81.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-22 / CWE-73 |
| Attack Vector | Network (AV:N) |
| CVSS v3.1 | 7.5 (High) |
| Impact | High Integrity Compromise (File Overwrite) |
| Exploit Status | Proof of Concept available in tests |
| KEV Status | Not listed |
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname.
NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.
CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.
CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.
CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.
A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.
CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.