Use after free in Autofill (CVE-2026-11131)
A use-after-free exists in the Android OTP verification dialog because the native C++ object is deleted synchronously on dismissal while the UI remains interactive during a 200ms fade-out animation. An attacker who can interact with the fading UI could trigger JNI calls on freed memory, potentially leading to remote code execution in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 53 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.
Overview: A potential Use-After-Free (UAF) exists in the Android OTP verification dialog. The native C++ object is destroyed synchronously upon dismissal, but the UI remains interactive during a 200ms fade-out animation. Interactions during this window invoke JNI methods using a stale pointer, potentially leading to Remote Code Execution in the browser process.
Affected files:
chrome/browser/ui/android/autofill/otp_verification_dialog_view_android.ccchrome/browser/ui/android/autofill/internal/java/src/org/chromium/chrome/browser/ui/autofill/OtpVerificationDialogBridge.javachrome/browser/ui/android/autofill/internal/java/src/org/chromium/chrome/browser/ui/autofill/OtpVerificationDialogMediator.javacomponents/browser_ui/modaldialog/android/java/src/org/chromium/components/browser_ui/modaldialog/TabModalPresenter.javaui/android/java/src/org/chromium/ui/modaldialog/ModalDialogManager.java
Estimated timestamp from git blame: 2021-12-07
Summary
A potential Use-After-Free (UAF) vulnerability has been identified in the OTP verification dialog for Autofill Payments on Chrome for Android. The issue stems from a lifecycle mismatch: the native OtpVerificationDialogViewAndroid C++ object deletes itself synchronously when the dialog is dismissed, but the corresponding Android UI remains visible and interactive during a 200ms exit animation.
Because the native pointer is stored as a primitive long in the Java bridge (OtpVerificationDialogBridge), it is not protected by MiraclePtr (BackupRefPtr). User or attacker-induced interaction with the UI during the animation window triggers JNI calls on the freed memory, which could potentially be exploited to achieve Remote Code Execution (RCE) in the highly privileged browser process.
Technical Details
- Dialog Initialization: When the OTP dialog is created,
OtpVerificationDialogBridge(Java) receives a raw pointer toOtpVerificationDialogViewAndroid(C++) and stores it in a primitivelongfield namedmNativeOtpVerificationDialogView. - Synchronous Destruction: When the dialog is dismissed (e.g., via the Cancel button or programmatically),
ModalDialogManager.dismissDialog()synchronously triggers the controller'sonDismisscallback. This propagates to the Java bridge, which calls the native JNI methodonDialogDismissed. The C++ methodOtpVerificationDialogViewAndroid::OnDialogDismissedexecutesdelete this;, freeing the native object's memory. - Asynchronous UI Teardown: Immediately after notifying the controller,
ModalDialogManagerinstructsTabModalPresenterto remove the view. Because the view is attached,TabModalPresenterinitiates a 200ms alpha fade-out animation (runExitAnimation). During this 200ms window, the view is not hidden, and its click listeners (such as theChromeClickableSpanfor the "Get new code" link) are not disabled. - Triggering the UAF: If an interaction occurs on the fading UI during this 200ms window (e.g., tapping "Get new code"), the Java bridge blindly passes the dangling
mNativeOtpVerificationDialogViewpointer across JNI toOtpVerificationDialogViewAndroid::OnNewOtpRequested. - Exploitation Path: Because the pointer crosses JNI as a primitive integer, MiraclePtr does not track it. An attacker capable of spraying the browser process heap (e.g., from a compromised renderer) could predictably reclaim the freed memory during the 200ms window. The C++ code evaluates
if (controller_)wherecontroller_is abase::WeakPtr. The attacker can forge theWeakPtrand its internalFlagobject to pass the validity check. The subsequent call to the pure virtual methodcontroller_->OnNewCodeLinkClicked()reads a fake vtable from the attacker-controlled memory, leading to potential arbitrary control-flow hijacking.
Note: These steps describe a potential exploitation path based on code analysis; an active proof-of-concept exploit has not been executed.
Potential Reproduction Steps
- Trigger an OTP verification dialog in Chrome for Android.
- Initiate dismissal of the dialog (e.g., tap 'Cancel').
- Within the 200ms exit animation window, tap the 'Get new code' link or the 'Confirm' button.
- Observe a crash or unexpected behavior due to the use of the freed native object.
Proposed Fix
The Java OtpVerificationDialogBridge should clear its native pointer upon dismissal to prevent further JNI calls. Specifically, in OtpVerificationDialogBridge.java:
@Override
public void onDialogDismissed() {
if (mNativeOtpVerificationDialogView == 0) return;
OtpVerificationDialogBridgeJni.get().onDialogDismissed(mNativeOtpVerificationDialogView);
// Add this line to clear the pointer:
mNativeOtpVerificationDialogView = 0;
}
All other methods in OtpVerificationDialogBridge that call into native (e.g., onConfirm, onNewOtpRequested) should check if mNativeOtpVerificationDialogView != 0 before proceeding. Additionally, TabModalPresenter should consider disabling interaction (e.g., via setClickable(false)) on the dialog container immediately when an exit animation begins.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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 native object is deleted synchronously on dismissal while the Java bridge keeps a raw pointer and the UI remains interactive during the exit animation, so later JNI calls use freed memory.
Impact
An attacker capable of spraying the browser process heap could potentially reclaim the freed memory and hijack control flow, leading to remote code execution in the browser process; however, no active proof-of-concept exploit has been executed.
What the attacker needed
Chrome for Android; OTP verification dialog is shown; attacker can spray browser heap; interaction during 200ms animation
The fix
The Java bridge should clear its native pointer upon dismissal and check it before any JNI call, and the dialog container should be made non-clickable when the exit animation begins.
How it was found
- Trigger an OTP verification dialog in Chrome for Android.
- Initiate dismissal of the dialog (e.g., tap 'Cancel').
- Within the 200ms exit animation window, tap the 'Get new code' link or the 'Confirm' button.
- Observe a crash or unexpected behavior due to the use of the freed native object.
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 frees memory but still uses it later, like deleting a file and then trying to open it. Here, the dialog's underlying code is deleted as soon as you close it, but the on-screen buttons stay clickable for a short animation. If someone clicks during that time, the program tries to use the deleted code, which can crash or, in theory, let an attacker 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.