Use after free in Mojo (CVE-2026-8580)
A race condition in Android's NFC implementation allows a background thread and the UI thread to concurrently destroy the same Mojo connection, leading to a double-free or use-after-free of a native object in the browser process. An attacker could potentially exploit this to cause memory corruption, though no working exploit was demonstrated.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 48 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A race condition exists in Android's NfcImpl where an NFC tag discovery callback runs on a background Binder thread while Mojo connection teardown happens on the UI thread. This can result in concurrent calls to Mojo's Java WatcherImpl.destroy(), leading to a double-free or Use-After-Free (UAF) of the native WatcherImpl object in the browser process.
Affected files:
mojo/public/java/system/src/org/chromium/mojo/system/impl/WatcherImpl.javaservices/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.javamojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.javamojo/public/java/system/watcher_impl.ccmojo/public/cpp/system/simple_watcher.cc
Estimated timestamp from git blame: 2025-07-02
Summary
A race condition in Android's NfcImpl allows a Binder thread and the UI thread to concurrently attempt to destroy the same Mojo connection. Because WatcherImpl.java lacks synchronization for its native pointer handle, this can result in a double-free or Use-After-Free (UAF) of the native C++ WatcherImpl object in the highly privileged Browser process.
Vulnerability Details
In NfcImpl.java, the onTagDiscovered method is triggered by the Android NFC adapter. According to Android documentation, this callback is invoked on a background Binder thread. NfcImpl processes the tag synchronously on this Binder thread and eventually attempts to send the read message to the renderer by calling mClient.onWatch().
mClient is a Mojo proxy whose underlying Connector and WatcherImpl were created on the UI thread. Mojo Java bindings do not enforce thread-confinement for proxy method calls.
If the webpage concurrently aborts the NFC scan or navigates away, the UI thread will begin closing the Mojo connection, which eventually calls Connector.close() -> WatcherImpl.destroy().
Simultaneously, if the Binder thread attempts to send the message via mClient.onWatch(), the underlying MessagePipeHandle.writeMessage() may fail because the handle is being closed. This throws a MojoException which is caught in Connector.accept(). The catch block calls Connector.onError(), which also invokes Connector.close() -> WatcherImpl.destroy() on the Binder thread.
WatcherImpl.destroy() manages its native counterpart via a jlong mImplPtr:
public void destroy() {
if (mImplPtr == 0) {
return;
}
WatcherImplJni.get().delete(mImplPtr);
mImplPtr = 0;
}
Because this method is not synchronized and mImplPtr is not volatile, both the UI thread and the Binder thread can concurrently read a non-zero value for mImplPtr and pass the same pointer to WatcherImplJni.get().delete(). This results in delete reinterpret_cast<WatcherImpl*>(watcher_ptr); being executed twice in C++ (watcher_impl.cc), causing a double-free in the browser process heap.
Alternatively, if one thread deletes the object while the other thread is executing WatcherImpl.cancel(), the native JNI_WatcherImpl_Cancel will be called with a freed pointer, causing a Use-After-Free.
Note: This analysis was performed by an AI agent and has not been verified with a working proof-of-concept exploit.
Potential Reproduction Steps
- A malicious page requests and is granted WebNFC permission.
- The page calls
NDEFReader.scan(), establishing a Mojo connection (NfcImpl). - The user taps a malicious physical NFC tag designed to artificially stall the NDEF read on the background Binder thread.
- While the Binder thread is blocked, the webpage aborts the scan, causing the UI thread to initiate Mojo connection teardown.
- The malicious NFC tag releases the stall. The Binder thread finishes the read and calls
mClient.onWatch(). - The write fails due to the concurrent teardown, throwing a
MojoExceptionwhich triggersConnector.close()on the Binder thread. - The UI thread and Binder thread concurrently execute
WatcherImpl.destroy(), resulting in a double-free or UAF in the C++ browser process.
Suggested Fix
In NfcImpl.java, ensure that all interactions with Mojo interfaces (such as mClient.onWatch() or mClient.onError()) are posted back to the UI thread, as Mojo endpoints should generally be thread-confined. For example, use PostTask.postTask(TaskTraits.UI_DEFAULT, ...) to deliver the messages. Additionally, WatcherImpl.java could be hardened by synchronizing destroy() and cancel(), or by using an AtomicLong for mImplPtr.
Evaluated with Chrome root at commit: bb48272cafb7e24c93f55ef40da398cd206ee651
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. Please feel free to reach out to me if you have concerns or feedback.
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 in WatcherImpl.destroy() and the failure to confine Mojo proxy calls to the UI thread, allowing concurrent destruction of the same native pointer.
Impact
This could lead to a double-free or use-after-free in the browser process, potentially enabling memory corruption, but no working exploit was verified.
What the attacker needed
WebNFC permission granted; malicious physical NFC tag; user taps the tag
The fix
The fix should post all Mojo interface interactions back to the UI thread and harden WatcherImpl by synchronising destroy() and cancel() or using an AtomicLong for mImplPtr.
How it was found
- A malicious page requests and is granted WebNFC permission.
- The page calls NDEFReader.scan(), establishing a Mojo connection.
- The user taps a malicious physical NFC tag designed to stall the NDEF read on the background Binder thread.
- While the Binder thread is blocked, the webpage aborts the scan, causing the UI thread to initiate Mojo connection teardown.
- The malicious NFC tag releases the stall; the Binder thread finishes the read and calls mClient.onWatch().
- The write fails due to the concurrent teardown, throwing a MojoException which triggers Connector.close() on the Binder thread.
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.
This report describes a timing bug in Android's NFC code. Two parts of the program can try to clean up the same internal object at the same time, which can corrupt memory. The author thinks this could be abused by a malicious webpage and a specially crafted NFC tag, but they did not actually build an exploit.
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.