Use after free in ServiceWorker (CVE-2026-11694)
A use-after-free flaw exists in the Service Worker global scope when duplicate race network request tokens are processed, leaving a dangling pointer in a secondary map. An attacker with a compromised renderer could trigger the bug to cause memory corruption and potentially remote code execution in the sandboxed renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 11 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 Service Worker global scope due to a key-collision ownership discrepancy. When duplicate tokens are processed in a race network request, a secondary lookup map retains a raw pointer to a temporary object that has been deallocated. Subsequent event resolution dereferences this dangling pointer, leading to potential memory corruption and remote code execution in the sandboxed renderer process.
Affected files:
third_party/blink/renderer/modules/service_worker/service_worker_global_scope.ccthird_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
Estimated timestamp from git blame: 2023-10-24
Description
There is a potential Use-After-Free (UAF) vulnerability in the Service Worker thread of the Blink renderer process. The bug stems from how duplicate network tokens are handled within ServiceWorkerGlobalScope::InsertNewItemToRaceNetworkRequests.
When inserting a new race network request, a raw pointer to a heap-allocated RaceNetworkRequestInfo structure is added to the secondary lookup map race_network_request_fetch_event_ids_ before ownership of the managing std::unique_ptr is transferred to the primary race_network_requests_ map. If a key collision occurs (due to duplicate tokens), WTF::HashMap::insert does not consume or move the std::unique_ptr. When the function scope exits, the std::unique_ptr is destroyed, freeing the underlying RaceNetworkRequestInfo allocation. However, the secondary map still retains the dangling raw pointer.
Upon completion or abortion of the associated event, RemoveItemFromRaceNetworkRequests retrieves this dangling raw pointer and dereferences its member fields, leading to memory corruption.
Code References
In third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc:
void ServiceWorkerGlobalScope::InsertNewItemToRaceNetworkRequests(
int fetch_event_id,
const base::UnguessableToken& token, ...)
{
auto race_network_request_token = String(token.ToString());
auto info = std::make_unique<RaceNetworkRequestInfo>(
fetch_event_id, race_network_request_token,
std::move(url_loader_factory));
race_network_request_fetch_event_ids_.insert(fetch_event_id, info.get()); // [1] Stores raw pointer to info
auto insert_result = race_network_requests_.insert(
race_network_request_token, std::move(info)); // [2] insert fails if duplicate token
...
} // [3] info dtor is invoked and deletes the object if not moved in [2]
And inside the cleanup path:
void ServiceWorkerGlobalScope::RemoveItemFromRaceNetworkRequests(int fetch_event_id) {
RaceNetworkRequestInfo* info =
race_network_request_fetch_event_ids_.Take(fetch_event_id); // [4] Returns the dangling raw pointer
if (info) {
race_network_requests_.erase(info->token); // [5] Use-After-Free on info->token
}
}
Potential Trigger Steps
(Note: These are potential steps modeled via code tracing, as our tooling does not currently run exploit code.)
- A compromised renderer process holds a direct
blink::mojom::ControllerServiceWorkerMojo remote. - The attacker triggers two
DispatchFetchEventForSubresourcecalls with differentfetch_event_ids but using the exact same non-zeroservice_worker_race_network_request_tokeninparams->request. - The first call populates the maps normally.
- The second call hits the key collision inside
InsertNewItemToRaceNetworkRequests. The secondRaceNetworkRequestInfois deleted at the end of the method, leaving a dangling pointer inrace_network_request_fetch_event_ids_under the second event's ID. - The attacker sprays the PartitionAlloc heap to reclaim the freed size bucket with controlled data.
- The attacker completes or aborts the second fetch event, triggering
RemoveItemFromRaceNetworkRequestsand invoking the UAF.
Proposed Fix
To resolve this issue, only add the entry to the secondary lookup map race_network_request_fetch_event_ids_ after a successful insertion into the primary map has occurred:
void ServiceWorkerGlobalScope::InsertNewItemToRaceNetworkRequests(
int fetch_event_id,
const base::UnguessableToken& token,
mojo::PendingRemote<network::mojom::blink::URLLoaderFactory>
url_loader_factory,
const KURL& request_url) {
auto race_network_request_token = String(token.ToString());
auto info = std::make_unique<RaceNetworkRequestInfo>(
fetch_event_id, race_network_request_token,
std::move(url_loader_factory));
auto insert_result = race_network_requests_.insert(race_network_request_token,
std::move(info));
if (insert_result.is_new_entry) {
race_network_request_fetch_event_ids_.insert(
fetch_event_id, insert_result.stored_value->value.get());
}
...
Evaluated with Chrome root at commit: 5133b93d189b383c37805b1cf3a9d2dbfe8d7379
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
The secondary map is populated with a raw pointer before the primary map's insert succeeds, so a duplicate-key failure leaves a dangling pointer after the unique_ptr is destroyed.
Impact
An attacker with a compromised renderer could cause memory corruption and potentially achieve remote code execution within the sandboxed renderer process.
What the attacker needed
Compromised renderer process; direct Mojo remote to controller service worker; ability to send crafted fetch events
The fix
The fix should insert into the secondary map only after the primary map insert succeeds, so no dangling pointer is stored on a duplicate key.
How it was found
- A compromised renderer process holds a direct Mojo remote to the controller service worker.
- The attacker triggers two DispatchFetchEventForSubresource calls with different fetch event IDs but the same non-zero race network request token.
- The first call populates the maps normally.
- The second call hits a key collision, the second RaceNetworkRequestInfo is deleted, and a dangling pointer remains under the second event's ID.
- The attacker sprays the PartitionAlloc heap to reclaim the freed size bucket with controlled data.
- The attacker completes or aborts the second fetch event, triggering RemoveItemFromRaceNetworkRequests and the use-after-free.
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 memory safety bug where a program keeps using a pointer to memory that has already been freed. Here, when two network requests share the same token, the code frees an object but leaves a pointer to it in a lookup table, so later cleanup reads freed memory. This can crash the browser or let an attacker who already controls one part of the browser run code in another sandboxed part.
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.