Inappropriate implementation in Chrome for iOS (CVE-2026-17822)
A time-of-check to time-of-use race condition in Chrome for iOS download finalisation allows two concurrent downloads with the same server-chosen filename to resolve to the same destination path, so one file silently overwrites the other. An attacker could exploit this to substitute a legitimate downloaded file with a malicious one.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
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 the finalization of iOS downloads within Chrome. Due to path resolution and file moving being split across non-atomic operations and multiple thread hops, concurrent downloads with identical server-chosen names can select the same target path. Consequently, one download can silently overwrite the other via POSIX rename semantics, leading to content substitution.
Affected files:
ios/chrome/browser/download/model/download_file_service.mmios/chrome/browser/download/model/download_manager_tab_helper.mmios/chrome/browser/download/model/download_directory_util.mmios/chrome/browser/download/model/download_file_service_factory.mm
Estimated timestamp from git blame: 2025-04-16
Potential Security Vulnerability: TOCTOU in iOS Download Finalization
We have identified a potential Time-of-Check to Time-of-Use (TOCTOU) vulnerability in the download finalization pipeline of Chrome on iOS. When multiple downloads with identical server-specified filenames complete concurrently in different tabs, they can resolve to the exact same destination file path. Due to POSIX rename() semantics, the second file move silently overwrites the first, leading to silent content substitution.
Root Cause Analysis
When a download completes on iOS Chrome, DownloadManagerTabHelper drives finalization using a series of asynchronous callbacks hopping between the main thread and the background sequenced runner file_task_runner_ belonging to the profile's DownloadFileService instance.
Specifically, the path-uniquification step checks for destination existence using base::PathExists, but it does not reserve or lock the path. Because the pipeline is split across five thread hops before the actual move occurs, a significant race window exists:
- Main Thread:
OnDownloadUpdated(kComplete)$\rightarrow$MaybeMoveDownloadToDownloadsDirectoryinitiates filename resolution viaResolveAvailableFilePath(user_download_path, base_file_name)(ios/chrome/browser/download/model/download_manager_tab_helper.mm, line 402). - Hop 1 (Main Thread $\rightarrow$ Background Runner):
ResolveAvailableFilePathpostsFindAvailableDownloadFilePathtofile_task_runner_. - Background Runner:
FindAvailableDownloadFilePath(ios/chrome/browser/download/model/download_file_service.mm, line 125) checks if/Documents/file_name.pdfexists. Since it does not exist yet, it returns this path. - Hop 2 (Background Runner $\rightarrow$ Main Thread): Returns to main thread callback
UseAvailableUserDocumentsPath(line 308). - Main Thread:
UseAvailableUserDocumentsPathstores the target path intask_final_file_path_and callsCheckFileExiststo ensure the source temporary file still exists (line 317). - Hop 3 (Main Thread $\rightarrow$ Background Runner):
CheckFileExistsposts a task to the background runner. - Background Runner: Evaluates
base::PathExists(source_path). - Hop 4 (Background Runner $\rightarrow$ Main Thread): Returns to main thread callback
MoveToUserDocumentsIfFileExists. - Main Thread: Calls
MoveDownloadFile(line 332). - Hop 5 (Main Thread $\rightarrow$ Background Runner): Posts
DoMoveFileOnBackgroundThreadtofile_task_runner_. - Background Runner: Runs
DoMoveFileOnBackgroundThread(line 100), callingbase::Movewhich usesrename()under the hood on POSIX (base/files/file_util_posix.cc, line 1496).
If two concurrent tabs download files that resolve to the same server-chosen name, both will execute the FindAvailableDownloadFilePath check (Step 3) before either has executed the actual move (Step 11). Thus, both will independently resolve to the same destination path, and the second move operation will silently overwrite the first.
Potential Attack Scenario
An attacker could potentially exploit this behavior via the following steps:
- The attacker hosts a page that concurrently initiates two downloads: a victim-requested download of a legitimate file (e.g.,
invoice.pdffromvictim.com) and an attacker-controlled file with the same filename (invoice.pdffromattacker.com). - Due to the multi-hop timing window, both downloads resolve to
/Documents/invoice.pdfduring path resolution. - The attacker's download completes and moves into place, or completes second and overwrites the legitimate file's content.
- The legitimate download's UI card shows completion and points to
/Documents/invoice.pdfas its target. When the user taps "Open" or shares the file from the trusted context, they will access the attacker's payload instead.
Note: These are suggested/potential steps; our tooling does not currently have the ability to execute code to produce an active Proof of Concept.
Suggested Fix
To remediate this issue, path resolution and file moving should be performed atomically on the background thread. Alternatively, when FindAvailableDownloadFilePath determines a path is available, it should immediately reserve it (e.g., by creating an empty placeholder file using O_CREAT | O_EXCL flags) before returning the path to the main thread. This ensures that any subsequent path-existence checks for concurrent downloads will detect the conflict and select a unique filename (e.g., invoice (1).pdf).
Evaluated with Chrome root at commit: 5133b93d189b383c37805b1cf3a9d2dbfe8d7379
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 path-uniquification check and the file move are not atomic and are separated by multiple thread hops, so two concurrent downloads can both see the same path as available and then both move to it.
Impact
An attacker could cause a user to open or share a malicious file instead of the legitimate file they intended to download, leading to content substitution.
What the attacker needed
Victim visits attacker's page; two concurrent downloads with same filename; user opens or shares the downloaded file
The fix
Path resolution and file moving should be performed atomically on the background thread, or the path should be immediately reserved (e.g., by creating an empty placeholder file with exclusive create flags) before returning it to the main thread.
How it was found
- The attacker hosts a page that concurrently initiates two downloads: a legitimate file and an attacker-controlled file with the same filename.
- Both downloads resolve to the same destination path during path resolution due to the multi-hop timing window.
- The attacker's download completes and moves into place, or completes second and overwrites the legitimate file's content.
- The legitimate download's UI card shows completion and points to the overwritten file; when the user opens or shares it, they access the attacker's payload.
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 download a file, the browser checks if a file with that name already exists and then later moves the new file into place. If two downloads happen at the same time, both can check before either moves, so they pick the same name and one overwrites the other. An attacker could use this to replace a file you downloaded from a trusted site with their own malicious file.
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.