Closed Bug 2032331 Opened 7 months ago Closed 7 months ago

RecvSetContainerFeaturePolicy: no embedder-process check allows Permissions Policy bypass for cross-origin iframes

Categories

(Core :: DOM: Security, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2025192

People

(Reporter: pakhunov.anton.n, Unassigned)

Details

(Keywords: ai-involved, reporter-external)

While auditing ContentParent IPC handlers I noticed RecvSetContainerFeaturePolicy (dom/ipc/ContentParent.cpp) doesn't check that the calling process is actually the one embedding the target BrowsingContext:

mozilla::ipc::IPCResult ContentParent::RecvSetContainerFeaturePolicy(
    const MaybeDiscardedBrowsingContext& aContainerContext,
    MaybeFeaturePolicyInfo&& aContainerFeaturePolicyInfo) {
  if (aContainerContext.IsNullOrDiscarded()) {
    return IPC_OK();
  }
  auto* context = aContainerContext.get_canonical();
  context->SetContainerFeaturePolicy(std::move(aContainerFeaturePolicyInfo));
  return IPC_OK();
}

No ownership check — a compromised content process can pass any BrowsingContext ID (not just iframes it embeds) along with a crafted FeaturePolicyInfo.

How it gets used

When an out-of-process iframe navigates, DocumentLoadListener::Open reads the container feature policy off the BrowsingContext and puts it in LoadInfo (netwerk/ipc/DocumentLoadListener.cpp:718-719). Then Document::InitFeaturePolicy calls InheritPolicy(featurePolicyContainer) which reconstructs a full FeaturePolicy from the attacker-supplied FeaturePolicyInfo:

  • mInheritedDeniedFeatureNames — if empty, nothing is denied
  • mAttributeEnabledFeatureNames — features enabled via allow=; MaybeSetAllowedPolicy is called for each, adding them with AllowsAll()
  • mDeclaredString — the raw policy string, parsed by SetDeclaredPolicy

So an attacker that has already compromised one content process can inject a FeaturePolicyInfo with e.g. mAttributeEnabledFeatureNames = ["camera", "microphone", "geolocation", "payment"] for any cross-origin iframe's BrowsingContext. The next time that iframe navigates, it inherits the attacker-controlled policy — bypassing whatever allow="" or allow="..." restrictions the legitimate embedder set.

This only applies to OOP (Fission) iframes: for in-process iframes, GetEmbedderElementFrom returns the live element and the IPC-supplied policy is ignored. The path through loadInfo->GetContainerFeaturePolicyInfo() is taken precisely when the embedder is in a different process (cross-origin Fission iframe).

Fix

Add an embedder-process check before applying the policy:

auto* context = aContainerContext.get_canonical();
if (!context->IsEmbeddedInProcess(ChildID())) {
  return IPC_FAIL(this, "SetContainerFeaturePolicy from non-embedder process");
}
context->SetContainerFeaturePolicy(std::move(aContainerFeaturePolicyInfo));

The same pattern should be applied to RecvSetReferrerPolicyForEmbedderFrame (immediately below, same missing check).

Status: UNCONFIRMED → RESOLVED
Closed: 7 months ago
Duplicate of bug: 2025192
Resolution: --- → DUPLICATE
Group: core-security → dom-core-security
Group: dom-core-security
You need to log in before you can comment on or make changes to this bug.