Use after free in WebView (CVE-2026-9888)
A potential use-after-free exists in Android WebView when a synchronous Java CleanupReference execution destroys the native AwContents object while a permission request is being handled, leading to a use-after-free write when the stack unwinds. A compromised renderer could trigger this in the unsandboxed browser process, potentially leading to remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 18 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 https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential Use-After-Free (UAF) vulnerability exists in Android WebView when a synchronous Java CleanupReference execution unexpectedly destroys the native AwContents object. This deletes the currently executing PermissionRequestHandler, leading to a UAF write when the execution stack unwinds.
Affected files:
android_webview/browser/permission/permission_request_handler.ccandroid_webview/browser/aw_contents.ccandroid_webview/java/src/org/chromium/android_webview/CleanupReference.javaandroid_webview/java/src/org/chromium/android_webview/permission/AwPermissionRequest.javaandroid_webview/browser/permission/aw_permission_request.cc
Estimated timestamp from git blame: 2026-01-26
Vulnerability Details
A potential Use-After-Free (UAF) vulnerability exists in the Android WebView browser process (the embedding application process). The issue is caused by an unsafe synchronous reentrancy and destruction pattern involving Java's CleanupReference mechanism.
In Android WebView, native objects are typically managed by Java peer objects using the CleanupReference class. When a Java object is garbage collected, its corresponding CleanupReference is enqueued in a global queue (sGcQueue) to be processed by a reaper thread.
If an embedder application abandons a WebView without explicitly calling destroy(), the Java AwContents object is eventually garbage collected, and its cleanup task is added to sGcQueue. A race condition occurs if a renderer-initiated permission request (e.g., Geolocation, MIDI) is processed on the UI thread while the AwContents cleanup task is still pending in the queue.
Potential Execution Chain:
-
PermissionRequestHandler::SendRequestis called on the UI thread to handle a new permission request from the renderer. -
It calls
client_->OnPermissionRequest(implemented by the C++AwContents). -
Inside
AwContents::OnPermissionRequest, it attempts to fetch the Java peer. Since the JavaAwContentshas already been collected, the JNI weak reference returns null. It then synchronously re-entersPermissionRequestHandler::CancelRequest()to cleanly abort the request. -
CancelRequestenters awhileloop, retrieves an iteratorito the request, and callsCancelRequestInternal, which invokesAwPermissionRequest::CancelAndDelete. -
This triggers a JNI call to
AwPermissionRequest.destroyNative, which explicitly callsmCleanupReference.cleanupNow()in the Java layer. -
CleanupReference.cleanupNow()dispatches a message to the UI thread. Since execution is already on the UI thread, the message handler runs synchronously. -
Crucially, this message handler contains a loop that drains the entire global
sGcQueuesynchronously:Java while ((ref = (CleanupReference) sGcQueue.poll()) != null) { ref.runCleanupTaskInternal(); } -
If the
AwContentscleanup task is still in the queue, it is executed synchronously. This triggers the destruction of the nativeAwContentsobject (delete this). BecauseAwContentsowns thePermissionRequestHandlervia astd::unique_ptr, the handler is also immediately deleted from the heap. -
When execution unwinds back to the C++
PermissionRequestHandler::CancelRequestmethod, it resumes thewhileloop and executesrequests_.erase(i). -
At this point, the implicit
thispointer (thePermissionRequestHandler) and itsrequests_vector have been deleted, resulting in a UAF read and write on the vector's freed heap buffer.
(Note: These are potential steps based on code analysis; we do not yet have a working proof of concept.)
Impact
This vulnerability allows a compromised renderer to trigger a Use-After-Free write in the unsandboxed browser process (the embedding Android application). This provides a strong primitive that can lead to Remote Code Execution (RCE) in the context of the application using WebView.
This vulnerability is not protected by MiraclePtr (BRP) because the access occurs through the implicit this pointer held on the call stack and a stack-based iterator (i), both of which bypass BRP protections.
Suggested Fix
To prevent this synchronous destruction race, avoid executing the entire sGcQueue synchronously during an explicit cleanupNow(). Alternatively, in PermissionRequestHandler::CancelRequest or AwContents::OnPermissionRequest, the cancellation callbacks or the destruction of the AwPermissionRequest should be posted asynchronously (e.g., using base::SingleThreadTaskRunner::PostTask) rather than executed synchronously on the current call stack.
Evaluated with Chrome root at commit: eca8648a4e1cdfdda68c495a6003059fed641955
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 the synchronous draining of the global garbage-collection queue during an explicit cleanup call, which can delete the native AwContents and its owned PermissionRequestHandler while a permission request is still being processed on the stack.
Impact
A compromised renderer could trigger a use-after-free write in the unsandboxed browser process, potentially leading to remote code execution in the context of the embedding application.
What the attacker needed
Compromised renderer; embedder abandons WebView without destroy(); race with pending cleanup task
The fix
The fix should avoid synchronously draining the entire garbage-collection queue during an explicit cleanup, or post the cancellation and destruction asynchronously instead of executing them on the current call stack.
How it was found
- A renderer-initiated permission request is sent to the UI thread and handled by PermissionRequestHandler::SendRequest.
- The handler calls the client's OnPermissionRequest, which tries to fetch the Java peer but finds it already garbage collected.
- The handler synchronously re-enters CancelRequest, which calls CancelRequestInternal and then AwPermissionRequest::CancelAndDelete.
- This triggers a JNI call to destroyNative, which calls CleanupReference.cleanupNow() and synchronously drains the global sGcQueue.
- The pending AwContents cleanup task runs, deleting the native AwContents and its owned PermissionRequestHandler.
- When execution returns to CancelRequest, it tries to erase the request from the now-freed vector, causing a use-after-free write.
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 is a bug where a program keeps using memory after it has been freed, which can let an attacker control what happens next. Here, a permission request from a web page causes the object handling it to be deleted while still in use, and then the code tries to clean up that same object, writing to freed memory. This happens in the part of Android that runs web content, so a malicious page could exploit it.
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.