← All reports

[Site Isolation] UIProcess validation of the frame a context-menu request names

Component: WebKit UIProcess IPC | bacf018

Source/WebKit/UIProcess/ValidationProcedures.h

+ std::optional<IPC::ValidationFailure> checkUntrusted(const WebCore::FrameIdentifier& frameID) const
+ {
+ if (!m_sender || !m_page)
+ return IPC::ValidationFailure::Ignore;
+ RefPtr frame { WebFrameProxy::webFrame(frameID) };
+ if (!frame || !frame->page())
+ return IPC::ValidationFailure::Ignore;
+ if (frame->page() != m_page.get())
+ return IPC::ValidationFailure::Terminate;
+ // The frame's previous process can still send messages for it until it receives LoadDidCommitInAnotherProcess.
+ if (&frame->process() != m_sender.get())
+ return IPC::ValidationFailure::Ignore;
+ return std::nullopt;
+ }

Source/WebKit/UIProcess/WebPageProxy.cpp

+ bool WebPageProxy::contextMenuReplyReachesAskingProcess(FrameIdentifier frameID)
+ {
+ return processContainingFrame(frameID).ptr() == internals().activeContextMenuProcess.get();
+ }

With site isolation, one page's frame tree is spread across several WebContent processes, and the UI process (WebPageProxy / WebFrameProxy) is the authority on which process hosts which frame. Many WebPageProxy handlers accept a frame identifier from the sender without checking that the sender hosts it, and the UI process resolves frame-to-process again when replying — so a frame that navigates cross-process while a context menu is open can route the dismissal and the chosen item to the new process. The IPC validation framework (IPC::Untrusted, ValidationProcedures.h) distinguishes Terminate (kill the sender, for provably malicious input) from Ignore (drop the message, for benign races).

WebPageProxy::showContextMenuFromFrame() now validates the frame named in FrameInfoData with a new ProcessHostsFrameInPage procedure: a frame in another page terminates the sender; a missing frame or a frame hosted by another process is ignored. The UI process records the asking process in activeContextMenuProcess, and contextMenuReplyReachesAskingProcess() drops the dismissal and item if the frame has since moved. Items that only change a setting or show a panel are handled earlier by the new handleContextMenuSettingOrPanelAction().

  WebContent A ── showContextMenuFromFrame(frameInfo{F}) ──► UIProcess
                    ProcessHostsFrameInPage{A, page}.checkUntrusted(F)
                      ├─ F missing / no page ......... Ignore
                      ├─ F.page != this page ......... Terminate
                      ├─ F.process != A .............. Ignore
                      └─ ok ─► activeContextMenuProcess = A
                    user picks item
                      ├─ setting/panel ─► handled locally
                      └─ other ─► reply reaches A? forward : drop

Under site isolation any WebContent process in a browsing context group can send WebPageProxy messages for any page in the group, so a compromised renderer could have made the UI process route a dismissal and the user's chosen item (Start Speaking, Paste) to the wrong process. This adds the first sender/page ownership check for this handler, which previously only checked that the frame existed (and since 322203@main not even that). It also provides a reusable validator for other handlers.

Narrow, within this change: verify every item in handleContextMenuSettingOrPanelAction() is truly frame-independent and touches no frame, document or hit-test result; probe the gap between initial validation and the reply-time recheck, including a stale or null activeContextMenuProcess (a WeakPtr) across menu lifetimes and nested runloops; and examine the documented exception where a suspended page keeps the old main frame alive, so the check passes and the reply goes to a process where the frame doesn't exist. FrameInfoData fields other than frameID, and menu position and contents, are still used as sent, so a compromised process can still present spoofed menus over frames it does host; the paste path repeats the check after pasteboard access is granted. Wider: sweep other WebPageProxy handlers that take a FrameIdentifier or FrameInfoData from the sender without ProcessHostsFrameInPage or an equivalent check, and ask for each whether the Ignore-vs-Terminate split could hide probing or races. Tell: a handler that resolves a sender-supplied frame ID with WebFrameProxy::webFrame and never compares frame->process() to the connection's process.