CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-Q56X-G2FJ-4RJ6

CVE-2025-51480: Arbitrary File Write via Path Traversal in ONNX save_external_data

Amit Schendel
Amit Schendel
Senior Security Researcher

Apr 2, 2026·6 min read·64 visits

Executive Summary (TL;DR)

A path traversal flaw in the ONNX library allows attackers to overwrite arbitrary files on the host system via manipulated tensor external data paths. Exploitation requires user interaction to process a malicious model but can lead to remote code execution.

The ONNX (Open Neural Network Exchange) Python library contains a high-severity path traversal vulnerability in the `save_external_data` function. Processing specially crafted ONNX models allows an attacker to write arbitrary files to the host filesystem, resulting in potential remote code execution or data corruption. The vulnerability also exposes a Time-of-Check Time-of-Use (TOCTOU) weakness during file operations.

Vulnerability Overview

The Open Neural Network Exchange (ONNX) format is an open standard designed for machine learning interoperability. It allows developers to move models between various machine learning frameworks. The ONNX Python library provides utilities to create, modify, and serialize these models. A critical component of this process is handling large tensor data, which is often stored outside the primary .onnx protobuf file to manage file size constraints.

CVE-2025-51480 represents a path traversal vulnerability (CWE-22) located within the onnx.external_data_helper.save_external_data function. This function is responsible for writing tensor data to the filesystem based on paths specified within the model's metadata. The implementation fails to adequately sanitize these user-supplied paths before performing filesystem operations.

By supplying an ONNX model with manipulated location values in its TensorProto structures, an attacker can coerce the library into writing file data outside the intended workspace directory. The vulnerability requires the victim to process an untrusted model, mapping to a high-severity CVSS score due to the severe impact on file integrity and system confidentiality.

Root Cause Analysis

The root cause of CVE-2025-51480 is the improper neutralization of special elements within file paths constructed from user-controlled input. In the ONNX specification, a TensorProto message can store data externally by utilizing the external_data field. This field contains key-value pairs, where the location key dictates the relative path to the data file on disk.

The onnx.external_data_helper.save_external_data function processes these keys and extracts the location string. The vulnerability manifests when the function constructs the final destination path. It executes an os.path.join(basepath, entry.value) operation, merging the intended workspace directory (basepath) with the user-supplied string (entry.value).

The Python os.path.join function evaluates path traversal sequences such as ../. If the entry.value contains extensive traversal sequences (e.g., ../../../../etc/passwd), the resulting path escapes the intended basepath. Furthermore, the vulnerability context identifies a Time-of-Check Time-of-Use (TOCTOU) weakness (CWE-367). Even if basic prefix validation occurs, an attacker with local access could swap directory symlinks between the validation phase and the file write phase, bypassing the intended safety boundaries.

Code Analysis

The vulnerable logic resides in the iteration over the external_data entries within a tensor definition. The code extracts the location string and directly applies it to the base path without canonicalization.

# Vulnerable implementation concept
def save_external_data(tensor, basepath):
    for entry in tensor.external_data:
        if entry.key == "location":
            # Flaw: entry.value is entirely user-controlled and unvalidated
            external_data_file_path = os.path.join(basepath, entry.value)
            
            # Flaw: The file is opened for writing at the traversed path
            with open(external_data_file_path, "wb") as f:
                f.write(tensor.raw_data)

The patch introduced in ONNX Pull Requests #6959 and #7040 addresses this by implementing rigorous path canonicalization and boundary checking. The corrected implementation utilizes os.path.abspath to resolve the full intended path and verifies that the resulting string is strictly a subdirectory of the canonicalized basepath.

# Patched implementation concept
def save_external_data(tensor, basepath):
    canonical_base = os.path.abspath(basepath)
    for entry in tensor.external_data:
        if entry.key == "location":
            target_path = os.path.join(canonical_base, entry.value)
            canonical_target = os.path.abspath(target_path)
            
            # Fix: Ensure the canonical target resides within the canonical base
            if not canonical_target.startswith(canonical_base + os.sep):
                raise ValueError("Path traversal detected in external_data location")
                
            with open(canonical_target, "wb") as f:
                f.write(tensor.raw_data)

This modification ensures that regardless of the presence of ../ sequences or absolute paths in the entry.value, the final output directory is strictly confined. Additional file status checks are incorporated to mitigate the TOCTOU symlink race conditions, ensuring the file path is securely resolved before the open operation.

Exploitation

Exploitation of CVE-2025-51480 requires a target application that processes untrusted ONNX models and invokes the save_external_data function. This scenario is common in machine learning pipelines, model transformation services, or ML observability platforms that parse and rewrite model definitions.

The attacker crafts a malicious ONNX model programmatically using the ONNX Python API. They instantiate a TensorProto object and populate its raw_data attribute with the malicious payload they intend to write to the victim's filesystem. They then append an external_data entry where the key is location and the value contains the path traversal payload.

# Malicious TensorProto construction
model = TensorProto()
model.raw_data = b"ssh-rsa AAAAB3NzaC1yc... attacker@domain\n"
 
location = model.external_data.add()
location.key = "location"
# Traverse out of the workspace to target the user's SSH keys
location.value = "../../../../../../../../home/user/.ssh/authorized_keys"

When the victim application receives this model and executes save_external_data(tensor=model, base_path="/tmp/model_workspace"), the Python interpreter evaluates the traversal payload. The os.path.join call generates the escaped path, and the open function subsequently truncates and overwrites the targeted authorized_keys file with the attacker's payload.

Impact Assessment

The direct impact of this vulnerability is arbitrary file overwrite (AFW) and arbitrary file read (AFR) depending on the specific application context. When the vulnerable function writes tensor data, an attacker can overwrite critical system configuration files, application source code, or initialization scripts.

Overwriting files such as ~/.ssh/authorized_keys, ~/.bashrc, or system cron jobs escalates the vulnerability directly to unauthenticated Remote Code Execution (RCE). The attacker achieves the privileges of the system user executing the ONNX model processing pipeline. In containerized environments, this often results in full container compromise, leading to subsequent lateral movement within the cluster.

The vulnerability holds a CVSS v3.1 base score of 8.8 (High). The User Interaction (UI) metric is assessed as Required, as the victim must manually process or automate the processing of the provided file. The Confidentiality, Integrity, and Availability metrics are all assessed as High due to the comprehensive system compromise possible via arbitrary file overwriting.

Remediation

The primary remediation for CVE-2025-51480 is updating the ONNX library to a patched version incorporating Pull Requests #6959 and #7040. Organizations should audit their dependency manifests (e.g., requirements.txt, Pipfile) to ensure onnx is upgraded beyond the affected versions.

For systems where immediate patching is unfeasible, developers must implement strict validation on incoming ONNX models. Applications should parse the model definition in memory and verify the location keys of all external_data entries within TensorProto structures before invoking any saving mechanisms. Rejecting models containing ../ sequences or absolute paths in these fields mitigates the immediate attack vector.

Security engineers should also enforce the principle of least privilege on machine learning pipelines. Executing model parsing and transformation tasks within heavily restricted sandboxes or containers with read-only root filesystems limits the attacker's ability to achieve meaningful system compromise. Removing write access to critical configuration directories effectively neutralizes the severe RCE impacts of the arbitrary file write.

Official Patches

ONNXPull Request fixing AFO via path traversal in save_external_data
ONNXInitial Pull Request addressing AFO via path traversal

Technical Appendix

CVSS Score
8.8/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Affected Systems

ONNX Python Package (`onnx` on PyPI)Applications parsing untrusted ONNX models using the external data helper

Affected Versions Detail

Product
Affected Versions
Fixed Version
ONNX
Linux Foundation
< Patched versions (post PR #6959/#7040)-
AttributeDetail
CWE IDCWE-22, CWE-367
Attack VectorNetwork (Requires User Interaction)
CVSS v3.1 Score8.8 (High)
Vulnerability TypePath Traversal
ImpactArbitrary File Write / RCE
Exploit StatusProof of Concept Available

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1204.002User Execution: Malicious File
Execution
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

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 that can cause the pathname to resolve to a location that is outside of the restricted directory.

Known Exploits & Detection

Gecko Security / HuntrPython script generating a malicious ONNX file to overwrite arbitrary target files.

Vulnerability Timeline

Initial discovery and submission via Huntr by Michael Keines
2025-01-16
Public disclosure by Gecko Security Research
2025-05-12
CVE-2025-51480 assigned and published in NVD
2025-07-22

References & Sources

  • [1]GitHub Advisory: GHSA-Q56X-G2FJ-4RJ6
  • [2]NVD Entry for CVE-2025-51480
  • [3]Huntr Bounty Report
  • [4]Gecko Security Blog Post

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•9 minutes ago•GHSA-CJCG-CXMH-9WCR
7.5

GHSA-cjcg-cxmh-9wcr: Unbounded Memory Allocation via HTTP/2 Bomb in praxis-proxy

A critical vulnerability exists in the praxis-proxy library where the omission of default limits on HTTP/2 server options allows remote attackers to trigger a Denial of Service (DoS) using an HPACK compression bomb and flow-control window stalls. This vulnerability is cataloged as GHSA-cjcg-cxmh-9wcr.

Amit Schendel
Amit Schendel
0 views•7 min read
•about 1 hour ago•GHSA-MWM8-39RW-8826
8.1

GHSA-MWM8-39RW-8826: Use-After-Free Vulnerability in Ruby sqlite3 Gem native extension

A Use-After-Free (UAF) vulnerability exists in the sqlite3-ruby native C extension when marshaling arguments for user-defined SQLite aggregate functions with multiple arguments. Due to temporary heap-allocated argument arrays not being registered with the Ruby Garbage Collector, active objects can be prematurely reclaimed, resulting in memory corruption or process-level crashes.

Alon Barad
Alon Barad
2 views•7 min read
•about 2 hours ago•CVE-2026-19484
7.5

CVE-2026-19484: Remote Denial of Service via Boyer-Moore-Horspool Integer Wrap-around in @fastify/busboy

An unauthenticated remote denial of service vulnerability exists in @fastify/busboy versions 3.1.0 through 3.2.0. The vulnerability is caused by an integer wrap-around in the Boyer-Moore-Horspool algorithm implementation inside the sbmh submodule when initializing skip distances. When processing a specific boundary of 252 bytes, the parser triggers an infinite loop, stalling the single-threaded Node.js event loop and exhausting CPU resources.

Alon Barad
Alon Barad
6 views•6 min read
•about 3 hours ago•CVE-2026-19481
7.5

CVE-2026-19481: Unauthenticated Remote Denial of Service via Prototype Lookup Crash in @fastify/busboy

A critical remote, unauthenticated Denial of Service (DoS) vulnerability in @fastify/busboy (<= 3.2.0) allows attackers to crash the Node.js process. By submitting a crafted multipart/form-data request with a header key matching an inherited property of Object.prototype (like __proto__ or constructor), the internal HeaderParser triggers a synchronous TypeError.

Amit Schendel
Amit Schendel
4 views•7 min read
•about 4 hours ago•GHSA-P23F-CM6Q-2QP8
8.6

GHSA-P23F-CM6Q-2QP8: Workspace Boundary Bypass and Arbitrary File Leak in SiYuan MCP

SiYuan is an open-source personal knowledge management system. Its Model Context Protocol (MCP) implementation within the asset.upload tool contains a path-traversal and workspace boundary bypass flaw. This allows remote AI models—acting on behalf of attackers via malicious prompts or documents—to import and read sensitive host-system files, such as private keys and system configurations, through absolute path inputs.

Alon Barad
Alon Barad
5 views•6 min read
•about 5 hours ago•GHSA-X8GV-G2G3-65FJ
8.2

CVE-2026-82234: Server-Side Request Forgery via DNS-Rebinding TOCTOU in SiYuan Kernel

An Server-Side Request Forgery (SSRF) vulnerability via DNS-Rebinding Time-of-Check to Time-of-Use (TOCTOU) has been discovered in SiYuan (思源笔记), an open-source personal knowledge management system. The flaw exists within the AI Agent tools http_request (util.HTTPRequest) and web_fetch (util.WebFetch) of the SiYuan Kernel, allowing unauthenticated remote attackers to bypass SSRF validation and access private internal services or cloud metadata endpoints.

Amit Schendel
Amit Schendel
5 views•7 min read