/

CVE-2026-49114

Severity:

HIGH RISK

(7.1)

Symlink Race (CWE-59) in ONNX External Data Writer

CVE-2026-49114

Analyzed

Vulnerability type

Category:

Symlink Following and TOCTOU

CWE:

CWE-22, CWE-59, CWE-367

Impact:

Unauthorized File Modification

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

ONNX can follow a pre-planted symbolic link when saving model external data because it checks the destination and opens it through separate, non-atomic operations. A local attacker who can write to the serialization directory may redirect the victim's output into another file that the victim can modify, including sensitive configuration or authorization files.

Affected context

The vulnerability occurs when ONNX serializes external model data and derives the output path from the model's external-data location field. Risk is present when an attacker can create or modify directory entries in the destination directory and the victim process has write permission to a targeted file. The unsafe behavior involves a separate file-existence check followed by an output open operation that does not prevent symbolic-link following or enforce exclusive creation.

Exploit preconditions

  • Attack surface: Local filesystem used for ONNX external-data serialization
  • Required access: Ability to write entries in the directory where the victim saves external data
  • Victim capability: The victim process must have write access to the redirected target file
  • Trigger point: Model serialization through the external-data saving function
  • Why exploitation is possible: A non-atomic existence check and subsequent file open can be influenced by a pre-existing symbolic link, allowing the output operation to affect a different writable file

Why this happens

The underlying bug combines unsafe symbolic-link handling with a time-of-check-to-time-of-use condition. The code checks whether a path is a file and later opens that path for writing without atomically binding the validation result to the opened file or rejecting symbolic links. This maps primarily to CWE-59: Improper Link Resolution Before File Access, with related aspects of CWE-367: Time-of-Check Time-of-Use Race Condition and CWE-22: Improper Limitation of a Pathname to a Restricted Directory.

Potential impact

  • An attacker could cause data to be written to an unintended file
  • Sensitive authorization or configuration files could be altered
  • The victim application's behavior could be changed through unauthorized file modification
  • Scheduled tasks or startup configuration could be affected
  • Local privilege escalation or broader compromise may occur depending on file permissions

General mitigation guidance

Mitigation generally focuses on making file creation resistant to symbolic-link substitution and eliminating check-then-use gaps.

Common defensive patterns include:

  • Open output files atomically with exclusive-creation semantics
  • Reject symbolic links and verify file identity using trusted directory descriptors
  • Use filesystem APIs that prevent link following where available
  • Keep model-output directories private, controlled, and non-writable by untrusted users
  • Reduce the privileges of processes that serialize model data
  • Validate external-data locations against controlled directories and avoid unnecessary path flexibility
  • Apply restrictive permissions and separate temporary or staging areas from sensitive application files

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules identifying file-existence checks followed by later opens or writes
  • Code review searches for filesystem calls that omit exclusive creation or no-follow protections
  • Review of path construction based on model, archive, or user-controlled metadata
  • Runtime monitoring for unexpected writes through symbolic links or into sensitive paths
  • Policy checks requiring private ownership and restrictive permissions on serialization directories
  • Automated security review tools that flag TOCTOU patterns and unsafe link resolution

Sources

SourceLink
github.comgithub.com/onnx/onnx/security/advisories/GHSA-q56x-g2fj-4rj6
raw.githubusercontent.comraw.githubusercontent.com/cisagov/CSAF/develop/csaf_files/IT/white/2026/va-26-233-01.json
cve.orgcve.org/CVERecord?id=CVE-2026-49114

Frequently asked

questions

Generally, no. Exploitation requires local filesystem access to the directory used for external-data serialization, although a separate service could expose that access indirectly.

The attacker needs permission to create or alter directory entries in the relevant output directory. The victim process must also have permission to write to the redirected target file.

Use atomic file-creation APIs with exclusive and no-follow behavior, and verify that the destination remains within a trusted directory before writing.

Avoid check-then-use filesystem logic, isolate writable directories from sensitive files, restrict directory permissions, and include symlink and TOCTOU checks in code review and automated analysis.

Find out what's already
exploitable in your codebase.