Use after free in Downloads (CVE-2026-8551)
A use-after-free vulnerability exists in the macOS download progress tracking code because an asynchronous block captures a raw pointer to a DownloadItem. An attacker who can groom the heap could potentially hijack the virtual table and achieve remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 42 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 without the security team.
Overview: A potential Use-After-Free (UAF) vulnerability exists in the macOS implementation of download progress tracking. An asynchronous block captures a raw pointer to a DownloadItem, which can be dereferenced after the item has been destroyed, potentially leading to a browser process compromise.
Affected files:
chrome/browser/download/download_status_updater_mac.mmchrome/browser/download/download_status_updater.hcomponents/download/internal/common/download_item_impl.cc
Estimated timestamp from git blame: 2022-03-08
Summary
A potential Use-After-Free (UAF) vulnerability exists in chrome/browser/download/download_status_updater_mac.mm due to the unsafe capture of a raw pointer in an asynchronous block.
The CreateOrGetNSProgress function sets the cancellationHandler for an NSProgress object, capturing a raw C++ download::DownloadItem* pointer by value. This handler is invoked by macOS on an arbitrary background thread when a user cancels a download via the Finder UI, and subsequently dispatches a task to the main GCD queue to call download->Cancel(). If the DownloadItem is destroyed on the main thread before the dispatched task executes, a UAF occurs.
Technical Details
In chrome/browser/download/download_status_updater_mac.mm at line 71:
progress.cancellationHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
download->Cancel(/*user_cancel=*/true);
});
};
The download pointer is captured as a raw pointer, circumventing Chromium's safe pointer mechanisms. According to Apple's documentation, the cancellationHandler runs on an arbitrary thread.
When a download is removed (e.g., via DownloadItemImpl::Remove()), the DownloadItem synchronously self-deletes. Although CrNSProgressUserData::~CrNSProgressUserData calls [progress_ unpublish], this does not revoke or cancel blocks that have already been enqueued via dispatch_async to the main GCD queue.
Since Cancel() is a virtual method (virtual void Cancel(bool user_cancel) = 0; in download_item.h), an attacker who can groom the heap to replace the freed DownloadItemImpl with controlled data can potentially achieve virtual table hijacking. This may lead to Remote Code Execution (RCE) within the highly privileged, unsandboxed browser process, effectively escaping the sandbox.
Potential Steps to Reproduce
Note: Our tooling agent doesn't yet have the ability to run code. These are suggested steps to trigger the vulnerability based on static analysis.
- An attacker (e.g., via a malicious extension or website) initiates a large or slow file download to ensure the
NSProgressremains active. - In macOS Finder (icon view), the user clicks the (X) overlay on the file icon to cancel the download. This triggers the
cancellationHandleron a background thread, which enqueues aCancel()call to the main queue. - Simultaneously, the attacker triggers the deletion of the
DownloadItemon the main thread. This could be done by:- Using a Chrome extension with the
downloadspermission to callchrome.downloads.erase(). - Closing the incognito window hosting the download.
- Selecting "Remove from list" in
chrome://downloads.
- Using a Chrome extension with the
- When the main thread's dispatch queue drains, it will execute
download->Cancel(true)on the freedDownloadItemImplobject.
Suggested Fix
Do not capture a raw C++ pointer in an asynchronous Objective-C block.
Instead, capture a base::WeakPtr<download::DownloadItem> (if supported by the caller, which it currently is not for the abstract DownloadItem interface without casting) or capture the unique download ID (e.g., uint32_t download_id = download->GetId();) and perform a lookup via the DownloadManager inside the block executing on the main thread before calling Cancel().
Evaluated with Chrome root at commit: e9e0fcbb690b1a8c1a26c81c2a9ea23d6e178368
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 cancellation handler block captures a raw C++ pointer to DownloadItem instead of a safe reference, and the dispatched task can run after the object is destroyed.
Impact
An attacker who can groom the heap could potentially achieve virtual table hijacking, leading to remote code execution within the unsandboxed browser process and escaping the sandbox.
What the attacker needed
MacOS; attacker can initiate a download; user cancels via Finder; attacker can delete the download item
The fix
The fix should avoid capturing a raw pointer in the asynchronous block, instead using a weak pointer or looking up the download by ID before calling Cancel().
How it was found
- An attacker initiates a large or slow file download to keep the NSProgress active.
- The user cancels the download via the Finder UI, triggering the cancellationHandler on a background thread.
- Simultaneously, the attacker triggers deletion of the DownloadItem on the main thread.
- When the main thread's dispatch queue drains, it executes Cancel() on the freed DownloadItemImpl object.
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 use-after-free happens when a program keeps a reference to memory after it has been freed, and then uses it again. Here, a background task holds a raw pointer to a download object; if the download is deleted before the task runs, the task calls a function on freed memory. An attacker who can control what replaces that memory might execute arbitrary code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.