Race in Payments (CVE-2026-8520)
The Java PaymentAppService drops references to native-backed JniPaymentApp objects without explicit cleanup, so the Java garbage collector finalises them on a background thread and destroys UI-thread-affine C++ objects off-thread. This causes a data race in the WebContents observer list, potentially leading to heap corruption and remote code execution in the privileged browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 26 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 go/chrome-ai-generated-security-bugs-faq for more information.
Overview: During payment app deduplication, Java JniPaymentApp references are dropped without explicitly cleaning up their native C++ counterparts. When Android's Garbage Collector later finalizes these objects on a background thread, it synchronously destroys UI-thread-affine C++ objects like SecurePaymentConfirmationApp. This triggers off-thread modification of the WebContents observer list, causing concurrent memory mutation and potential heap corruption in the privileged Browser process.
Affected files:
components/payments/content/android/java/src/org/chromium/components/payments/PaymentAppService.javacomponents/payments/content/android/java/src/org/chromium/components/payments/JniPaymentApp.javacomponents/payments/content/secure_payment_confirmation_app.hcomponents/payments/content/service_worker_payment_app.hcomponents/webauthn/content/browser/internal_authenticator_impl.h
Estimated timestamp from git blame: 2024-10-01
Summary
There is a potential thread-safety vulnerability in the Android PaymentApp implementation. The Java-side PaymentAppService drops references to native-backed JniPaymentApp objects without calling their explicit cleanup method (dismissInstrument()). Relying on the Java Garbage Collector to finalize these objects results in C++ destructors executing on the Android FinalizerDaemon thread instead of the Browser UI thread. Because these C++ objects observe WebContents, destroying them off-thread leads to a data race in base::ObserverList, allowing an attacker to corrupt the heap in the Browser process.
Vulnerability Details
- In
PaymentAppService.java, thededuplicatePaymentAppsmethod filters out redundant payment apps (for example, hiding a Service Worker payment app if a preferred native Android app is present). - When an app is filtered out, it is removed from the local collections (e.g.,
uniquePaymentApps) and the temporarymPossiblyDuplicatePaymentAppslist is cleared. The references are dropped without invokingdismissInstrument(). - The unreferenced
JniPaymentAppinstances become eligible for Java Garbage Collection. - When the GC runs, the Android
FinalizerDaemonthread executesJniPaymentApp.finalize(), which callsdismissInstrument()and crosses the JNI boundary to invokeJniPaymentApp::FreeNativeObject(env). FreeNativeObjectexecutesdelete this;, which destroys the underlying C++PaymentAppobject (such asSecurePaymentConfirmationApporServiceWorkerPaymentApp) entirely on the backgroundFinalizerDaemonthread.SecurePaymentConfirmationAppinherits fromcontent::WebContentsObserver. Its destructor implicitly calls~WebContentsObserver(), which invokesWebContentsImpl::RemoveObserver(this).WebContentsImpl::RemoveObservercallsRemoveObserveron itsbase::ObserverList.- If
base::ObserverListcurrently has no active iterators (live_iterators_.empty()), it bypasses its internal sequence checker and directly callsobservers_.erase(it)on its underlyingstd::vector. - This concurrent
std::vector::erase()execution from a background thread races against the Browser UI thread, which frequently reads, iterates, and mutates the sameWebContentsobserver list.
Because std::vector is not thread-safe, this data race causes use-after-free or memory corruption inside the highly-privileged Browser process, potentially leading to a Sandbox Escape and Remote Code Execution (RCE).
Potential Reproduction Steps
Note: Our tooling agent cannot run code yet, so these steps are theoretical based on code analysis.
- An attacker hosts a malicious website that registers a Service Worker payment handler.
- The Service Worker's web-app manifest includes
"prefer_related_applications": trueand specifies a widely installed Android native payment app as a related application. - The attacker's site invokes a
PaymentRequestwith methods that match both the Service Worker and the Android native app. - During the payment app discovery phase, both apps are instantiated in C++ and Java.
PaymentAppService.deduplicatePaymentAppsdrops the Java reference to the Service Worker app in favor of the native app.- The attacker uses memory-intensive JavaScript to apply memory pressure, forcing an Android Garbage Collection.
- The
FinalizerDaemontriggers the C++ destructor off-thread. Concurrent UI actions (like navigating theWebContentsor registering a new observer) cause a data race in theObserverList, crashing or corrupting the Browser process.
Suggested Fix
- Explicit Cleanup: Update
PaymentAppService.javato explicitly calldismissInstrument()on anyPaymentAppinstances that are discarded during deduplication or when aPaymentRequestis aborted/closed, ensuring resources are freed deterministically on the UI thread. - Thread Enforcement: Update
JniPaymentApp::FreeNativeObjectto ensure the C++ object is always deleted on the UI thread, regardless of which thread initiates it. For example, usecontent::GetUIThreadTaskRunner({})->DeleteSoon(...)instead of a directdelete this;.
Evaluated with Chrome root at commit: 661452647ddb2827305122ff3273bd5dea403f09
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 Java code drops references to JniPaymentApp objects without calling dismissInstrument(), so the Java finaliser destroys the native C++ object on a background thread instead of the UI thread.
Impact
This data race could cause use-after-free or memory corruption in the privileged browser process, potentially leading to a sandbox escape and remote code execution.
What the attacker needed
Android device with Chrome; Victim visits attacker's website; Attacker registers a Service Worker payment handler; Manifest sets prefer_related_applications to true
The fix
The fix should explicitly call dismissInstrument() on discarded PaymentApp instances and ensure native objects are always deleted on the UI thread, for example by using DeleteSoon instead of a direct delete.
How it was found
- An attacker hosts a malicious website that registers a Service Worker payment handler.
- The Service Worker's web-app manifest includes "prefer_related_applications": true and specifies a widely installed Android native payment app as a related application.
- The attacker's site invokes a PaymentRequest with methods that match both the Service Worker and the Android native app.
- During the payment app discovery phase, both apps are instantiated in C++ and Java.
- PaymentAppService.deduplicatePaymentApps drops the Java reference to the Service Worker app in favor of the native app.
- The attacker uses memory-intensive JavaScript to apply memory pressure, forcing an Android Garbage Collection.
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.
When a payment app is no longer needed, the Java code simply forgets about it instead of cleaning it up properly. Later, Java's automatic memory cleaner (the garbage collector) runs on a background thread and destroys the underlying C++ object there, but that object is only safe to destroy on the main UI thread. This can corrupt memory in the browser process, which is dangerous because that process has high privileges.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.