← All reports

Validate frame in DidSameDocumentNavigationForFrame IPC handlers

Site isolation checked who owned the frame, but never whose page it was

Component: WebKit Site Isolation | 914969c

LayoutTests/http/tests/site-isolation/did-same-document-navigation-validation.html

+ const popup = window.open("resources/frame-of-another-page-popup.html");
+ t.add_cleanup(() => popup.close());
+ await waitForMessage(popup, (data) => data == "opened window loaded");
+ const message = await captureSameDocumentNavigation();
+ assert_greater_than(replaceFrameID(message.body, IPC.frameID[0], popup.IPC.frameID[0]), 0);
+ takeInvalidMessageString();
+ IPC.sendMessage("UI", message.destinationID, message.name, message.body);
+ assert_true(takeInvalidMessageString().includes("frame->page() == this"));

LayoutTests/http/tests/site-isolation/did-same-document-navigation-validation-expected.txt

+PASS didSameDocumentNavigationForFrame rejects a frame of another page (disallowed)
+PASS didSameDocumentNavigationForFrameViaJS rejects a frame of another page (disallowed)

The UI process keeps a WebPageProxy per page and a WebFrameProxy per frame, and treats FrameIdentifiers arriving from WebContent as untrusted, validating them with MESSAGE_CHECK. Under site isolation, handlers check that the sender is the process that owns the named frame, but a process can host frames from several pages (for example, a popup opened by a cross-site iframe), so frame ownership and page membership are separate invariants. This commit adds MESSAGE_CHECK(frame->page() == this) to didSameDocumentNavigationForFrame and didSameDocumentNavigationForFrameViaJS, ahead of the sender comparison and any state change.

 Embedder page (process A) └─ cross-site iframe ─► process B ─► opens popup (B)
 B sends DidSameDocumentNavigationForFrame(frame = popup main frame) to embedder's page
 Before: sender == frame's process (B == B) ─► OK ─► embedder URL updated
 After:  MESSAGE_CHECK(frame->page() == this) ─► FAIL ─► sender terminated

A compromised WebContent process could previously change the URL reported for a page it does not own, the cross-page confusion site isolation exists to prevent.

This is a confused-deputy pattern in a site-isolation validator: proving that the sender owns the frame says nothing about whether the frame belongs to the receiving page. Audit other WebPageProxy handlers that take a FrameIdentifier (didCommitLoad, didFinishLoad, didFailLoad, the policy and navigation callbacks) and handlers keyed by PageIdentifier or WebFrameProxy lookups. Flag any that check only the sender's process, or only that the frame exists. Consider process reuse across pages (shared pools, same-site popups, openers), state changes made before validation, and lookups that return a detached frame or one moved between pages. URL spoofing was the impact here, and the same missing check elsewhere could reach further.