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

Inappropriate implementation in WebView (CVE-2026-12438)

A compromised renderer could pipeline multiple print-document requests so that a raw file descriptor is captured by value into background tasks. After the first task closes and the descriptor is recycled, a later task could write attacker-controlled bytes into a reassigned browser-side resource, potentially escaping the sandbox.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 21 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 compromised renderer can potentially trigger a write-after-close vulnerability in the unsandboxed WebView browser process by pipelining multiple Mojo DidPrintDocument requests. This occurs because the raw file descriptor is captured by value into background tasks without being immediately invalidated or guarded against concurrent execution. If the first task completes and the descriptor is closed and recycled, subsequent tasks will write attacker-controlled bytes to the reassigned descriptor.

Affected files:

  • android_webview/browser/aw_print_manager.cc
  • android_webview/browser/aw_print_manager.h

Estimated timestamp from git blame: 2020-12-03

Potential Security Vulnerability in android_webview

There is a potential Use-After-Close (Write-After-Free) vulnerability involving file descriptors inside android_webview/browser/aw_print_manager.cc and android_webview/browser/aw_print_manager.h that can be triggered by a compromised renderer.

Root Cause Analysis

In AwPrintManager, the file descriptor for writing the PDF document is tracked as a raw, borrowed integer (int fd_):

C++
// android_webview/browser/aw_print_manager.h
int fd_ = -1;

When DidPrintDocument is invoked over Mojo, the file descriptor is captured by value into a base::ThreadPool task with BEST_EFFORT priority:

C++
// android_webview/browser/aw_print_manager.cc
void AwPrintManager::DidPrintDocument(
    printing::mojom::DidPrintDocumentParamsPtr params,
    DidPrintDocumentCallback callback) {
  ...
  base::ThreadPool::CreateTaskRunner(
      {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
       base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})
      ->PostTaskAndReplyWithResult(
          FROM_HERE, base::BindOnce(&SaveDataToFd, fd_, number_pages(), data),
          base::BindOnce(&AwPrintManager::OnDidPrintDocumentWritingDone,
                         weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}

There are no concurrent-execution or in-flight guards in DidPrintDocument to prevent multiple requests. Additionally, the tracking variable fd_ is only reset to -1 within PdfWritingDone, which is invoked asynchronously via OnDidPrintDocumentWritingDone on the UI thread after a background worker thread has finished writing:

C++
void AwPrintManager::OnDidPrintDocumentWritingDone(...) {
  PdfWritingDone(base::checked_cast<int>(page_count));
  ...
}

void AwPrintManager::PdfWritingDone(int page_count) {
  fd_ = base::kInvalidFd; // Reset happens after worker completes and triggers callback
  ...
}

Because the DidPrintDocument Mojo interface allows pipelining, a compromised renderer can issue multiple sequential DidPrintDocument messages with the same document cookie before the first task completes. Each duplicate request will pass the cookie check and capture the identical file descriptor fd_ (value N) by value into separate, queued ThreadPool worker tasks.

Potential Step-by-Step Exploitation Scenario

(Please note: These are theoretical steps; our tooling cannot run or execute proof-of-concept code.)

  1. Initiation: The user or host app starts a Print or "Save as PDF" action. AwPrintManager::UpdateParam sets fd_ to a valid system file descriptor N and creates a document cookie.
  2. Pipelining: A compromised renderer acquires the active document cookie and pipelines multiple DidPrintDocument Mojo calls back-to-back.
  3. Task Queueing: Two separate tasks are queued in the background ThreadPool, both capturing the raw file descriptor N by value:
    • Task 1: Bound to write Payload A to N.
    • Task 2: Bound to write Payload B (malicious payload) to N.
  4. Task 1 Completion & FD Close: Task 1 executes, writes Payload A, and returns. The UI thread runs PdfWritingDone, setting fd_ to base::kInvalidFd and triggering the Java completion callback. The Android print framework then closes the underlying system file descriptor N.
  5. FD Grooming: Since Task 2 has BEST_EFFORT priority, the attacker can stall it (e.g., by saturating worker threads) and simultaneously execute browser-side operations from the renderer (such as opening WebSQL/IndexedDB databases, establishing new Mojo data pipes, or opening network sockets) to allocate a new file descriptor. The OS kernel will reassign the newly freed descriptor slot N to one of these sensitive resources.
  6. Write-After-Close (Task 2 Execution): Task 2 finally executes, running SaveDataToFd(N, ..., Payload_B). It executes base::WriteFileDescriptor(N, ...) and writes attacker-controlled bytes directly into the reassigned browser-side resource, resulting in sandbox escape and arbitrary code execution within the unsandboxed WebView browser process.

Suggested Fix

To prevent duplicate or pipelined requests from accessing the same descriptor, the file descriptor should be invalidated immediately upon posting the first writing task, or we should track whether a task is in flight. For example:

C++
void AwPrintManager::DidPrintDocument(
    printing::mojom::DidPrintDocumentParamsPtr params,
    DidPrintDocumentCallback callback) {
  if (params->document_cookie != cookie() || fd_ == base::kInvalidFd) {
    PdfWritingDone(0);
    std::move(callback).Run(false);
    return;
  }
  
  ...
  
  int fd_to_use = fd_;
  fd_ = base::kInvalidFd; // Invalidate immediately to prevent concurrent usage

  base::ThreadPool::CreateTaskRunner(...)
      ->PostTaskAndReplyWithResult(
          FROM_HERE, base::BindOnce(&SaveDataToFd, fd_to_use, number_pages(), data),
          ...);
}

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 raw file descriptor is captured by value into asynchronous background tasks without being invalidated or guarded against concurrent use, so a pipelined request can reuse a closed and recycled descriptor.

Impact

The text claims this could result in sandbox escape and arbitrary code execution within the unsandboxed WebView browser process, but notes the steps are theoretical and no proof-of-concept was run.

What the attacker needed

Compromised renderer; user or host starts a print action; attacker knows the document cookie; ability to stall background tasks

The fix

The file descriptor should be invalidated immediately when the first writing task is posted, or the code should track whether a task is already in flight.

How it was found

  1. Start a print or save-as-PDF action so the manager stores a valid file descriptor and a document cookie.
  2. From a compromised renderer, obtain the active document cookie and pipeline multiple print-document calls.
  3. Two background tasks are queued, each holding the same raw descriptor value.
  4. The first task writes and completes; the UI thread resets the stored descriptor and the print framework closes the underlying descriptor.
  5. Stall the second task and perform browser-side operations to make the kernel reuse the freed descriptor slot for a sensitive resource.
  6. The second task runs and writes attacker-controlled bytes into the reassigned descriptor.

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 file descriptor is a small number the operating system uses to refer to an open file or connection. The browser code saved this number and used it later in a background job without checking whether the file had already been closed and the number reused for something else. If an attacker can make the browser do this twice, the second write can land in a different, sensitive resource instead of the intended PDF file.

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.