Summary
ONNX versions prior to 1.21.0 contain a path traversal vulnerability that allows attackers to leverage symlinks to read files outside the intended model or user-specified directory.
When ONNX processes model-related paths without fully resolving and validating symlinks, an attacker who controls model content or file structure can potentially access arbitrary files on the underlying filesystem.
Affected context
This vulnerability appears in ONNX components that load or manipulate model files and related resources from the filesystem.
It is relevant in environments where:
- ONNX is given model files or directories that may be influenced by untrusted or semi-trusted parties
- The application expects ONNX to stay confined to a specific model directory or user-provided path
- Symlinks within those directories are not treated as potentially dangerous and are resolved without strict validation
The issue becomes more serious on systems where sensitive configuration files, credentials, or keys reside near the ONNX runtime.
Exploit preconditions
- Attack surface: Local filesystem access via ONNX model loading or processing APIs
- Required access: Ability to supply or modify model directories, archives, or files that ONNX will load (e.g., upload model, place files on disk, or control extraction locations)
- Trigger point: ONNX reading or resolving file paths that traverse through a symlink within the model or user-provided directory
- Why exploitation is possible: Path normalization and directory confinement checks do not adequately account for symlink resolution, allowing computed paths to escape the intended root directory (CWE-23 / CWE-61)
Why this happens
The root cause is insufficient validation of file system paths when following symlinks inside model or user-controlled directories.
ONNX resolves file paths that may include symbolic links without enforcing that the final, fully-resolved path remains within the expected directory boundary.
This maps to CWE-23: Relative Path Traversal and CWE-61: UNIX Symbolic Link Following: the implementation assumes that paths remain confined based on their apparent structure, but symlinks permit redirection to arbitrary locations on the host filesystem.
Potential impact
- Reading arbitrary files outside the intended model or user directory
- Exposure of sensitive configuration files, logs, or environment details
- Disclosure of credentials, API keys, or tokens stored on disk
- Gathering information that could support further privilege escalation or lateral movement
General mitigation guidance
Effective mitigation focuses on constraining filesystem access and hardening path handling:
- Normalize and canonicalize all paths after resolving symlinks, and enforce that the final path remains within an allowed root directory
- Avoid following symlinks in user-controlled directories where possible, or explicitly disallow symlinked entries
- Run ONNX-based workloads with least-privilege filesystem permissions so that even if traversal occurs, sensitive files are not readable
- Separate model storage from system and secret storage, placing sensitive material outside any directory tree that untrusted models can influence
- Treat model artifacts from external parties as untrusted input, applying the same scrutiny used for file uploads or archives
How teams detect issues like this
Organizations can look for this class of issue and its symptoms via:
- Static analysis rules that flag direct filesystem access using user-influenced paths without robust canonicalization and boundary checks
- Code review checklists that explicitly ask how symlinks, relative paths, and directory traversal are handled for model files
- Runtime monitoring for unexpected file access patterns by ONNX processes, such as reads from /etc, user home directories, or secret paths
- Automated security testing that places crafted symlinks inside model directories to validate that traversal is blocked by defensive controls

