Race in Safe Browsing (CVE-2026-12454)
A time-of-check to time-of-use flaw in TemporaryFileGetter on macOS lets a compromised sandboxed child process replace a temporary file with a symlink before the browser reopens it. This could allow an attacker to write arbitrary files outside the sandbox with browser privileges.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 21 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 TemporaryFileGetter on macOS allows a symlink race. Because sandboxed child processes like the GPU or Network processes share access to the same temporary directory, a compromised child could replace the closed temporary file with a symlink. This can lead to an arbitrary file write primitive outside the sandbox with browser privileges.
Affected files:
chrome/services/file_util/public/cpp/temporary_file_getter.cc
Estimated timestamp from git blame: 2023-02-24
Summary of Potential Vulnerability
A potential Time-of-Check to Time-of-Use (TOCTOU) vulnerability exists in TemporaryFileGetterHelper within chrome/services/file_util/public/cpp/temporary_file_getter.cc.
When a temporary file is requested, the helper calls base::CreateTemporaryFile(&temp_path) to allocate a new path under the temporary directory. On POSIX-based systems, this function creates the file using mkstemp but immediately closes the returned file descriptor, leaving the path vacant. Subsequently, TemporaryFileGetterHelper attempts to reopen this path using temp_file.Initialize with the base::File::FLAG_CREATE_ALWAYS flag:
// chrome/services/file_util/public/cpp/temporary_file_getter.cc
base::File TemporaryFileGetterHelper(int num_files_requested) {
base::FilePath temp_path;
base::File temp_file;
if (num_files_requested <= kMaxNumberOfFilesAllowed &&
base::CreateTemporaryFile(&temp_path)) { // (1) File created, FD closed
temp_file.Initialize(
temp_path, (base::File::FLAG_CREATE_ALWAYS | // (2) Re-opened BY PATH
base::File::FLAG_READ | base::File::FLAG_WRITE |
base::File::FLAG_WIN_TEMPORARY |
base::File::FLAG_DELETE_ON_CLOSE));
} ...
}
Potential Attack Vector on macOS
On macOS, this pattern is potentially exploitable because of the shared temporary directory and sandbox configurations:
-
Shared Temp Directory:
GetTempDir()resolves toNSTemporaryDirectory()(which corresponds to_CS_DARWIN_USER_TEMP_DIR). The browser passes this same temporary directory to child sandboxes via thedarwin-user-temp-dirparameter during process launch. -
Sandboxed Child Access: Highly exposed sandboxed child processes, such as the GPU process (
sandbox/policy/mac/gpu.sb) and the Network service (sandbox/policy/mac/network.sb), are granted read, write, create, and unlink access withindarwin-user-temp-dir:SCHEME (allow file-read* file-write-data file-write-create file-write-owner file-write-unlink (subpath (param darwin-user-temp-dir)) ) -
Symlink Race: If an attacker compromises the GPU or Network process, they can monitor the temporary directory. As soon as a temporary file matching the Chrome temp pattern (e.g.,
.com.google.Chrome.XXXXXX) is created and closed, the attacker can atomicallyunlinkit and replace it with a symbolic link pointing to an arbitrary file outside the sandbox (e.g.,~/Library/LaunchAgents/com.pwn.plistor~/.zshrc). -
Arbitrary File Write: When the unsandboxed browser process reopens the path via
temp_file.Initialize, it does not useO_NOFOLLOWon macOS/POSIX. It follows the symlink, truncates the target file to 0 bytes viaO_TRUNC(fromFLAG_CREATE_ALWAYS), and obtains a writable file descriptor. Due toFLAG_DELETE_ON_CLOSE, it unlinks the symlink but leaves the open descriptor intact. The browser then returns this descriptor over Mojo to the sandboxed file utility service (e.g., during Safe Browsing Zip/DMG/Rar extraction), allowing the attacker-controlled contents of a downloaded file to be written to the target location.
Potential Steps to Trigger the Vulnerability
(Note: These are suggested/potential steps; our tooling does not currently have the ability to run code or verify a live proof of concept).
- The attacker exploits a separate vulnerability to run code in a sandboxed child process that has access to the shared
darwin-user-temp-dir(such as the GPU or Network process). - The sandboxed child process sets up a file system monitor (e.g., via
kqueueor directory polling) on the shared temporary directory to watch for files matching the Chrome temp template (e.g., starting with.com.google.Chrome.). - A user downloads an archive, triggering a legitimate Safe Browsing archive analysis in the sandboxed utility process, which requests a temporary file via the
TemporaryFileGetterMojo interface. - When
base::CreateTemporaryFilecreates the file and closes its file descriptor, the monitoring child process immediately unlinks it and replaces it with a symbolic link pointing to a critical user file (e.g.,~/.zshrc). - The browser process calls
temp_file.Initialize, following the symbolic link and opening the target file for writing. This file descriptor is sent to the sandboxed utility process, which writes the extracted file contents to it, completing the arbitrary file write and escaping the sandbox.
Suggested Remediation
To prevent the symlink race, the browser process should avoid closing and reopening temporary files by path.
Instead of calling base::CreateTemporaryFile and then calling temp_file.Initialize, use a helper that creates and keeps the file descriptor open in a single atomic step, such as base::CreateAndOpenTemporaryFileInDir (or base::CreateAndOpenTemporaryStream). Alternatively, if the file must be reopened, ensure that O_NOFOLLOW is used on POSIX platforms to prevent the file system from traversing symbolic links during the open call.
Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8
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 code creates a temporary file, closes its descriptor, and later reopens the same path without O_NOFOLLOW, allowing a symlink race.
Impact
A compromised sandboxed child process could write arbitrary files outside the sandbox with browser privileges, potentially leading to code execution or data modification.
What the attacker needed
Compromise of a sandboxed child process; shared temporary directory access; user downloads an archive
The fix
The browser should create and keep the file descriptor open atomically, or use O_NOFOLLOW when reopening the path.
How it was found
- The attacker compromises a sandboxed child process that can access the shared temporary directory.
- The child process monitors the temporary directory for files matching Chrome's temporary file pattern.
- A user downloads an archive, triggering Safe Browsing analysis that requests a temporary file.
- The child process unlinks the newly created temporary file and replaces it with a symlink to a target file.
- The browser reopens the path, follows the symlink, and sends the writable descriptor to the utility process, which writes attacker-controlled content to the target.
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 closed, then reopened by path. Between those steps, another process sharing the same temporary folder can swap the file for a shortcut (symlink) pointing to a sensitive file. When the browser reopens the path, it follows the shortcut and writes to the sensitive file instead.
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.