Use after free in WebView (CVE-2026-13037)
A use-after-free exists in the Android WebView JS Sandbox service because incoming Binder messages can use a raw pointer to a JsSandboxMessagePort object that has already been freed during isolate teardown. An attacker could potentially exploit this race to achieve arbitrary code execution in the utility process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 10 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. 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 exists in JsSandboxMessagePort due to a race condition during JsSandboxIsolate destruction. Incoming Binder messages from Java blindly cast a raw long to a C++ pointer, which may have already been freed when the V8 isolate tears down its garbage-collected heap. An attacker could potentially exploit this to achieve arbitrary code execution in the utility process.
Affected files:
android_webview/js_sandbox/service/js_sandbox_message_port.ccandroid_webview/js_sandbox/service/js_sandbox_message_port.handroid_webview/js_sandbox/java/src/org/chromium/android_webview/js_sandbox/service/JsSandboxMessagePort.java
Estimated timestamp from git blame: Unknown (Google3 checkout)
Summary
A potential Use-After-Free (UAF) vulnerability exists in JsSandboxMessagePort within the Android WebView JS Sandbox service. The vulnerability stems from a lack of synchronization between the destruction of a JsSandboxIsolate (and its associated V8 Oilpan heap) and concurrent incoming Inter-Process Communication (IPC) messages processed on Binder threads.
Technical Details
When a JsSandboxMessagePort is created, its C++ counterpart is allocated on V8's cppgc (Oilpan) heap. The native memory address is passed back to Java and stored as a raw long (mNativeJsSandboxMessagePort).
When a JsSandboxIsolate is closed via the Java API, a DeleteSelf task is posted to the isolate thread. This task synchronously destroys the V8 isolate and its attached CppHeap. Destroying the heap unconditionally frees the memory of all associated JsSandboxMessagePort objects.
However, incoming messages on the MessagePort (handled by MessagePortInternal.MessagePortClient callbacks on a Binder thread) do not synchronize with this teardown. A concurrent message can invoke JNI methods such as tryAllocateMemoryBudget or handleString using the raw mNativeJsSandboxMessagePort value. The JNI bridge blindly casts this long back to a JsSandboxMessagePort*.
If the V8 isolate teardown occurs precisely between the message arriving and the JNI boundary crossing, the Binder thread will execute methods on a freed C++ object.
Exploitability
This vulnerability is not protected by MiraclePtr (BackupRefPtr). The JNI boundary relies on an unmanaged jlong, bypassing reference counting. Furthermore, JsSandboxMessagePort is allocated in the CppHeap, which does not support BRP.
An attacker could potentially exploit this to gain Remote Code Execution (RCE) in the js_sandbox utility process using the following theoretical steps:
- Spawn two isolates (
Isolate AandIsolate B) via the JS Sandbox API. - Trigger the destruction of
Isolate Awhile simultaneously flooding its MessagePort with incoming strings from Java to hit the race window. - As soon as
Isolate Abegins teardown, execute a heap spray payload inIsolate B(which shares the same process address space). - Reclaim the freed
JsSandboxMessagePortmemory chunk with an attacker-controlled fake object. - Overwrite the
js_sandbox_isolate_pointer in the fake object to point to another forged structure containing a fakeTaskRunner. - When the racing Binder thread executes
JsSandboxMessagePort::HandleString, it will dereference the fakejs_sandbox_isolate_and callGetIsolateTaskRunner()->PostTask(...). PostTaskmakes a virtual method call toPostDelayedTask, which will be hijacked via the fakeTaskRunner's vtable, redirecting control flow to an attacker payload.
(Note: These are suggested steps based on code analysis; our tooling has not run a live proof-of-concept exploit.)
Suggested Fix
- Do not use raw memory addresses (
long) to track C++ object lifetimes across the JNI boundary if the C++ object can be destroyed asynchronously. - A thread-safe handle or registry (e.g., using a lock and an ID-to-pointer map) should be used to look up the
JsSandboxMessagePortpointer from Java. - During isolate teardown, the
JsSandboxMessagePortobjects should be safely unregistered from this map so that concurrent Binder calls fail gracefully rather than dereferencing a dangling pointer.
Evaluated with Chrome root at commit: 65b3256311f3ab6fb9870eaa522de7e6dd2663bb
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
Likely the lack of synchronisation between isolate teardown and concurrent Binder messages, combined with passing a raw C++ pointer across the JNI boundary as an unmanaged long, allows a dangling pointer to be dereferenced.
Impact
An attacker could potentially achieve remote code execution in the js_sandbox utility process, though the report notes the exploit steps are theoretical and have not been run as a live proof-of-concept.
What the attacker needed
Ability to use the JS Sandbox API; ability to spawn multiple isolates; ability to send messages to a MessagePort; win a narrow race window
The fix
The fix should replace raw pointer tracking across JNI with a thread-safe handle or registry, and unregister message ports during isolate teardown so concurrent calls fail gracefully.
How it was found
- Spawn two isolates via the JS Sandbox API.
- Trigger destruction of one isolate while flooding its MessagePort with incoming strings from Java.
- Execute a heap spray payload in the other isolate to reclaim the freed memory.
- Overwrite the isolate pointer in the fake object to point to a forged structure with a fake TaskRunner.
- When the racing Binder thread handles a string, it dereferences the fake isolate and calls PostTask on the fake TaskRunner, hijacking control flow.
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 a piece of memory after it has been freed, like reading a note after it has been shredded. Here, messages arriving from Java can still refer to a C++ object that has just been destroyed, so the program may treat random memory as if it were that object. If an attacker can control what fills that memory, they might redirect the program's execution.
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.