[4] Forged `IsPlayingMediaDidChange` activates the display-capture process capability without consent
The UI process granted a screen-capture capability on the renderer's word alone.
A logic bug, not memory corruption, and Medium because the attacker needs a compromised renderer first. Past that gate, the renderer could talk the UI process into granting an OS-level screen-capture capability without ever showing a prompt.
WebKit's UI process is the privileged broker in a multi-process browser: it owns permission prompts and treats everything the sandboxed web-content process reports as untrusted. On Cocoa platforms it can also grant OS-level process capabilities through a capability granter. A MediaCapability is the object representing one such grant, and one of them covers display (screen/window) capture. The expected rule is that the display-capture capability is activated only after the UI process itself has prompted for, or recorded approval of, a getDisplayMedia() request.
The angle: an attacker who already has renderer code execution could make the UI process activate the display-capture capability with no user prompt, and could keep it from being revoked.
From the commit message: internals().mediaState is stored verbatim from WebContent IPC, yet shouldActivateDisplayCaptureCapability() used it to drive a privileged action. A compromised WebContent process could set display-capture bits and have the UI process grant BEProcessCapability screenCapture back to itself and to the GPU process, with no getDisplayMedia() prompt. Both HasActiveScreenCaptureDevice and the IsPromptingFor*Capture bits reach the predicate, and both are forgeable. Activation is now gated on a UI-process authorization record instead. The commit deliberately does not use a MESSAGE_CHECK: an in-flight message still carrying display-capture bits after the UI process resets access or navigates would otherwise terminate a legitimate WebContent process.
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
LayoutTests/http/tests/ipc/display-capture-capability-forged-media-state.html
Patch Details
The change makes three moves. It introduces a UI-owned authorization record. It wires that record into both capability predicates. It adds test plumbing that forges the offending IPC message.
In WebPageProxy.h, two bools are added: m_isPromptingForDisplayCapture and m_hasGrantedDisplayCapture. They are set and cleared in WebPageProxy.cpp:
setIsPromptingForGetDisplayMedia()mirrors its argument into the prompting flag.- In
willStartCapture(), theDisplayMediacase clears the prompting flag and setsm_hasGrantedDisplayCapture = true. The case above it ends in[[fallthrough]], so at least one otherMediaStreamRequest::Typealso reaches this assignment. - Both flags are cleared on main-frame
didCommitLoadForFrame()and inresetState(). - The grant flag is also cleared in
stopMediaCapture()for theDisplayandEveryKindkinds. ASSERT(userMediaPermissionRequestManager)is removed fromupdatePlayingMediaDidChange(); the null check below it already handled that case.
In WebPageProxyCocoa.mm, hasDisplayCaptureAuthorization() ORs the two flags. shouldActivateDisplayCaptureCapability() returns false without authorization before it consults the mediaState bits. shouldDeactivateDisplayCaptureCapability() returns true (revoke) for an active or activating capability whenever authorization is absent.
The test plumbing comprises WebPageProxyTesting::isDisplayCaptureCapabilityActive(), the WKWebView/WebKitTestRunner bindings, an API test, and a layout test. The layout test sends a forged WebPageProxy_IsPlayingMediaDidChange carrying bit 29 (IsPromptingForScreenCapture) and asserts the capability stays inactive.
Privileged capability grant driven by state the less-privileged peer reports about itself, rather than by an authorization record the privileged side owns.
Background
Process model. WebKit splits a page across a sandboxed WebContent process (page script and layout), a GPU process (media and graphics work), and the privileged UI process. The UI process owns permission decisions and treats WebContent as untrusted when it receives IPC.
MediaProducerMediaStateFlags.
This bitfield summarizes a page's media activity: playing audio or video, an active or muted camera, microphone, screen or window capture, and whether a capture permission prompt is pending. WebContent reports it to the UI process via the IsPlayingMediaDidChange message, and WebPageProxy keeps an aggregate in internals().mediaState. DisplayCaptureMask and IsPromptingForDisplayCaptureMask are the subsets of these flags that relate to screen and window capture.
The getDisplayMedia() permission flow.
When a page calls getDisplayMedia(), the request reaches the UI process's user-media permission manager, which may show a system or app prompt; setIsPromptingForGetDisplayMedia tracks the prompt state. On approval, WebPageProxy::willStartCapture configures the page for the granted capture kind, switching on MediaStreamRequest::Type. stopMediaCapture and resetState tear capture state down, and didCommitLoadForFrame on the main frame marks a navigation boundary.
Process capabilities.
On platforms built with ENABLE(EXTENSION_CAPABILITIES), the UI process can grant OS-level process capabilities to helper processes through the process pool's extensionCapabilityGranter(). A MediaCapability represents one such grant and exposes states like isActivatingOrActive(). WebPageProxy decides when to activate or deactivate its displayCaptureCapability using the predicates shouldActivateDisplayCaptureCapability() and shouldDeactivateDisplayCaptureCapability().
MESSAGE_CHECK.
This WebKit IPC-validation macro treats the sending process as compromised and terminates it when its condition fails.
Analysis
This is a confused-deputy authorization bypass: the UI process granted a privilege based on the renderer's own description of itself.
WebContent (compromised) UI process
+------------------------+ IPC +---------------------------------------+
| IsPlayingMediaDidChange| --------> | internals().mediaState := bit 29 |
| (1 << 29) | | shouldActivateDisplayCaptureCapability|
+------------------------+ | isViewVisible() && bits present |
^ | -> true |
| capability granted | extensionCapabilityGranter()->grant( |
+-------------------------- | *displayCaptureCapability, *this) |
+---------------------------------------+
(no getDisplayMedia() prompt, no permission record, at any step)
Before the fix, the predicate on the right checked only view visibility and whether mediaState contained any display-capture or prompting bit. Nothing tied those bits to a permission decision the UI process had made. The commit message states that internals().mediaState is stored verbatim from WebContent IPC, and the regression test confirms that a single forged message carrying bit 29 reaches the predicate. Once the predicate went true, the activation path called grant(). Deactivation had the mirror flaw: shouldDeactivateDisplayCaptureCapability() returned false whenever the same forgeable bits were present, so a renderer could also keep an active capability alive.
The removed ASSERT is a secondary finding. It sat in updatePlayingMediaDidChange(), which forged capture bits make reachable from WebContent IPC, so a renderer could trip it in debug builds. Release builds were already safe because of the null check that followed. The regression test's single-message forgery through the IPC testing API suggests IPC-boundary pattern auditing, or IPC-focused fuzzing that sends arbitrary WebPageProxy messages and watches UI-side state.
The bug is reachable only from a compromised WebContent process, or from the IPC testing API in test builds. Ordinary script must go through getDisplayMedia() and its prompt. For an attacker who already has renderer code execution, the pre-fix code would activate the display-capture capability with no user consent. This is a post-compromise escalation step, not an entry point.
Two audit questions bound the real-world impact. The first is what the display-capture MediaCapability unlocks once grant() succeeds. Holding it might be enough for a compromised WebContent or GPU process to reach display-capture APIs directly, or capture might still be brokered by UI-process code that runs its own permission checks.
The second is the lifetime of m_hasGrantedDisplayCapture. It is set at the DisplayMedia case of willStartCapture(), which the preceding case also reaches via [[fallthrough]]. It is cleared only on main-frame commit, resetState(), and stopMediaCapture(Display|EveryKind). If a legitimate non-display or already-ended capture session left it set, for example a page-initiated track stop with no UI-side stopMediaCapture, forged mediaState bits could again steer activation during that window. The ceiling remains logic-level: activating the capability without a prompt and suppressing its revocation. The forged-IPC ASSERT was a debug-only crash, not a primitive.
Before the fix, the UI-process privilege boundary for display capture was weakened. The security model assumes the display-capture process capability is activated only after the UI process has prompted for, or recorded, a getDisplayMedia() grant. A renderer able to forge IPC broke that assumption with its own IsPlayingMediaDidChange report, and could also block revocation. Exploited after a renderer compromise, this would give the attacker an OS-level capability the UI process normally withholds until consent. Per the commit message, the grant reaches the WebContent and GPU processes; what remains open is whether holding the screenCapture capability lets those processes capture display contents directly, or whether capture is still brokered by UI-process code with its own permission checks.
Insight: The fix gates the privileged action at its point of use, keyed on UI-owned state, rather than adding a MESSAGE_CHECK on the incoming bits. Legitimate bits can arrive after the UI process has reset access or navigated, so validating the message would kill benign processes. Whenever renderer-reported state is inherently racy with UI-side state changes, gating the privilege is fail-safe, while validating the message is brittle. The fix is also symmetric across activation and deactivation, because forged state can serve either to acquire a grant or to keep one from being revoked. The authorization flag is somewhat coarse, though: the [[fallthrough]] means it records something broader than "the user approved getDisplayMedia()". More broadly, every WebPageProxy consumer that turns mediaState into a privilege, rather than a display affordance, is a candidate for the same bug.
Audit directions
- A privileged process converting an unprivileged peer's self-reported status into a grant. The invariant: any decision that widens privilege must be keyed on state the privileged side wrote itself.
- Narrow: grep
WebPageProxy*.cpp/.mmfor readers ofinternals().mediaStateandmainFrameMediaState. Classify each consumer as cosmetic (indicator, logging) or privileged (capability grant, sandbox extension, process assertion, audio-session or background-execution permission). A match is any privileged consumer whose only gate ismediaState.containsAny(...). - Wider: apply the same audit to other renderer-reported states in WebKit, such as audio-playback-driven process assertions,
ProcessThrottleractivity requests, and sandbox-extension issuance keyed on renderer claims. In code-search results, look for a UI-side branch that grants something while reading only fields decoded from an IPC message. - Widest: this is the confused-deputy class seen in Chromium's browser process trusting
RenderFrameHost-reported state, Android system services trusting app-supplied state flags, and Linux PolicyKit/D-Bus services trusting caller-reported attributes. In any multi-process design, ask whether each grant traces back to a write performed by the privileged party. - UI-owned authorization flags that are not scoped and timed to the session they authorize.
m_hasGrantedDisplayCaptureis set at theDisplayMediacase ofwillStartCapture(), also reached by the preceding case via[[fallthrough]]. It is cleared only on main-frame commit,resetState, andstopMediaCapture(Display|EveryKind). - Narrow: identify which
MediaStreamRequest::Typefalls through. Then trace whether page-initiated track stop, device ending, permission revocation from system settings, or process swap clears the flag. A match is any non-display grant that sets it, or any session-end path that leaves it set while forgedmediaStatebits could re-arm activation. - Wider: audit other UI-side grant records in
UserMediaPermissionRequestManagerProxy(granted-request caches,resetAccess) for the same pattern: a setter reached by more cases than intended, cleared by only a subset of teardowns. - Widest: this is the general stale or over-broad authorization class: session tokens not invalidated on logout, OAuth grants surviving scope changes, capability handles surviving context teardown. Enumerate every path that can set the grant and every way the authorized session can end, and verify each setter is intended and each end path clears it.
- Code-review tell: a boolean authorization flag set inside a
switchwith[[fallthrough]], or a flag with several clearers where at least one lifecycle-end path is missing. - IPC-reachable
ASSERTs in UIProcess message handlers. A debug assertion encodes an invariant the author believed could not be violated. If a renderer controls the asserted state, the assert marks a missing validation or gating point. - Narrow: grep
WebPageProxy.cpphandlers for messages likeIsPlayingMediaDidChangeforASSERT(on state derived from message arguments. - Wider: apply the same audit to
WebProcessProxy,NetworkProcessProxy, and GPU-processRemote*receivers. Each such assert is either aMESSAGE_CHECKcandidate or, as here, a sign that a downstream privileged decision trusts the same input. - This class is specific to WebKit's
ASSERT/MESSAGE_CHECKsplit for IPC validation; the audit ceiling is WebKit's IPC receiver layer. - Code-review tell: an
ASSERTimmediately followed by a defensive null or range check on IPC-derived state.