Use after free in Input (CVE-2026-15118)
A use-after-free exists in Chromium's input handling where a gesture event can synchronously trigger focus/blur events, allowing a nested event loop to destroy the widget. An attacker could then cause a 1-byte write of zero to freed memory, potentially leading to arbitrary read/write and remote code execution in the renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 27 days
Flapjack, 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 Use-After-Free vulnerability exists in WidgetBaseInputHandler::HandleInputEvent. Handling specific gesture events can synchronously trigger DOM blur/focus events, allowing a nested event loop to destroy the WidgetBase. Returning to the unwound stack results in a reliable 1-byte write of zero to freed memory, bypassing MiraclePtr protections.
Affected files:
third_party/blink/renderer/platform/widget/input/widget_base_input_handler.ccthird_party/blink/renderer/core/frame/web_frame_widget_impl.cc
Estimated timestamp from git blame: 2020-10-31
Description
A potential Use-After-Free (UAF) vulnerability exists in WidgetBaseInputHandler::HandleInputEvent. When processing gesture events, the code can trigger synchronous DOM selection updates, leading to a nested event loop. If the widget is destroyed during this loop, execution unwinds to a dangling this pointer, resulting in a reliable memory corruption primitive.
Vulnerability Details
- Gesture Handling: In
WidgetBaseInputHandler::HandleInputEvent, gesture events are pre-processed viawidget_->client()->WillHandleGestureEvent(...). - Synchronous Selection: For certain gestures (e.g.,
kGestureScrollBeginwithcursor_controlactive),WebFrameWidgetImpl::WillHandleGestureEventcallsfocused_frame->MoveCaretSelection(...). - Synchronous Event Dispatch: Updating the selection can synchronously dispatch
blurandfocusevents viaSetFocusedNodeIfNeeded()if the focused element changes. - Nested Event Loop & Destruction: An attacker can register a JavaScript event listener for these
blurorfocusevents that spins a nested event loop (e.g., usingwindow.print()). During this loop, the frame can be detached via an IPC message (e.g.,mojom::Frame::Delete), destroying theWebFrameWidgetImpl, itsWidgetBase, and the inline memberWidgetBaseInputHandler. - UAF Write: When the stack unwinds back to
HandleInputEvent, execution continues using the now-danglingthispointer:
if (input_event.GetType() != WebInputEvent::Type::kChar ||
!suppress_next_char_events_) {
suppress_next_char_events_ = false; // <--- UAF Write
Because the event is not a kChar event, the first half of the logical OR evaluates to true. C++ short-circuit evaluation prevents the read of !suppress_next_char_events_ (which might otherwise crash if the memory was poisoned). The code unconditionally executes the assignment, resulting in a reliable 1-byte write of 0x00 (false) to the offset of suppress_next_char_events_.
MiraclePtr Bypass
This vulnerability bypasses MiraclePtr (BackupRefPtr). WidgetBaseInputHandler is an inline member of WidgetBase, and its internal raw_ptr<WidgetBase> widget_ is destroyed alongside the widget. Because this is the only raw_ptr to the allocation, the refcount drops to zero, and the memory is fully freed to PartitionAlloc. The subsequent access in HandleInputEvent uses the raw implicit this pointer on the stack, which BRP does not protect.
Potential Exploitation Steps
(Note: These are suggested steps based on static analysis; a working PoC has not been executed).
- Create an attacker-controlled cross-site iframe.
- Inside the iframe, create a focusable text input and attach a
blurevent listener. - Induce the user to perform a cursor movement gesture (e.g., swiping the spacebar on the Android virtual keyboard) while the text input is focused.
- In the
blurevent listener, callwindow.print()to spin a nested event loop. - From the parent frame, remove the iframe from the DOM, triggering the destruction of the iframe's
WidgetBasevia IPC. - During the nested event loop (e.g., using a Web Worker), spray the PartitionAlloc heap with objects matching the size of
WidgetBase(~1056 bytes). - When the event loop finishes and the stack unwinds, the UAF write will overwrite a 1-byte value in the attacker-controlled sprayed object, potentially corrupting a length field or pointer to achieve arbitrary read/write and Remote Code Execution in the renderer process.
Recommended Fix
Move the existing WeakPtr check (!weak_self) earlier in HandleInputEvent. It currently resides at line 427, after the UAF write occurs at line 415. The check should be placed immediately following the calls to WillHandleMouseEvent and WillHandleGestureEvent (around line 409) to ensure the handler is still valid before accessing any member variables.
Evaluated with Chrome root at commit: 2155cb00003ec35716a76ed3246eae995f87b7ff
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 code accesses member variables after a nested event loop may have destroyed the object, because the WeakPtr check occurs after the write.
Impact
An attacker could potentially corrupt a length field or pointer to achieve arbitrary read/write and remote code execution in the renderer process, though a working proof-of-concept has not been executed.
What the attacker needed
Victim uses a browser with gesture input; victim interacts with a malicious iframe; attacker can trigger a cursor movement gesture
The fix
The WeakPtr check should be moved earlier in HandleInputEvent, immediately after the calls to WillHandleMouseEvent and WillHandleGestureEvent, to ensure the handler is still valid before accessing any member variables.
How it was found
- Create an attacker-controlled cross-site iframe.
- Inside the iframe, create a focusable text input and attach a blur event listener.
- Induce the user to perform a cursor movement gesture while the text input is focused.
- In the blur event listener, call window.print() to spin a nested event loop.
- From the parent frame, remove the iframe from the DOM, triggering destruction of the iframe's WidgetBase via IPC.
- During the nested event loop, spray the PartitionAlloc heap with objects matching the size of WidgetBase.
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 using memory after it has been freed. Here, handling a gesture can run JavaScript that destroys the widget, but the code then writes to the now-freed memory. This could let an attacker corrupt memory and possibly 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.