Site Isolation: validate target frame before redispatching mouse, wheel, gesture and modifier events
Component: WebKit UIProcess | 50215ee
Source/WebKit/UIProcess/WebPageProxy.cpp
앞서 다룬 iOS selection 수정과 짝을 이루는 input event 쪽 수정입니다. UI process는 frame을 호스팅하는 process로 input event를 전송합니다. 이때 hit test 결과가 다른 process에 호스팅된 subframe에 떨어지는 경우가 있습니다. 그러면 reply에 담긴 RemoteUserInputEventData가 event를 어디로 다시 보낼지 UI process에 알려줍니다. 문제는 이 target frame ID를 신뢰할 수 없는 renderer가 제공한다는 점입니다.
이번 패치로 WebPageProxy는 mouse, wheel, gesture, modifier flag hit test event를 재전송하기 전에 frameForRemoteUserInputEventRedispatch를 먼저 실행하도록 변경되었습니다. Target이 유효하지 않으면 mouse와 gesture 경로는 remote data를 버리고, wheel과 modifier flag 경로는 재전송 자체를 건너뜁니다. 한편 wheel 경로에 있던 siteIsolationEnabled 기반 MESSAGE_CHECK는 제거되었습니다.
Before: UIProcess ◄─reply{targetFrameID=X}── WebProcess A (untrusted)
UIProcess ──re-send to X (no validation)──► Process(X)
After: UIProcess: frameForRemoteUserInputEventRedispatch(connection, frameID, X)
├─ invalid ─► drop remote data / skip redispatch
└─ valid ─► re-send to X
Significance
Compromised WebContent process가 자신의 source frame을 포함해, 접근해서는 안 되는 frame으로 UI process의 input 재전송을 유도할 수 있었습니다. 이번 수정으로 mouse, wheel, gesture, modifier flag 재전송 경로에 남아 있던 IPC trust boundary의 공백이 메워졌습니다.
Audit directions
먼저 frameForRemoteUserInputEventRedispatch 자체를 점검할 필요가 있습니다. 해당 frame이 실제로 존재하는지, 이 page에 속하는지, source frame의 하위 frame인지 검사하는지 확인해야 합니다. 또한 reply를 보낸 connection과 다른 process에 호스팅되어 있는지도 검사하는지 살펴봐야 합니다. 각 검사를 우회할 수 있는지도 함께 따져볼 대상입니다. 그다음으로는 RemoteUserInputEventData나 renderer가 전달한 다른 frame ID를 사용하면서도 이번에 수정되지 않은 형제 경로를 찾아볼 만합니다. iOS touch event, drag and drop, context menu, keyboard/focus 처리 등이 후보에 해당합니다.
두 가지 동작 변화도 후속 점검이 필요합니다. 먼저 siteIsolationEnabled MESSAGE_CHECK가 사라졌습니다. 그 결과 Site Isolation이 꺼진 page가 remote data를 받는 경우, 검증은 전적으로 helper에 의존하게 됩니다. 다음으로 실패 시 동작이 경로마다 다릅니다. 한쪽은 data를 버린 뒤 이후 로직으로 계속 진행하고, 다른 쪽은 별도 처리 없이 반환합니다. 따라서 계속 진행하는 경로에서 parked mouse event, gesture queue, response timer의 상태 불일치가 발생하지 않는지 확인해야 합니다.