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

Use after free in ServiceWorker (CVE-2026-78951)

A use-after-free exists in the browser process when handling Service Worker script updates because a synchronous callback can destroy the update checker object while a method is still running. An attacker could potentially corrupt freed memory and achieve arbitrary code execution in the unsandboxed browser process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 months

Flapjack, 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 Use-After-Free vulnerability exists in the browser process when handling Service Worker script updates. If the connection to the storage process is disconnected, a synchronous callback chain can delete the ServiceWorkerSingleScriptUpdateChecker object while a method is still executing on the stack, leading to memory corruption when control unwinds.

Affected files:

  • content/browser/service_worker/service_worker_single_script_update_checker.cc

Estimated timestamp from git blame: 2022-01-25

Description

A potential Use-After-Free (UAF) vulnerability exists in content::ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse within the browser process. The issue stems from the fact that ServiceWorkerCacheWriter::MaybeWriteHeaders can invoke its completion callback synchronously if an immediate error occurs, such as the Mojo connection to the storage process being disconnected.

This synchronous error handling initiates a callback chain that ultimately destroys the ServiceWorkerSingleScriptUpdateChecker instance. When the call stack unwinds, execution continues in OnReceiveResponse using a dangling this pointer to write to member variables and invoke further methods.

Suggested Exploitation Steps

(Note: These are suggested steps based on code analysis; a working Proof of Concept has not been run.)

  1. An attacker registers a Service Worker on a controlled origin and triggers an update for it.
  2. The browser creates a ServiceWorkerUpdateChecker, which in turn creates a ServiceWorkerSingleScriptUpdateChecker and stores it in a std::unique_ptr.
  3. The update checker initiates a network request for the updated script.
  4. Before the network headers arrive, the attacker induces a condition that causes the Mojo pipe to the Storage process to disconnect (e.g., by exhausting resources to crash the storage process).
  5. When the network response headers arrive, ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse is called.
  6. OnReceiveResponse processes the headers and synchronously calls WriteHeaders(), passing a callback bound with a WeakPtr.
  7. WriteHeaders() calls ServiceWorkerCacheWriter::MaybeWriteHeaders().
  8. Because the storage pipe is disconnected, MaybeWriteHeaders() synchronously executes the callback with net::ERR_FAILED.
  9. The callback invokes ServiceWorkerSingleScriptUpdateChecker::OnWriteHeadersComplete(), which calls Fail(), and then Finish().
  10. Finish() synchronously executes its stored callback_, signaling failure back to ServiceWorkerUpdateChecker::OnOneUpdateCheckFinished().
  11. If this is the main script, the failure is propagated to ServiceWorkerRegisterJob::OnUpdateCheckFinished(), which synchronously aborts the job via Complete(), resulting in the destruction of the ServiceWorkerUpdateChecker and its std::unique_ptr<ServiceWorkerSingleScriptUpdateChecker>.
  12. The object is freed, and the stack unwinds back to OnReceiveResponse() immediately after the WriteHeaders() call.
  13. Execution continues using the dangling this pointer. The method performs several operations on the freed memory, including network_consumer_ = std::move(consumer); and modifying network_loader_state_. This corrupts the freed memory chunk with predictable/attacker-controlled values.
  14. Finally, it calls MaybeStartNetworkConsumerHandleWatcher(), which interacts with the corrupted network_watcher_ member, potentially leading to arbitrary code execution in the unsandboxed browser process.

Impact

This is a critical vulnerability because it occurs in the unsandboxed browser process. Successful exploitation of this memory corruption could lead to arbitrary Remote Code Execution (RCE) and a full sandbox escape. Note that MiraclePtr (BackupRefPtr) does not protect against this specific UAF because the dangling pointer is the implicit this pointer stored on the stack, not a heap-to-heap pointer.

Suggested Fix

There are a few ways to mitigate this:

  1. Asynchronous Callbacks: Ensure that ServiceWorkerCacheWriter::MaybeWriteHeaders (and similar methods) always invoke their completion callbacks asynchronously, even for immediate errors. This prevents synchronous destruction while methods are still on the stack.
  2. WeakPtr Checks: If synchronous callbacks are permitted, ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse must check if this is still valid after calling WriteHeaders(). This can be achieved by creating a WeakPtr to this before the call and checking it immediately after the call returns. If the WeakPtr has been invalidated, the method should return immediately.

Evaluated with Chrome root at commit: 2155cb00003ec35716a76ed3246eae995f87b7ff


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 completion callback from MaybeWriteHeaders can run synchronously on error, destroying the ServiceWorkerSingleScriptUpdateChecker object while OnReceiveResponse is still executing on the stack.

Impact

This could lead to arbitrary code execution in the unsandboxed browser process and a full sandbox escape, though no working proof of concept has been run.

What the attacker needed

Attacker controls a Service Worker origin; ability to disconnect storage process

The fix

The fix should make MaybeWriteHeaders always invoke callbacks asynchronously, or add a WeakPtr check after WriteHeaders returns to detect if the object was destroyed.

How it was found

  1. An attacker registers a Service Worker on a controlled origin and triggers an update.
  2. The browser creates a ServiceWorkerUpdateChecker and a ServiceWorkerSingleScriptUpdateChecker.
  3. The update checker starts a network request for the updated script.
  4. The attacker causes the Mojo pipe to the Storage process to disconnect before headers arrive.
  5. When headers arrive, OnReceiveResponse calls WriteHeaders, which synchronously fails and triggers a callback chain that frees the checker object.
  6. Execution returns to OnReceiveResponse, which continues using the dangling this pointer and corrupts freed memory.

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 an object from memory but then keeps using it, like deleting a file and then trying to read it. Here, a callback runs immediately and deletes an object while a function is still using it, so the function writes to memory that no longer belongs to it. This can let an attacker control what gets written and potentially 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.

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.