Inappropriate implementation in Network (CVE-2026-17856)
A potential time-of-check to time-of-use flaw in base::ScopedTempFile allows a compromised sandboxed child process on macOS to replace a temporary file with a symbolic link. The unsandboxed browser process then reopens the path without O_NOFOLLOW, potentially writing to or truncating arbitrary files at browser privilege, which could lead to sandbox escape.
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 systemic Time-of-Check to Time-of-Use (TOCTOU) vulnerability exists when using base::ScopedTempFile in conjunction with path-based reopens (such as SimpleURLLoader::DownloadToFile). Because macOS GPU and Network sandbox profiles permit write and unlink access to the shared temporary directory, a compromised child process could replace the temporary file with a symbolic link. Subsequent write operations by the unsandboxed browser process would then follow the symlink, leading to arbitrary file write or truncation outside the sandbox.
Affected files:
base/files/scoped_temp_file.ccbase/files/scoped_temp_file.hbase/files/file_proxy.ccchrome/browser/enterprise/data_protection/file_snapshot_creator.cccomponents/webapps/isolated_web_apps/download/bundle_downloader.ccservices/network/public/cpp/simple_url_loader.cc
Estimated timestamp from git blame: 2023-09-20
Potential Systemic TOCTOU vulnerability in base::ScopedTempFile and SimpleURLLoader on macOS
Summary
A potential design flaw in base::ScopedTempFile exposes callers to path-based reopening races. On macOS, sandboxed child processes (e.g., GPU or Network processes) share access to the system temporary directory (darwin-user-temp-dir). Because base::ScopedTempFile closes its file descriptor immediately after creation and only maintains the string path, a compromised child process can race to replace the temp file with a symlink. When the browser process subsequently reopens the file path (for example, via SimpleURLLoader::DownloadToFile with create_temp_file = false), it uses base::File::Initialize with FLAG_CREATE_ALWAYS (equivalent to POSIX O_CREAT | O_TRUNC) without O_NOFOLLOW. This causes the unsandboxed browser process to follow the symlink and write or truncate arbitrary files at browser-process privilege levels, resulting in a potential sandbox escape.
Potential Vulnerability Mechanism
- Creation: A high-privilege component in the browser process (such as
IsolatedWebAppUpdateDiscoveryTaskduring IWA updates orIwaInstallerduring policy-enforced installation) initiates a temporary file allocation usingScopedTempWebBundleFile::Create()(components/webapps/isolated_web_apps/download/bundle_downloader.cc:25). - Handle Release: Under the hood,
base::ScopedTempFile::Create()usesbase::CreateTemporaryFilewhich executesmkstemp(base/files/file_util_posix.cc:865). It returns aScopedFDwhich is immediately destroyed on scope exit, closing the secure file handle. The class only retains the string path (base/files/scoped_temp_file.cc:37-40). - The Race: Under macOS sandbox policies, sandboxed child processes (such as GPU or Network) are granted
file-write-unlinkandfile-write-createaccess to the shared subpathdarwin-user-temp-dir(sandbox/policy/mac/gpu.sb:124-128). A compromised process can monitor the temporary directory, detect the creation of the temporary file,unlink()it, and place a symlink at the same path pointing to a sensitive file (e.g.,~/Library/LaunchAgents/pwn.plist). - Reopening and Write: The browser process instructs
SimpleURLLoader::DownloadToFileto write downloaded data to theScopedTempWebBundleFile's path. Because an explicit path is provided, the network service invokesSaveToFileBodyHandler::FileWriterwithcreate_temp_file_ = false(services/network/public/cpp/simple_url_loader.cc:1349-1352). - Unchecked Open:
FileWriteropens the target file usingbase::File::Initializewithbase::File::FLAG_CREATE_ALWAYS(services/network/public/cpp/simple_url_loader.cc:1029), which compiles toopen(..., O_CREAT | O_TRUNC | O_WRONLY)(base/files/file_posix.cc:573-577). Crucially,O_NOFOLLOWis not specified. The kernel follows the symlink, truncating and overwriting the target file outside the sandbox at browser-process privilege level.
Note: Our static analysis tools cannot execute code or generate live proofs of concept, so these steps represent a potential attack sequence derived from manual code tracing.
Impact
If successfully exploited, a compromised GPU or Network child process could escape the macOS App Sandbox by writing to user configuration files (such as LaunchAgents), executing arbitrary code at the user's full privilege level.
Suggested Remediation
- Harden
base::File::DoInitializeto restrict symlink traversal when opening/creating temporary files or whenFLAG_CREATE_ALWAYSis specified, possibly by leveragingO_NOFOLLOWor verifying file descriptors usingfstat. - Deprecate path-only temporary file structures (like
base::ScopedTempFile) in favor of classes that retain and pass an openbase::FileorScopedFDhandle (such asCreateAndOpenTemporaryFileInDir), eliminating the necessity of performing path-based reopens in the browser process.
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
Likely the design of base::ScopedTempFile closes the file descriptor after creation and only keeps the path, so later path-based reopens with FLAG_CREATE_ALWAYS lack O_NOFOLLOW and follow symlinks.
Impact
If successfully exploited, a compromised GPU or Network child process could escape the macOS App Sandbox by writing to user configuration files, executing arbitrary code at the user's full privilege level.
What the attacker needed
MacOS; compromised GPU or Network child process; shared temporary directory access
The fix
The text suggests hardening base::File::DoInitialize to restrict symlink traversal and deprecating path-only temporary file structures in favour of retaining open file handles; it does not state that a fix was applied.
How it was found
- A high-privilege browser component creates a temporary file using ScopedTempWebBundleFile::Create().
- The underlying ScopedTempFile::Create() uses mkstemp and immediately closes the file descriptor, retaining only the string path.
- A compromised sandboxed child process monitors the temporary directory, unlinks the temporary file, and places a symlink at the same path pointing to a sensitive file.
- The browser process instructs SimpleURLLoader::DownloadToFile to write to the ScopedTempWebBundleFile's path with create_temp_file = false.
- FileWriter opens the target file using base::File::Initialize with FLAG_CREATE_ALWAYS, which compiles to open with O_CREAT | O_TRUNC | O_WRONLY and without O_NOFOLLOW.
- The kernel follows the symlink, truncating and overwriting the target file outside the sandbox at browser-process privilege level.
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 its path is remembered, but the file itself is closed. Another program running with fewer privileges can quickly delete that file and put a shortcut (symbolic link) in its place. When the main browser later writes to that path, it follows the shortcut and overwrites a sensitive file, potentially letting the attacker run 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.