Skip to content
Memory corruption Advisory Advanced CVE-2026-3936

Use after free in WebView (CVE-2026-3936)

A use-after-free flaw exists in the JsCommunication component of Chromium's WebView when injected JavaScript removes an iframe during script execution. An attacker could exploit this to cause a crash and potentially achieve remote code execution.

Am4deu$ Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 34 days

Steps to reproduce the problem

Tested on Pixel 9 Pro, Chromium version 144.0.7559.109.

  1. Build app.zip and Install
  2. python -m http.server
  3. Visit index.html
  4. UAF and Crash

Problem Description

JsCommunication is a content::RenderFrameObserver, which is destructed along with the destruction of the RenderFrameImpl [1]. On iOS and Android platforms, application developers can use interfaces (such as addDocumentStartJavaScript) to inject JavaScript code that runs at DocumentEnd or DocumentStart. JavaScript injected through this interface also runs in iframes. When the JavaScript executes, the scripts in the vector are processed one by one in a for-loop[2],[3].

C++
void JsCommunication::OnDestruct() {
  delete this;              // [1]
}

void JsCommunication::RunScripts(mojom::DocumentInjectionTime injection_time) {
  url::Origin frame_origin =
      url::Origin(render_frame()->GetWebFrame()->GetSecurityOrigin());
  for (const auto& script : scripts_) {                  // [2]
    if (!script->origin_matcher.Matches(frame_origin)) {
      continue;
    }
    if (script->injection_time == injection_time) {
      if (script->js_world == content::ISOLATED_WORLD_ID_GLOBAL) {
        render_frame()->GetWebFrame()->ExecuteScript(
            blink::WebScriptSource(script->script));
      } else {
        render_frame()->GetWebFrame()->ExecuteScriptInIsolatedWorld(             // [3]
            script->js_world, blink::WebScriptSource(script->script),
            blink::BackForwardCacheAware::kAllow);
      }
    }
  }
}

The injected JavaScript can easily be redirected to code controlled by an attacker, for example, through getter, setter, or redefining functions in the prototype. An attacker can then remove the iframe, causing the RenderFrameImpl to be destroyed, which in turn destroys the JsCommunication object. When the next loop attempts to execute JavaScript, a UAF occurs, which is not protected by miraclePtr Although triggering this UAF requires certain preconditions, in practice, many browsers (such as the Pawxy browser) utilize this interface, and it is also widely used by third-party libraries (e.g., react-native-webview).

  1. app.zip is a simple WebView-based browser that injects two JavaScript codes via the addDocumentStartJavaScript interface.
Java
    private void injectStartUpScripts() {
        if (WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) {
            Set<String> allowedOriginRules = Collections.singleton("*");
            try {
                WebViewCompat.addDocumentStartJavaScript(
                        webView,
                        "console.log(`${new Number(1.1)}`);",
                        allowedOriginRules
                );
//                WebViewCompat.addDocumentStartJavaScript(
//                        webView,
//                        "console.log(global_value)",
//                        allowedOriginRules
//                );
                WebViewCompat.addDocumentStartJavaScript(
                        webView,
                        "console.log('Second Script Injected');",
                        allowedOriginRules
                );
            } catch (Exception e) {
                Log.e(TAG, "addDocumentStartJavaScript failed");
            }
        } else {
            Toast.makeText(this, "addDocumentStartJavaScript not supported", Toast.LENGTH_SHORT).show();
        }
    }
  1. Using this browser to visit the attacker’s webpage.
  2. The attacker’s webpage redefines Number.prototype.toString inside an iframe.
JavaScript
node.contentWindow.Number.prototype.toString = function () {
  node.remove();
};
  1. The first injected JavaScript executes and triggers the attacker’s code, which removes the iframe, ultimately leading to the destruction of JsCommunication.
  2. In the next iteration of the loop, a UAF occurs.

Summary

UAF in JsCommunication, leading to RCE

Custom Questions

Reporter credit:

Am4deu$

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A \

The original report as published on the Chromium issue tracker, by Am4deu$. 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 JsCommunication object is deleted when its RenderFrameImpl is destroyed, but the loop iterating over injected scripts continues to use the deleted object without a check.

Impact

The use-after-free could lead to remote code execution, though the report notes that triggering it requires certain preconditions.

What the attacker needed

Victim uses a WebView app with injected scripts; victim visits attacker-controlled page; app uses addDocumentStartJavaScript

How it was found

  1. Build and install a WebView-based browser app that injects two JavaScript snippets via addDocumentStartJavaScript.
  2. Start a local HTTP server and visit the attacker's index.html page.
  3. The attacker's page redefines Number.prototype.toString inside an iframe to remove the iframe.
  4. The first injected script runs and triggers the attacker's code, removing the iframe and destroying JsCommunication.
  5. On the next loop iteration, a use-after-free occurs and the browser crashes.

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 is a bug where a program deletes an object from memory but then tries to use it again, which can let an attacker control what happens next. Here, a browser feature that injects JavaScript into web pages can be tricked into deleting an iframe while still running scripts, causing the browser to crash and possibly run attacker 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.