Skip to content
Race condition Advisory Advanced CVE-2026-106405

Race condition in CustomTabs (CVE-2026-106405)

A lifecycle flaw in Chrome's PostMessageHandler lets a malicious Android app inject a wildcard MessagePort into an arbitrary website loaded in a Custom Tab. If the victim page does not validate message origins, the attacker could establish a persistent bidirectional channel into that origin's context.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 4 months

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 lifecycle management flaw in PostMessageHandler allows a malicious Android application to inject a bidirectional MessagePort into an arbitrary website loaded within a Chrome Custom Tab. If a cross-document navigation occurs before the PostMessage channel is fully initialized, the cleanup path is bypassed because mChannel is null, leaking a stale WebContents reference. Once the pending Digital Asset Links (DAL) verification completes, the handler initializes the channel and delivers a wildcard MessagePort to the newly loaded, potentially untrusted origin.

Affected files:

  • chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java

Estimated timestamp from git blame: 2026-05-18

Issue Overview

In PostMessageHandler, the lifecycle management of mWebContents is potentially flawed when a cross-document navigation occurs before the PostMessage channel has been fully initialized (such as during asynchronous Digital Asset Links (DAL) verification). If mChannel is null when the navigation occurs, the cleanup path is bypassed, leaving a stale reference to mWebContents while the navigation observer self-detaches. A subsequently completed DAL verification will then target the new document on the stale mWebContents, sending a wildcard-target MessagePort to the newly navigated origin.

Root Cause Analysis

In chrome/android/java/src/org/chromium/chrome/browser/browserservices/PostMessageHandler.java, the WebContentsObserver is configured to tear down state on cross-document navigation:

Java
@Override
public void didFinishNavigationInPrimaryMainFrame(NavigationHandle navigation) {
    if (mNavigatedOnce && navigation.hasCommitted() && !navigation.isSameDocument()) {
        observe(null);                 // Observer detaches itself
        mPostMessageSourceUri = null;
        disconnectChannel();           // Triggers teardown
        return;
    }
    mNavigatedOnce = true;
}

However, the disconnectChannel() method is implemented as follows:

Java
private void disconnectChannel() {
    if (mChannel == null) return;   // Early return if no channel exists
    mChannel[0].close();
    mChannel = null;
    mWebContents = null;            // Bypassed if mChannel is null
    mPostMessageBackend.onDisconnectChannel(ContextUtils.getApplicationContext());
}

If the navigation happens while DAL verification is still pending, mChannel will be null. As a result, disconnectChannel() returns early and mWebContents is not set to null, even though the observer has already detached itself (observe(null)).

When DAL verification eventually completes, onOriginVerified triggers initializeWithPostMessageUri(), which acts on the stale mWebContents without verifying if the current committed origin matches the verified origin:

Java
public void initializeWithPostMessageUri(Uri postMessageUri, @Nullable Uri targetOrigin) {
    mPostMessageSourceUri = postMessageUri;
    mPostMessageTargetUri = targetOrigin;
    if (mWebContents != null && !mWebContents.isDestroyed()) {
        initializeWithWebContents(mWebContents);   // Re-initializes on the stale WebContents
    }
}

Inside initializeWithWebContents(), a new MessageChannel is created and a message is posted to the main frame of the stale WebContents (which now displays the navigated page, such as a third-party victim site):

Java
private void initializeWithWebContents(final WebContents webContents) {
    mChannel = webContents.createMessageChannel();
    mChannel[0].setMessageCallback(mMessageCallback, null);
    webContents.postMessageToMainFrame(
            new MessagePayload(""),
            mPostMessageSourceUri.toString(),
            mPostMessageTargetUri != null ? mPostMessageTargetUri.toString() : "",  // Wildcard target
            new MessagePort[] {mChannel[1]});
    ...
}

Because mPostMessageTargetUri can be null (such as via the 2-argument Custom Tabs API requestPostMessageChannel overload), the target origin defaults to "" (wildcard). Consequently, the browser process delivers the MessagePort to whatever origin is currently loaded in the WebContents without enforcing an origin match.

Potential Attack Steps

(Note: These are suggested/potential steps; our tooling does not currently have the capability to dynamically execute code to verify them.)

  1. A malicious Android application initiates a Chrome Custom Tab (CCT) session.
  2. The application requests a postMessage channel with a target origin parameter set to null.
  3. The application intentionally delays the Digital Asset Links verification (for example, by stalling the .well-known/assetlinks.json fetch on its own server).
  4. The application navigates the CCT to a target victim origin (e.g., https://victim.com).
  5. The navigation completes, triggering the WebContentsObserver to detach and call disconnectChannel(). Since mChannel is null, mWebContents remains pointing to the active WebContents instance.
  6. The application allows the DAL check to succeed. This invokes initializeWithPostMessageUri, delivering a wildcard MessagePort to the victim origin.
  7. If the victim page's window.onmessage handler does not strictly validate the message's origin, the attacker can establish a persistent, bidirectional communication channel into the authenticated context of the victim origin.

Suggested Fix

Ensure that mWebContents is always cleared when disconnectChannel() is called, regardless of whether mChannel is null:

Java
private void disconnectChannel() {
    if (mChannel != null) {
        mChannel[0].close();
        mChannel = null;
        mPostMessageBackend.onDisconnectChannel(ContextUtils.getApplicationContext());
    }
    mWebContents = null;
}

Additionally, initializeWithPostMessageUri or initializeWithWebContents should verify that the current committed origin of the WebContents matches the expected target origin before posting the message channel.

Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 cleanup method returns early when no channel exists, so the stored WebContents reference is not cleared, and a later verification step reuses that stale reference without checking the current origin.

Impact

If the victim page's message handler does not strictly validate origins, the attacker could establish a persistent bidirectional channel into the authenticated context of the victim origin; the report notes the steps are potential and were not dynamically verified.

What the attacker needed

Malicious Android app installed; victim page lacks strict origin checks; attacker controls DAL verification timing

The fix

The cleanup method should always clear the stored WebContents reference, and the initialisation path should verify that the current committed origin matches the expected target origin before posting the channel.

How it was found

  1. A malicious Android app opens a Chrome Custom Tab.
  2. The app requests a postMessage channel with a null target origin.
  3. The app delays Digital Asset Links verification by stalling the assetlinks.json fetch.
  4. The app navigates the Custom Tab to a victim origin.
  5. The navigation triggers the observer to detach and call disconnectChannel, but mChannel is null so mWebContents is not cleared.
  6. The app lets DAL verification succeed, which delivers a wildcard MessagePort to the victim origin.

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.

Chrome Custom Tabs let Android apps open web pages inside Chrome. A feature called postMessage lets the app and the page talk to each other, but only after Chrome checks that the app really owns the site. Here, if the page changes while that check is still running, Chrome forgets to clean up and later hands a communication channel to whatever page is now loaded, even though it never verified that page.

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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.