← 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)

UI process는 page마다 WebPageProxy를, frame마다 WebFrameProxy를 하나씩 유지합니다. 이때 WebContent에서 넘어오는 FrameIdentifier는 신뢰할 수 없는 값으로 취급되며, MESSAGE_CHECK로 검증을 거칩니다. Site isolation 환경에서 handler는 sender가 해당 frame을 소유한 process인지 확인합니다. 문제는 하나의 process가 여러 page의 frame을 동시에 호스팅할 수 있다는 점입니다. 예를 들어 cross-site iframe이 연 popup이 여기에 해당합니다. 즉, frame 소유 관계와 page 소속 관계는 서로 별개의 invariant입니다. 이번 commit에서는 didSameDocumentNavigationForFrame과 didSameDocumentNavigationForFrameViaJS에 MESSAGE_CHECK(frame->page() == this)가 추가되었습니다. 해당 검사는 sender 비교와 모든 상태 변경보다 먼저 수행됩니다.

 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

패치 이전에는 compromised WebContent process가 자신이 소유하지 않은 page의 URL을 변경할 수 있었습니다. Site isolation이 막으려는 cross-page confusion에 정확히 해당합니다.

Site isolation validator에서 나타난 confused-deputy 패턴입니다. Sender가 frame을 소유한다는 사실만으로는, 그 frame이 수신 측 page에 속하는지 보장되지 않습니다. 먼저 FrameIdentifier를 받는 다른 WebPageProxy handler를 점검할 필요가 있습니다. didCommitLoad, didFinishLoad, didFailLoad, 그리고 policy 및 navigation callback이 대상입니다. PageIdentifier나 WebFrameProxy 조회를 기준으로 동작하는 handler도 함께 살펴봐야 합니다. Sender의 process만 확인하거나 frame의 존재 여부만 확인하는 handler가 있다면 표시해 두십시오. 아울러 여러 page 간의 process 재사용도 고려해야 합니다. Shared pool, same-site popup, opener가 대표적인 경우입니다. 검증 이전에 수행되는 상태 변경, 그리고 detached frame이나 page 간에 이동한 frame을 반환하는 조회도 확인 대상입니다. 이번 사례의 영향은 URL spoofing에 그쳤습니다. 다만 같은 검사가 다른 곳에서 누락되었다면, 더 큰 영향으로 이어질 가능성이 있습니다.