Race condition in ServiceWorker (CVE-2026-113311)
A race condition in ServiceWorker registration allows a Fenced Frame to be destroyed during registration, causing the browser to misclassify the worker as a normal frame and bypass process isolation and API restrictions. An attacker could then run a Service Worker in a non-isolated process and access restricted APIs like Push Messaging.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 7 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 without the security team.
Overview: A race condition exists if a Fenced Frame is destroyed while processing a Service Worker registration IPC. The browser process fails to look up the detached frame, securely defaults to classifying the worker as a non-fenced kNormalFrame, and permanently bypasses Fenced Frame process isolation and restricted API checks.
Affected files:
content/browser/service_worker/service_worker_context_core.cccontent/browser/service_worker/service_worker_process_manager.cc
Estimated timestamp from git blame: 2022-06-12
Summary
A potential race condition in ServiceWorkerContextCore::RegisterServiceWorker allows a compromised renderer or an attacker-controlled Fenced Frame to register a Service Worker that is incorrectly classified as a normal (non-fenced) worker. By destroying the Fenced Frame via the top-level document immediately after calling navigator.serviceWorker.register(), an attacker can cause a browser-side frame lookup to fail. The browser then insecurely defaults to an unrestricted state (kNormalFrame), completely bypassing Fenced Frame Site Isolation and API restrictions.
Technical Details
When a Service Worker registration request is sent from a renderer, it is processed via the ServiceWorkerContainerHost Mojo interface. The registration reaches ServiceWorkerContextCore::RegisterServiceWorker, which attempts to securely classify the requester using its GlobalRenderFrameHostId:
// content/browser/service_worker/service_worker_context_core.cc
void ServiceWorkerContextCore::RegisterServiceWorker(
...,
const GlobalRenderFrameHostId& requesting_frame_id,
...) {
// ...
auto* render_frame_host = RenderFrameHostImpl::FromID(requesting_frame_id);
const blink::mojom::AncestorFrameType ancestor_frame_type =
render_frame_host && render_frame_host->IsNestedWithinFencedFrame()
? blink::mojom::AncestorFrameType::kFencedFrame
: blink::mojom::AncestorFrameType::kNormalFrame;
// ...
}
The Service Worker Register IPC and the FrameHost::Detach IPC (sent when a frame is removed) travel over different Mojo pipes. If an attacker times the removal of a Fenced Frame perfectly, the frame is destroyed just before the Register IPC is processed.
Because the receiver's lifetime is tied to the Mojo pipe and not synchronously to the RenderFrameHostImpl destructor, the Register IPC is still processed. However, RenderFrameHostImpl::FromID(requesting_frame_id) returns nullptr. The ternary operator then silently falls back to blink::mojom::AncestorFrameType::kNormalFrame.
This incorrect, elevated status is permanently saved into the Service Worker registration database. When the worker is subsequently started, ServiceWorkerProcessManager::AllocateWorkerProcess reads this status:
// content/browser/service_worker/service_worker_process_manager.cc
const bool is_fenced =
ancestor_frame_type == blink::mojom::AncestorFrameType::kFencedFrame &&
SiteIsolationPolicy::IsProcessIsolationForFencedFramesEnabled();
Because ancestor_frame_type is kNormalFrame, is_fenced evaluates to false. The Service Worker is allocated in a standard renderer process, bypassing Fenced Frame process isolation. Furthermore, API restrictions (like the Push API in PushMessagingManager::Subscribe) rely on this status and will incorrectly permit restricted operations, allowing exfiltration of partitioned data.
Suggested Reproduction Steps
Note: These are potential steps as we currently lack an active testing environment to run a Proof of Concept.
- Host a page that embeds a cross-site Fenced Frame.
- Inside the Fenced Frame, execute
navigator.serviceWorker.register('/sw.js'). - Immediately after the call, have the top-level parent page remove the Fenced Frame from the DOM (
fenced_frame.remove()). - If the race condition is won (the Detach IPC beats the Register IPC processing), the Service Worker is saved as a
kNormalFrameworker. - Verify that the resulting Service Worker starts in a non-isolated process and can successfully subscribe to the Push API or use Background Sync.
Proposed Fix
Do not default to kNormalFrame upon a frame lookup failure. If the registration originates from a window client and render_frame_host is nullptr (due to the frame being destroyed or detached mid-flight), the registration request should either be aborted, or the ancestor_frame_type should be reliably cached earlier in the ServiceWorkerClient's lifetime (e.g., during CommitResponse) and passed explicitly to RegisterServiceWorker.
Evaluated with Chrome root at commit: 09ec9e7cc4d24823d20b6d37cf3d282734f6bf0f
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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
Likely the code defaults to a normal frame type when the requesting frame cannot be found, instead of aborting or using a cached type.
Impact
A Service Worker could run in a non-isolated process and access restricted APIs, potentially allowing exfiltration of partitioned data.
What the attacker needed
Attacker-controlled Fenced Frame; ability to remove frame at precise timing
The fix
The registration should be aborted or the ancestor frame type should be cached earlier and passed explicitly, rather than defaulting to kNormalFrame.
How it was found
- Host a page that embeds a cross-site Fenced Frame.
- Inside the Fenced Frame, execute navigator.serviceWorker.register('/sw.js').
- Immediately after the call, have the top-level parent page remove the Fenced Frame from the DOM.
- If the race condition is won, the Service Worker is saved as a kNormalFrame worker.
- Verify that the resulting Service Worker starts in a non-isolated process and can successfully subscribe to the Push API or use Background Sync.
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 Fenced Frame is a special web page container that is supposed to be isolated from the rest of the site for privacy. This report shows that if the container is removed at just the right moment while a background worker is being registered, the browser forgets it was a Fenced Frame and treats the worker as normal, breaking that isolation.
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.