Site isolation frame validation in DidDestroyFrame, FrameNameChanged and SetFramePrinting
Under site isolation, an iframe could tear down a sibling it never owned
Component: WebKit Site Isolation | bd2c66d
LayoutTests/http/tests/site-isolation/did-destroy-frame-validation.html
Site isolation 환경에서는 UI process가 기준이 되는 frame tree(WebFrameProxy)를 관리합니다. 이 tree를 바탕으로 WebContent process 사이에서 frame lifecycle 변화를 중계하게 됩니다. 문제는 frame 단위 IPC 메시지에 담기는 FrameIdentifier를 sender가 직접 지정한다는 점입니다. 따라서 UI process가 두 가지를 확인해야 합니다. 먼저 해당 frame이 메시지를 받은 WebPageProxy에 속하는지, 그리고 sender가 그 frame을 정당하게 소유하거나 parent로 두고 있는지입니다. 이 검증이 없으면 compromised renderer가 자신이 제어하지 않는 frame에 대해서도 동작을 수행할 수 있습니다.
이번 commit으로 WebPageProxy::didDestroyFrame, frameNameChanged, setFramePrinting에 검증이 추가되었습니다. frame이 다른 page에 속하면 MESSAGE_CHECK 실패로 처리되고, 메시지를 보낼 권한이 없는 process의 요청은 별도 알림 없이 무시됩니다. 다만 허용되는 sender 집합은 메시지마다 다릅니다. cross-site navigation 중 parent의 provisional process가 보내는 메시지나, main frame이 다른 곳에서 commit된 뒤 이전 process가 보내는 child 제거 통보처럼 정상적인 흐름이 존재하기 때문입니다. 그 결과 규칙이 다음과 같이 세분화되었습니다.
Message Frame's proc Parent's proc Parent's provisional Any proc
DidDestroyFrame yes yes yes only if no parent
FrameNameChanged yes no no no
SetFramePrinting yes yes no no
frame->page() != this page => MESSAGE_CHECK failure (kills sender)
sender not in allowed set => ignored
unknown frame => early return (didDestroyFrame still broadcasts removal)
Significance
패치 이전에는 compromised iframe process가 sibling iframe을 제거하거나, main frame의 이름을 바꾸거나 print를 유발하거나, 다른 page에 속한 frame의 이름을 지정할 수 있었습니다. Site isolation은 UI process를 trust boundary로 삼아 동작합니다. 그런데 해당 handler들은 sender가 지정한 ID를 그대로 신뢰하고 있었습니다.
Audit directions
이번 사례는 더 넓은 버그 유형의 구체적인 한 예에 해당합니다. WebContent process가 전달한 FrameIdentifier나 PageIdentifier를 UI process handler가 그대로 신뢰하는 유형입니다. Narrow: 다른 frame 상태 메시지를 처리하는 WebPageProxy의 인접 handler들을 살펴볼 필요가 있습니다. page 소유 관계나 sender 신원을 확인하지 않고 frame을 조회하는 경우가 점검 대상입니다. Wider: 다른 handler에서도 비슷한 버그는 예외 규칙 쪽에 숨어 있을 가능성이 높습니다. "parent가 없는 subframe에 대한 임의 process 허용"과 "parent의 provisional process 허용"이 대표적입니다. compromised process가 frame detach나 cross-site navigation과 race를 일으켜 이런 상태에 도달할 가능성이 존재합니다. 한편 didDestroyFrame처럼 검증을 건너뛰면서도 broadcast는 수행하는 unknown-frame 경로도 확인할 필요가 있습니다. 위조된 ID로 다른 process가 아직 호스팅 중인 frame을 해체하게 만들 수 있는지가 점검 포인트입니다. Ordering: frameNameChanged처럼 동작의 정확성이 시점에 의존하는 handler도 대상입니다. UI process가 frame의 process를 교체하는 시점과 이전 process의 pagehide/unload 메시지 사이의 순서가 핵심입니다. Match tell: message handler 안에서 webFrameFromID(...)를 호출한 뒤, connection의 process나 frame->page()와 비교하는 코드가 없는 경우입니다.