Race in Downloads (CVE-2026-17709)
A race condition in the download copy routine could let a compromised sandboxed process replace a temporary file with a symbolic link, causing the browser to write attacker-controlled data to an arbitrary path outside the sandbox. The report describes a potential sandbox escape on macOS but does not demonstrate it.
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 in MakeCopyOfDownloadFile may allow a compromised sandboxed process to escape the macOS sandbox. By exploiting a race condition in the shared temporary directory, an attacker could replace a closed temporary file with a symbolic link. Because the subsequent copy operation follows symbolic links, this could redirect the unsandboxed browser process to write attacker-controlled bytes to arbitrary file paths.
Affected files:
components/download/internal/common/download_item_impl.cc
Estimated timestamp from git blame: 2016-11-16
Root Cause Analysis
In components/download/internal/common/download_item_impl.cc, the function MakeCopyOfDownloadFile prepares a copy of a downloaded file to a temporary location:
base::FilePath MakeCopyOfDownloadFile(DownloadFile* download_file) {
DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
base::FilePath temp_file_path;
if (!base::CreateTemporaryFile(&temp_file_path)) // (1) File created, FD closed
return base::FilePath();
if (!base::CopyFile(download_file->FullPath(), // (2) Copied by path
temp_file_path)) {
DeleteDownloadedFile(temp_file_path);
return base::FilePath();
}
return temp_file_path;
}
-
FD is closed early:
base::CreateTemporaryFileinternally creates the temporary file and immediately closes the file descriptor (seebase/files/file_util_posix.cc). -
Path-based copy follows symlinks: On macOS,
base::CopyFileuses Apple'scopyfile()API withCOPYFILE_DATAbut without theCOPYFILE_NOFOLLOW_DSTflag (seebase/files/file_util_apple.mm):C++ bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ... return (copyfile(from_path.value().c_str(), to_path.value().c_str(), /*state=*/nullptr, COPYFILE_DATA) == 0); }By default,
copyfile()opens the destination withO_WRONLY|O_CREAT|O_TRUNCand follows symbolic links unlessCOPYFILE_NOFOLLOW_DSTis explicitly passed in the flags.
Shared Temp Directory Across Trust Boundary
The temporary file is created in _CS_DARWIN_USER_TEMP_DIR. This same directory is shared with sandboxed child processes (such as the Network Service or GPU process) under the Seatbelt parameter darwin-user-temp-dir. These sandboxed processes are granted write/create/unlink permissions in this subpath:
- Network Service sandbox profile (
network.sb):(allow file-read* file-write* (subpath (param darwin-user-temp-dir))) - GPU sandbox profile (
gpu.sb):(allow file-read* file-write-data file-write-create file-write-owner file-write-unlink (subpath (param darwin-user-temp-dir)))
Potential Exploitation Path
Because our tooling agent does not have the ability to run code, these are suggested/potential exploitation steps an attacker could follow to trigger the vulnerability from a compromised sandboxed process (e.g., the Network Service):
- The compromised process spawns a thread to poll the shared temporary directory for new entries matching the
.com.google.Chrome.*prefix. - The attacker triggers a Safe Browsing download feedback flow (e.g., forging a
ClientDownloadResponsewithupload=trueand an eligible verdict likeUNCOMMON). - The browser process receives the response and dispatches
MakeCopyOfDownloadFileto the ThreadPool. - When
MakeCopyOfDownloadFilecallsbase::CreateTemporaryFile(), the temporary file is created and its file descriptor is closed. - The attacker's polling thread detects the newly created file, immediately calls
unlink()on it, and creates asymlink()with the same name pointing to a sensitive target (such as~/Library/LaunchAgents/com.attacker.plist). - The browser process calls
copyfile()on the path. Becausecopyfile()follows symlinks, it writes the attacker-controlled download payload into the targeted configuration file outside the sandbox. - On next login, the newly written configuration file executes arbitrary code outside the sandbox.
Suggested Fix
To resolve this potential TOCTOU vulnerability, Chrome should avoid closing the file descriptor and copying by path. Instead, the temporary file should be kept open, and the contents should be copied directly via the open file descriptor:
- Retrieve the file handle directly during creation (using
CreateAndOpenTemporaryFileInDir). - Perform the copy operation utilizing
base::CopyFileContentswhich takes openbase::Filedescriptors, ensuring that filesystem path-resolution races are completely neutralized.
Alternatively, COPYFILE_NOFOLLOW_DST could be added to base::CopyFile flags on Apple platforms, though keeping the file descriptor open remains the most robust cross-platform solution.
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.
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 temporary file's file descriptor is closed immediately after creation, and the subsequent copy is done by path with a function that follows symbolic links, creating a time-of-check to time-of-use race.
Impact
A compromised sandboxed process could potentially escape the macOS sandbox and write arbitrary files, leading to code execution outside the sandbox; the report notes this is a potential issue and has not been demonstrated.
What the attacker needed
Compromised sandboxed process; macOS; shared temporary directory writable by sandbox
The fix
The temporary file should be kept open and copied via its file descriptor, or the copy should use a no-follow flag on Apple platforms.
How it was found
- A compromised sandboxed process polls the shared temporary directory for new files with the Chrome prefix.
- The attacker triggers a Safe Browsing download feedback flow that causes the browser to copy the download.
- The browser creates a temporary file and closes its descriptor.
- The attacker unlinks the file and creates a symbolic link with the same name pointing to a sensitive target.
- The browser copies the download by path, following the symlink and writing outside the sandbox.
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.
A temporary file is created and then copied by its name, but between those two steps another process can swap the file for a shortcut (a symbolic link) pointing somewhere sensitive. Because the copy follows shortcuts, the browser could be tricked into writing attacker data to a protected location, potentially escaping the sandbox that normally confines risky code.
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.