← All reports

Site Isolation: validate target frame before redispatching iOS selection gestures

Component: WebKit UIProcess | 3ddf01b

Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

+ std::optional<WebCore::FrameIdentifier> sourceFrameID = frameID;
+ if (!sourceFrameID && m_mainFrame)
+ sourceFrameID = m_mainFrame->frameID();
...
- if (protectedThis && remoteUserInputEventData) {
+ if (RefPtr targetFrame = protectedThis && sourceFrameID && remoteUserInputEventData ? protectedThis->frameForRemoteUserInputEventRedispatch(connection, *sourceFrameID, remoteUserInputEventData->targetFrameID) : nullptr) {
...
- protectedThis->selectPositionAtPoint(remoteUserInputEventData->targetFrameID, ...);
+ protectedThis->selectPositionAtPoint(targetFrame->frameID(), ...);

Source/WebKit/UIProcess/WebPageProxy.h

+template<typename Message> using ReplyWithConnection = typename ReplyWithConnectionType<typename Message::Reply>::Type;

With Site Isolation, each cross-origin frame can live in a different WebContent process, and the UI process routes frame-targeted IPC to the owning process. For iOS selection gestures, the receiving process may find that the hit test landed on a cross-origin subframe it does not host. It then replies with RemoteUserInputEventData, a target frame ID plus a transformed point, and the UI process re-dispatches the request to that frame's process.

The reply handlers of selectWithGesture, selectPositionAtPoint, selectTextWithGranularityAtPoint, selectPositionAtBoundaryWithDirection, prepareSelectionForContextMenuWithLocationInView and selectWithTwoTouches now call the existing frameForRemoteUserInputEventRedispatch(connection, sourceFrameID, targetFrameID) before redispatching. Here sourceFrameID is the requested frame, or the main frame if none was given. The handlers switched to a new ReplyWithConnection<> reply type so the reply's originating IPC::Connection is available. On rejection, most handlers run the callback with the replying process's own result; the context-menu handler calls callbackFunction(false, RevealItem()). New tests forge replies that name the source frame itself.

A compromised WebContent process could forge a reply naming any FrameIdentifier and make the UI process send selection IPC to whichever process hosts it. Naming the source frame would make the UI process re-send the same request to the same process forever, which is the case the new tests mainly exercise. This closes a confused-deputy gap on the UI-process trust boundary.

The pattern to hunt is a WebContent reply carrying a FrameIdentifier or other routing key that the UI process uses to send further IPC. Because this fix is applied per call site, any consumer of RemoteUserInputEventData or targetFrameID that was not converted is a candidate. Frame-targeted async-reply paths still on the older INSTANTIATE_SEND_WITH_ASYNC_REPLY_TO_PROCESS_CONTAINING_FRAME macro, such as PerformDictionaryLookupAtLocation, CommitPotentialTap and RequestDragStart, are the first place to check whether a reply-carried frame ID or redispatch target is used unchecked.

Read the body of frameForRemoteUserInputEventRedispatch to see what relationship it enforces between the reply connection, sourceFrameID and targetFrameID, and whether the main-frame fallback for a missing frameID is too permissive. The redispatch re-enters the same handler with targetFrame->frameID(), so check whether a chain of hops can still loop when each hop individually passes validation. Also verify that the captured WeakPtr and callback survive the async hop and that the callback runs exactly once on every rejection path. The forged-reply tests (countRequestsAndForgeRedispatch) make a ready harness for fuzzing other reply-carried identifiers.