Use after free in Payments (CVE-2026-19155)
A use-after-free vulnerability exists in the browser-process PaymentRequest class when calling delegate_->ShowErrorMessage(), which can synchronously destroy the hosting WebContents and free the PaymentRequest instance. Subsequent code then accesses freed memory, potentially leading to memory corruption.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 29 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 potential Use-After-Free (UAF) vulnerability exists in the browser-process PaymentRequest class. When calling delegate_->ShowErrorMessage(), the hosting WebContents (and thus the PaymentRequest DocumentService itself) can be synchronously destroyed. Subsequent execution inside the method continues to access members of the freed PaymentRequest instance, potentially leading to memory corruption.
Affected files:
components/payments/content/payment_request.cc
Estimated timestamp from git blame: 2021-06-16
Description
A potential Use-After-Free (UAF) vulnerability has been identified in PaymentRequest::ShowErrorMessageAndAbortPayment() located in components/payments/content/payment_request.cc.
PaymentRequest is a browser-process content::DocumentService<mojom::PaymentRequest> whose lifetime is tied to the RenderFrameHost's document. When a Secure Payment Confirmation (SPC) dialog is shown, calling delegate_->ShowErrorMessage() can trigger synchronous dismissal of the widget dialog. Crucially, closing the widget can trigger activation/focus observers (such as ExtensionPopup::OnWidgetTreeActivated) that synchronously destroy the hosting WebContents.
When the WebContents is destroyed, ~DocumentAssociatedData synchronously deletes all registered DocumentService objects, executing ~PaymentRequest(). This frees the PaymentRequest heap allocation. However, when the execution stack unwinds and returns to the caller frame PaymentRequest::ShowErrorMessageAndAbortPayment(), the code continues to read from and execute virtual calls through member variables of the freed this pointer.
Potential Call Chain
PaymentRequest::ShowErrorMessageAndAbortPayment()ChromePaymentRequestDelegate::ShowErrorMessage()SecurePaymentConfirmationController::ShowErrorMessage()SecurePaymentConfirmationController::OnCancel()SecurePaymentConfirmationController::CloseDialog()SecurePaymentConfirmationDialogView::HideDialog()views::Widget::Close()- Focus/activation shifts, triggering observers like
ExtensionPopup::OnWidgetTreeActivatedwhich synchronously callWebContents::Close()/ destroy the host. DocumentAssociatedData::~DocumentAssociatedData()executes and synchronously destroys thePaymentRequestinstance.- Execution resumes in
PaymentRequest::ShowErrorMessageAndAbortPayment()at line 1294:
// components/payments/content/payment_request.cc:1287-1301
void PaymentRequest::ShowErrorMessageAndAbortPayment() {
if (display_handle_ && display_handle_->was_shown()) {
delegate_->ShowErrorMessage(); // <--- synchronously frees |this|
if (observer_for_testing_) // <--- UAF read of freed member variable
observer_for_testing_->OnErrorDisplayed(); // <--- Virtual method call on potentially corrupted/reclaimed heap memory
} else {
...
}
}
Why Previous Hardening is Insufficient
While the hardening fix for crbug.com/521495992 applied a weak_this guard inside SecurePaymentConfirmationController::OnCancel() to prevent the controller itself from accessing freed memory, it did not protect the caller frame PaymentRequest::ShowErrorMessageAndAbortPayment(). When the WebContents is destroyed, both the controller and the PaymentRequest parent service are freed. The execution resumes in PaymentRequest without any self-lifetime validation.
Suggested / Potential Trigger Steps
(Note: These are suggested steps based on source-code tracing; our tooling does not currently have the capability to run a live proof of concept).
- Embed a PaymentRequest-capable iframe within a focus-sensitive parent window (such as an extension popup dialog).
- Initialize a
PaymentRequestspecifying Secure Payment Confirmation (SPC) with valid credentials matching a registered authenticator. - Call
Show()to bring up the SPC dialog modal. - Before any user interaction, have the compromised renderer issue a
mojom::PaymentRequest::Complete(mojom::PaymentComplete::FAIL)Mojo message. PaymentRequest::Completereceives the failure command and routes execution toShowErrorMessageAndAbortPayment(), triggering the synchronous destruction flow described above.
Suggested Fix
To remediate this issue, check if the PaymentRequest object has been destroyed during the synchronous call by capturing and checking a base::WeakPtr of this before accessing any member variables:
void PaymentRequest::ShowErrorMessageAndAbortPayment() {
if (display_handle_ && display_handle_->was_shown()) {
base::WeakPtr<PaymentRequest> weak_self = weak_ptr_factory_.GetWeakPtr();
delegate_->ShowErrorMessage();
if (!weak_self) {
return;
}
if (observer_for_testing_)
observer_for_testing_->OnErrorDisplayed();
} else {
...
}
}
Evaluated with Chrome root at commit: 84065d9121f6e48f67755f0ae963cc09617e5c85
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 code does not check whether the PaymentRequest object was destroyed during the synchronous call to delegate_->ShowErrorMessage(), leading to use of freed memory.
Impact
This could lead to memory corruption, potentially allowing an attacker to execute arbitrary code or cause a crash.
What the attacker needed
Compromised renderer; SPC with valid credentials; focus-sensitive parent window
The fix
The issue should be fixed by capturing a base::WeakPtr of this before the synchronous call and checking it before accessing any member variables.
How it was found
- Embed a PaymentRequest-capable iframe within a focus-sensitive parent window.
- Initialize a PaymentRequest specifying Secure Payment Confirmation with valid credentials.
- Call Show() to bring up the SPC dialog modal.
- Before any user interaction, have the compromised renderer issue a Complete(FAIL) Mojo message.
- PaymentRequest::Complete routes execution to ShowErrorMessageAndAbortPayment(), triggering the synchronous destruction 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 frees memory but then keeps using it, like deleting a file and still trying to read it. Here, showing an error message can cause the whole page to close, which frees the payment object, but the code then tries to use that object again. This can crash the browser or let an attacker run harmful 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.