Race condition in Downloads (CVE-2026-130987)
A time-of-check to time-of-use flaw in the 'Save Page As' feature allows a compromised renderer to append malicious data to a saved file after the antivirus scan has started but before it finishes, bypassing the scan. An attacker could thus deliver a malicious file that appears to have passed the OS quarantine check.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 8 months
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A Time-of-Check to Time-of-Use (TOCTOU) vulnerability exists in the "Save Page As" feature. A compromised renderer can bypass OS-level antivirus quarantine checks by appending malicious data to a saved file after it has signaled completion but before the asynchronous AV scan finishes.
Affected files:
content/browser/download/save_file_manager.cccontent/browser/download/save_package.cccontent/browser/download/save_file.hcontent/browser/download/save_package_serialization_handler.cc
Estimated timestamp from git blame: 2025-10-22
Summary
A logic flaw in the serialization process of "Save Page As" (Complete HTML) leads to a potential write-after-quarantine Time-of-Check to Time-of-Use (TOCTOU) vulnerability. A compromised renderer can exploit this by sending a Done() signal to initiate the asynchronous antivirus scan (via the OS Quarantine Service) and subsequently sending malicious data via DidReceiveData(). Because the browser does not ignore further data or close the file handle during the quarantine window, the malicious data is appended to the file while or after it is scanned, effectively bypassing the security check.
Technical Details
-
Persistent Communication Channel: When a user saves a page, the browser initiates serialization and creates a Mojo receiver for
FrameHTMLSerializerHandlerusingmojo::MakeSelfOwnedReceiverinSavePackage::GetSerializedHtmlWithLocalLinksForFrame. When the renderer callsDone(),SavePackageSerializationHandler::Done()is executed. It runs the completion callback but does not close the Mojo pipe or invalidate the data callback. This allows a compromised renderer to continue callingDidReceiveData(). -
Asynchronous Quarantine and Weak Guards: Upon receiving the
Done()signal,SavePackage::OnDidFinishedSerializingHtmlDataposts a task toSaveFileManager::SaveFinished. This method callsSaveFile::RunQuarantineCallback(), initiating an asynchronous quarantine process (e.g.,IAttachmentExecute::Save()on Windows).During this asynchronous scan:
- The
SaveFileobject remains active inSaveFileManager::save_file_map_. SaveFile::InProgress()remains true becauseClose()is only called inSaveCompletedafter the quarantine resolves.- In
SavePackage::OnDidReceiveSerializedHtmlData, the UI thread statesave_item->state()is stillIN_PROGRESS.
- The
-
The TOCTOU Race: Because the file remains open and the state checks still pass, any
DidReceiveData()calls arriving during the quarantine window are successfully written to disk viaSaveFileManager::UpdateSaveProgressandAppendDataToFile. The malicious payload is appended to the file while or after the AV scanner reads the benign prefix, allowing the attacker to bypass the scan.
Potential Attacker Steps
Note: These steps are suggested based on code analysis; our tooling has not executed a live proof-of-concept.
- An attacker compromises a renderer process.
- The user is tricked into saving the webpage (e.g., via Ctrl+S).
- The browser requests the serialized HTML from the compromised renderer.
- The renderer sends a benign HTML payload via
DidReceiveData(benign_data). - The renderer sends the
Done()signal, prompting the browser to begin the OS-level antivirus scan on the file. - Immediately after, the renderer sends
DidReceiveData(malicious_data)over the still-open Mojo pipe. - The browser appends the malicious data to the file while the AV scan is occurring on the benign prefix.
- The AV scan completes with a safe verdict, and the browser finalizes the file, leaving the user with a malicious file that bypassed scanning.
Suggested Fix
Modify SavePackageSerializationHandler to ignore data received after Done() is called. For example, explicitly clear or check the did_serialize_data_callback_:
void SavePackageSerializationHandler::DidReceiveData(
const std::string& data_buffer) {
if (!did_serialize_data_callback_) return;
did_serialize_data_callback_.Run(data_buffer);
}
void SavePackageSerializationHandler::Done() {
if (!done_callback_) return;
std::move(done_callback_).Run();
did_serialize_data_callback_.Reset(); // Prevent further writes
}
Alternatively, SavePackage::OnDidReceiveSerializedHtmlData could check if the item is already waiting for quarantine, or the Mojo receiver could be explicitly closed upon Done().
Evaluated with Chrome root at commit: 876d480da1f794d87813cfa2e6ff4fcf9771e939
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 browser does not stop accepting data from the renderer after the renderer signals that serialization is done, so data sent during the asynchronous antivirus scan is still written to the file.
Impact
A compromised renderer could bypass the OS antivirus quarantine check and cause the user to save a malicious file that appears to have been scanned and found safe.
What the attacker needed
Compromised renderer process; user saves the page (e.g., Ctrl+S)
The fix
The browser should ignore any data received after the Done() signal, for example by resetting the data callback or closing the Mojo receiver.
How it was found
- An attacker compromises a renderer process.
- The user is tricked into saving the webpage (e.g., via Ctrl+S).
- The browser requests the serialized HTML from the compromised renderer.
- The renderer sends a benign HTML payload via DidReceiveData(benign_data).
- The renderer sends the Done() signal, prompting the browser to begin the OS-level antivirus scan on the file.
- Immediately after, the renderer sends DidReceiveData(malicious_data) over the still-open Mojo pipe.
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 writes the file and then asks the operating system's antivirus to check it. The browser keeps the file open during that check, so a malicious part of the browser can sneak extra bad content into the file after the check has already looked at the safe beginning. This means the antivirus says the file is safe, but it actually contains harmful data.
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.