Skip to content
Race condition Advisory Advanced CVE-2026-17711

Race in Downloads (CVE-2026-17711)

A time-of-check to time-of-use flaw in macOS 'Save Page As' lets a compromised sandboxed process swap a temporary file for a symlink before the browser reopens it by path. The browser could then write attacker-controlled bytes to an arbitrary file outside the sandbox, such as a launch agent plist.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 56 days

Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.

Overview: A potential Time-of-Check to Time-of-Use (TOCTOU) vulnerability exists in macOS 'Save Page As' operations. The browser creates a temporary file in the shared user temporary directory and immediately closes its file descriptor before later reopening it by path. A compromised sandboxed process with write access to the temporary directory could potentially race to replace the temporary file with a symlink, allowing the unsandboxed browser process to write attacker-controlled bytes to an arbitrary target file.

Affected files:

  • components/download/internal/common/base_file.cc
  • content/browser/download/save_file.cc

Estimated timestamp from git blame: 2008-07-26

Description

A potential filesystem Time-of-Check to Time-of-Use (TOCTOU) vulnerability has been identified in the macOS 'Save Page As' implementation. This issue could potentially allow a compromised sandboxed process (such as the GPU, Network, or On-Device Model Execution process) to escape its sandbox by racing the browser process to replace a temporary file with a symbolic link.

Root Cause Analysis

  1. Temporary File Generation without FD Retention: In content/browser/download/save_file.cc, SaveFile::Initialize() initializes the underlying BaseFile with empty paths:

    C++
    download::DownloadInterruptReason reason = file_.Initialize(
        /*full_path=*/base::FilePath(), /*default_directory=*/base::FilePath(),
        /*file=*/base::File(), ...);
    

    In components/download/internal/common/base_file.cc, because the path is empty, BaseFile::Initialize creates a temporary file via base::CreateTemporaryFile(&temp_file):

    C++
    if (full_path.empty()) {
      base::FilePath temp_file;
      if (... && !base::CreateTemporaryFile(&temp_file)) {
        return LogInterruptReason(...);
      }
      full_path_ = temp_file;
    }
    

    The base::CreateTemporaryFile helper calls mkstemp and immediately closes the resulting file descriptor when the ScopedFD goes out of scope in CreateTemporaryFileInDir (base/files/file_util_posix.cc). The file descriptor is discarded, and only the string path is retained.

  2. Reopening by Path Without O_NOFOLLOW: BaseFile::Initialize then calls BaseFile::Open(), which reopens the file by path via InitializeFile():

    C++
    file->Initialize(
        file_path,
        base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE |
        base::File::FLAG_READ | ...);
    

    On POSIX platforms, FLAG_OPEN_ALWAYS maps to standard open(path, O_RDWR) or open(path, O_CREAT | O_RDWR) calls inside base/files/file_posix.cc. Crucially, these calls do not utilize the O_NOFOLLOW flag, meaning the system call will traverse symbolic links.

  3. Shared Temp Directory Trust Boundary on macOS: On macOS, the temporary file is created in _CS_DARWIN_USER_TEMP_DIR. The macOS Seatbelt sandbox profiles for several sandboxed processes (such as gpu.sb, network.sb, and on_device_model_execution.sb) explicitly allow directory scanning, unlinking, and writing in this exact directory parameter (darwin-user-temp-dir).

Potential Attack Scenario

Because our testing environment is purely analytical and does not have the ability to execute live exploit code, the following steps represent a potential attack path:

  1. An attacker gains remote code execution within a sandboxed helper process (e.g., the GPU or Network process).
  2. The user navigates to an attacker-controlled page and initiates a 'Save Page As' ('Webpage, Complete') command.
  3. The attacker's page serves hundreds of small subresources to maximize the number of save operations and thus increase the likelihood of winning the race.
  4. For each subresource, the browser creates a temporary file under _CS_DARWIN_USER_TEMP_DIR and closes the file descriptor.
  5. The compromised sandboxed process, polling the directory, quickly calls unlink() on the newly created temporary file and replaces it with a symbolic link (e.g., pointing to ~/Library/LaunchAgents/pwn.plist).
  6. The browser process executes the open() call, follows the symlink, and truncates/writes the incoming attacker-controlled subresource bytes directly to the targeted launch agent plist.
  7. Upon completion, the rename operation moves the symlink itself (since rename does not follow symlinks), leaving the written launch agent payload in place outside the sandbox.

Suggested Fix

Instead of closing the file descriptor immediately after creation and reopening it by path, the browser should retain the open file descriptor from the initial creation step.

We recommend modifying BaseFile::Initialize to utilize base::CreateAndOpenTemporaryFileInDir or a similar wrapper that keeps the file descriptor open and passes it directly to BaseFile, removing the window of opportunity for a TOCTOU symlink swap. This pattern was previously applied successfully to resolve a similar issue in chrome/services/file_util/public/cpp/temporary_file_getter.cc.

Evaluated with Chrome root at commit: 57b021e1fdae94a215627d29aeb1ccf2eb5b3e91


Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:

  • If you are familiar with the severity guidelines, you may adjust the severity.
  • If this is a false positive, and there's no work to be done, please close as WAI.
  • If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.

Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The browser creates a temporary file, discards its file descriptor, and later reopens it by path without O_NOFOLLOW, so a symlink planted in the shared temp directory is followed.

Impact

A compromised sandboxed process could potentially escape its sandbox by writing attacker-controlled bytes to an arbitrary file, though the report is analytical and does not demonstrate a live exploit.

What the attacker needed

Code execution in a sandboxed helper; macOS with shared temp directory; victim saves an attacker page

The fix

The browser should keep the file descriptor from creation and pass it directly to BaseFile instead of reopening by path.

How it was found

  1. An attacker gains code execution inside a sandboxed helper process.
  2. The user saves an attacker-controlled page as 'Webpage, Complete'.
  3. The page serves many small subresources to increase save operations.
  4. For each subresource the browser creates a temp file and closes its descriptor.
  5. The compromised process unlinks the temp file and replaces it with a symlink.
  6. The browser opens the path, follows the symlink, and writes to the target file.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you save a web page, the browser first makes a temporary file, closes it, and later opens it again using only its name. If another program can change what that name points to in the meantime, the browser may end up writing to a different file than intended. Here a sandboxed helper process could do that swap, potentially writing outside its sandbox.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.