Use after free in HTML (CVE-2026-13899)
A use-after-free flaw in Blink's popup handling allows a re-entrant call during popup cancellation to orphan a popup, leaving a dangling pointer in the client. An attacker could exploit this to achieve arbitrary code execution via heap spraying.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 3 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 without the Chrome Security team.
Overview: A Use-After-Free vulnerability exists in Blink's handling of page popups due to a re-entrancy flaw in WebViewImpl::OpenPagePopup. Synchronous JavaScript execution during popup cancellation can create a secondary popup whose reference is later overwritten by the outer call. When the orphaned popup is eventually freed, its client retains a dangling raw pointer that can be dereferenced, potentially leading to arbitrary code execution.
Affected files:
third_party/blink/renderer/core/exported/web_view_impl.ccthird_party/blink/renderer/core/exported/web_page_popup_impl.ccthird_party/blink/renderer/core/html/forms/internal_popup_menu.ccthird_party/blink/renderer/core/html/forms/color_chooser_popup_ui_controller.ccthird_party/blink/renderer/core/html/forms/select_type.ccthird_party/blink/renderer/core/html/forms/html_select_element.cc
Estimated timestamp from git blame: 2022-06-29
Description
A potential Use-After-Free (UAF) vulnerability exists in the Blink renderer's handling of page popups (e.g., <select> menus and color pickers). The issue arises from re-entrant calls to WebViewImpl::OpenPagePopup, which can be triggered by synchronous JavaScript execution during the cancellation of an existing popup.
When WebViewImpl::OpenPagePopup is called, it first calls CancelPagePopup() to maintain a single-popup invariant. CancelPagePopup() systematically closes the active popup, which invokes HTMLSelectElement::PopupDidCancel(). If there is a provisional selection, this method synchronously dispatches a change event. An attacker can use a change event listener to immediately open another popup, causing a re-entrant call to OpenPagePopup.
The inner OpenPagePopup successfully creates a WebPagePopupImpl instance, assigns it to the WebViewImpl::page_popup_ scoped_refptr, and returns the raw pointer to the client (e.g., InternalPopupMenu), which stores it in a PagePopup* member variable.
Once the synchronous script finishes, the outer OpenPagePopup resumes execution. It creates its own WebPagePopupImpl instance and overwrites WebViewImpl::page_popup_. The inner popup is now orphaned from WebViewImpl but remains alive due to a self-reference.
When the browser process detects the inner widget is orphaned, it initiates closure, triggering WebPagePopupImpl::Close(). This calls WebViewImpl::ClosePagePopup(popup). However, ClosePagePopup checks if page_popup_.get() == popup. Since page_popup_ now points to the outer popup, the check fails, and the method early-returns. Consequently, the client's DidClosePopup() is never called, and its raw pointer is never nulled. The WebPagePopupImpl then drops its self-reference and is freed, leaving the client with a dangling pointer.
Because WebPagePopupImpl is allocated via PartitionAlloc (USING_FAST_MALLOC) and the client holds a bare pointer (PagePopup*) rather than raw_ptr<T>, MiraclePtr does not mitigate this vulnerability.
Potential Steps to Trigger
Note: These are suggested steps to trigger the vulnerability based on code analysis; our tooling has not executed this as a live proof-of-concept.
- An attacker serves an HTML page containing
<select id="s1">,<input type="color" id="c1">, and<select id="s2">. - The user interacts with
s1, opening the popup and provisionally selecting an option. - A user gesture (e.g., keypress) triggers an event listener that calls
c1.click(). Because of the user gesture, this passes transient activation checks. WebViewImpl::OpenPagePopupis called forc1(the "outer" call). It callsCancelPagePopup()to closes1.- Closing
s1commits the provisional selection, firing a synchronouschangeevent. - The attacker's
changeevent listener callss2.showPicker(), triggering the "inner" re-entrant call toWebViewImpl::OpenPagePopup. - The inner call creates Popup C, assigns it to
WebViewImpl::page_popup_, ands2'sInternalPopupMenustores a raw pointer to Popup C. - The inner call completes, the event listener finishes, and the outer
OpenPagePopupresumes. - The outer call creates Popup B and overwrites
WebViewImpl::page_popup_with it. - The browser destroys the orphaned Popup C widget, invoking
WebPagePopupImpl::Close(). WebViewImpl::ClosePagePopupbails out early becausepage_popup_points to Popup B. TheInternalPopupMenuis not notified, leaving itspopup_pointer dangling.- Popup C is freed from memory.
- The attacker script mutates
s2's DOM (e.g., adding an<option>). This triggersInternalPopupMenu::Update(), which attempts to send the new data to the UI by callingpopup_->PostMessageToPopup(). - The virtual function call dereferences the freed memory. If the attacker has used heap spraying, they can hijack the vtable to achieve arbitrary code execution.
Suggested Fix
- Lifecycle fix (Primary): Prevent re-entrancy in
WebViewImpl::OpenPagePopup. This could be done by using a boolean flag (is_opening_popup_) and ignoring/crashing on nested calls, or by establishing anEventDispatchForbiddenScopeorEventQueueScopearound the popup teardown/creation logic to defer synchronous JavaScript execution. - Memory safety fix (Defense in depth): Migrate the raw
PagePopup* popup_pointer in clients (such asInternalPopupMenuandColorChooserPopupUIController) tobase::raw_ptr<PagePopup>. This ensures that even if the lifecycle logic fails, the vulnerability is mitigated to a safe crash via MiraclePtr.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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
Likely a re-entrancy flaw in WebViewImpl::OpenPagePopup where synchronous JavaScript during popup cancellation allows a nested popup to be created and then overwritten, leaving a dangling pointer in the client.
Impact
An attacker could potentially achieve arbitrary code execution by exploiting the dangling pointer with heap spraying, though the report notes this is based on code analysis and not a live proof-of-concept.
What the attacker needed
Victim visits attacker page; user gesture required; browser with vulnerable Blink
The fix
The report suggests preventing re-entrancy in OpenPagePopup and migrating raw pointers to base::raw_ptr, but does not state that a fix was applied.
How it was found
- An attacker serves an HTML page with select and color input elements.
- The user interacts with a select element, opening its popup and provisionally selecting an option.
- A user gesture triggers an event listener that calls click() on the color input, passing transient activation checks.
- The outer OpenPagePopup call cancels the select popup, which synchronously fires a change event.
- The change event listener calls showPicker() on another select, triggering an inner re-entrant OpenPagePopup that creates and stores a popup.
- The outer call resumes, creates its own popup, and overwrites the stored reference, orphaning the inner popup.
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 frees memory but keeps a pointer to it, then later uses that pointer as if the memory still belonged to it. Here, a popup window is closed and freed, but the code that manages it still holds a reference and tries to use it, which can let an attacker take control. This is dangerous because the attacker can arrange for the freed memory to contain data they control.
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.