Use after free in Downloads (CVE-2026-8522)
A use-after-free flaw in iOS Chrome's download manager arises from a race condition during the dismissal animation of the download UI. An attacker who times a tab closure within the 200ms window could potentially trigger the use of freed memory, leading to remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 24 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 Chrome Security team. Please see go/chrome-ai-generated-security-bugs-faq for more information.
Overview: A potential Use-After-Free vulnerability exists in iOS Chrome's Download Manager due to a race condition during the dismissal animation of the download UI. A sequence of downloading, closing the UI, downloading again, and closing the tab can result in a dangling raw pointer that bypasses MiraclePtr and is accessed virtually.
Affected files:
ios/chrome/browser/download/coordinator/download_manager_coordinator.mmios/chrome/browser/download/model/download_manager_tab_helper.mmios/chrome/browser/download/coordinator/download_manager_mediator.mmios/chrome/browser/presenters/ui_bundled/vertical_animation_container.mm
Estimated timestamp from git blame: 2025-04-22
Technical Details
A potential Use-After-Free (UAF) vulnerability exists in DownloadManagerCoordinator on iOS. The coordinator manages the lifecycle of the download UI and holds a bare Objective-C pointer to the active web::DownloadTask in the _downloadTask ivar. This pointer is not protected by MiraclePtr (base::raw_ptr).
The vulnerability is triggered by a race condition during the dismissal of the download manager UI:
-
UI Dismissal Initiated: When a user taps 'Close' on the download bar,
DownloadManagerCoordinatorcalls-pause. This sets_stopped = YES, clears_downloadTask, and initiates a 200msUIViewanimation inVerticalAnimationContainerto dismiss the UI. -
New Download Arrival: If a new download (D2) arrives while the dismissal animation is still running,
didCreateDownload:is called. It updates the raw_downloadTaskivar to point to D2 and calls-restart. Because_stoppedisYESand the presenter is still displaying the view controller (as the animation is not finished),-restartsets_restartPending = YESand returns early. Crucially, it does not call_mediator.SetDownloadTask(D2). The mediator (which usesraw_ptr<web::DownloadTask>) never receives a pointer to D2. -
Tab Closure: If the tab is closed (e.g., via
window.close()) during this same animation window, theWebStatedetachment process eventually callsDownloadManagerCoordinator::pause. However, because_stoppedis alreadyYES,pausereturns early (ios/chrome/browser/download/coordinator/download_manager_coordinator.mm:186) without clearing the now-populated_downloadTaskor the_restartPendingflag. -
Task Destruction: When the
WebStateis destroyed,DownloadManagerTabHelper::WebStateDestroyedclears itsstd::unique_ptr<web::DownloadTask>, which destroys D2. Since noraw_ptrever held a reference to D2, the object's BackupRefPtr refcount drops to zero, and the memory is unquarantined. -
Use-After-Free: When the 200ms dismissal animation completes,
containedPresenterDidDismiss:is called. Seeing_restartPendingisYES, it calls-restart, which now proceeds to call_mediator.SetDownloadTask(_downloadTask). This method performs a virtual call (AddObserver) on the freed_downloadTaskobject through its vtable pointer.
Impact
This vulnerability could potentially allow for Remote Code Execution (RCE) in the browser process of iOS Chrome. An attacker who can time a tab closure within the 200ms window after a user closes the download bar can trigger this UAF. By reclaiming the freed memory with controlled data (e.g., via heap spraying during the animation window), the attacker might gain control of the vtable and redirect execution in the unsandboxed browser process.
Potential Reproduction Steps
- Host an attacker-controlled page (T0) that opens a popup (T1).
- In T1, trigger a fast download (D1) to show the download bar.
- Prompt the user to tap the 'X' button to close the download bar for D1.
- In T1, set up a script that triggers a second download (D2) and calls
window.close()within the 200ms animation window following the 'X' tap. - Upon completion of the animation, the browser will attempt to use the freed
web::DownloadTaskobject, leading to a crash or code execution.
Suggested Fix
- Convert the
_downloadTaskivar inDownloadManagerCoordinatorfrom a bare pointer to abase::raw_ptr<web::DownloadTask>orbase::WeakPtr<web::DownloadTask>to ensure it is protected by MiraclePtr or safely nullified. - In
DownloadManagerCoordinator::pause, do not return early if_stoppedis alreadyYES. Ensure_downloadTaskand_restartPendingare cleared regardless of the_stoppedstate to prevent dangling pointers and stale state.
Evaluated with Chrome root at commit: 7353d249d9cacf9c7218e1d7b8a39cf39c72d646
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 download manager coordinator stores a bare Objective-C pointer to the download task that is not protected by MiraclePtr, and its pause method returns early when already stopped, leaving a dangling pointer that is later used after the task is destroyed.
Impact
This could potentially allow remote code execution in the browser process of iOS Chrome if an attacker can time a tab closure within the 200ms window and reclaim the freed memory with controlled data.
What the attacker needed
Victim uses iOS Chrome; victim taps close on download bar; attacker times tab closure within 200ms
The fix
The fix should convert the raw pointer to a protected pointer type and ensure the pause method clears state even when already stopped.
How it was found
- Host an attacker-controlled page that opens a popup.
- In the popup, trigger a fast download to show the download bar.
- Prompt the user to tap the close button on the download bar.
- In the popup, set up a script that triggers a second download and calls window.close() within the 200ms animation window.
- Upon completion of the animation, the browser attempts to use the freed download task 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 pointer to memory after that memory has been freed, and then tries to use it. Here, the download manager holds a raw pointer to a download task, and during a short animation window, that task can be destroyed while the pointer remains. If an attacker can time things right, they might make the program use the freed memory, which could crash the browser or let them run their own 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.