← All reports

Site Isolation frame validation before redispatching drag and lookup requests

The UIProcess asked the renderer where to send input — and believed the answer

Component: WebKit Site Isolation | dd76abb

LayoutTests/http/tests/site-isolation/mouse-events/drag-controller-action-redispatch-to-source-frame-is-rejected.html

+ // std::optional<DragOperation>, DragHandlingMethod, bool, unsigned, IntRect 두 개, 그 다음 std::optional<RemoteUserInputEventData> 순서입니다.
+ const requestCount = forgeRedispatchToItself('WebPage_PerformDragControllerAction', [
+ { type: 'bool', value: 0 }, { type: 'uint8_t', value: 0 }, { type: 'bool', value: 0 }, { type: 'uint32_t', value: 0 },
+ ...
+ { type: 'bool', value: 1 }, ...remoteUserInputEventDataForThisFrame(),
+ ]);
+ ...
+ const invalidMessage = await waitForInvalidMessageString();
+ ...
+ else if (!invalidMessage.includes("Message check failed"))
+ finish("FAIL: the UI process accepted the redispatch. Invalid message: '" + invalidMessage + "'");

Site Isolation 환경에서는 cross-origin frame이 각각 별도의 WebContent process에서 실행되고, 입력 처리는 UIProcess가 중개합니다. macOS의 drag, immediate action(force-click/look-up), dictionary lookup의 경우 UIProcess는 먼저 하나의 process에 요청을 보냅니다. 이때 해당 process의 hit test 결과가 다른 process에 있는 frame에 닿으면, RemoteUserInputEventData로 그 frame을 지정해 응답하게 됩니다. 그러면 UIProcess는 해당 frame을 host하는 process로 요청을 다시 전송합니다. 문제는 web process가 compromise된 경우입니다. 이때 이 응답은 attacker가 제어하는 데이터에 해당합니다.

WebPageProxy::performDragControllerAction, dragEndedInFrame, performImmediateActionHitTestAtLocation, performDictionaryLookupAtLocationInFrame은 이제 응답을 그대로 따르지 않습니다. 응답한 connection 기준으로 frameForRemoteUserInputEventRedispatch()가 지정된 frame을 허용하는 경우에만 redispatch가 진행되도록 변경되었습니다. 허용되지 않으면 message check가 실패합니다. 아울러 IPC testing API로 redispatch를 위조하는 layout test와 TestWebKitAPI test가 새로 추가되었습니다.

WebContent A --reply(frameID = X)--> UIProcess
                                      +-> frameForRemoteUserInputEventRedispatch(X, connA)
                                            +- accepted --> re-send to process hosting X
                                            +- rejected --> message check fails

패치 이전에는 compromise된 WebContent process가 UIProcess를 유도해, 입력 기반 요청을 자신이 고른 frame으로 재전송하게 만들 가능성이 있었습니다. 결과적으로 frame 소유권에 대한 UIProcess의 판단 권한이 무력화될 여지가 있었습니다.

점검할 패턴은 분명합니다. frame이나 process identity를 담은 응답이 UIProcess의 재전송을 유발하는 경우입니다. 먼저 frameForRemoteUserInputEventRedispatch()를 거치지 않고 응답의 frame을 그대로 사용하는 다른 redispatch 지점을 찾아볼 필요가 있습니다. 다른 drag callback, text interaction 및 services/lookup 흐름, 그리고 macOS 외 플랫폼의 대응 코드가 후보입니다.

다음으로 이 검증이 실제로 무엇을 허용하는지 살펴봐야 합니다. frame을 응답한 connection과 원래 요청 양쪽에 모두 묶어 확인하는지 점검이 필요합니다. stale frame이나 reparent된 frame, navigation 도중이거나 process swap 중인 frame이 검증을 통과할 수 있는지도 확인해야 합니다.

한편 새 테스트는 source frame 자기 자신으로의 redispatch만 위조합니다. 따라서 다른 process에 있는 다른 frame으로의 redispatch는 별도의 테스트로 다룰 가치가 있습니다. sibling cross-origin iframe이 대표적인 예입니다. 요청과 응답의 대응 관계도 살펴볼 만합니다. 요청 없이 도착한 응답, replay된 응답, drag session이 끝난 뒤 도착한 응답이 주요 점검 대상입니다.