Closed Bug 2079927 Opened 1 month ago Closed 28 days ago

Cross-frame policy overwrite: `SetContainerPermissionsPolicy` / `SetReferrerPolicyForEmbedderFrame` accept any browsing context (embedder-ownership check exists nearby in `DiscardBrowsingContext`)

Categories

(Core :: DOM: Security, defect)

Firefox 160
defect

Tracking

()

RESOLVED DUPLICATE of bug 2045868

People

(Reporter: mnsy701x, Unassigned)

Details

Steps to reproduce

Summary

Two PContent handlers let a content process overwrite security-relevant embedder-side policy state on any browsing context id: the container permissions-policy info and the embedder referrer policy of a frame. Both are supposed to be set by the embedding document's process (when it creates/adjusts an iframe or object), and the parent has a ready-made ownership check for exactly this relation (CheckBrowsingContextEmbedder used by DiscardBrowsingContext) — but neither handler uses it, so a compromised child can retarget another process's frames.

What did you do (steps to reproduce)

  1. RecvSetContainerPermissionsPolicy (dom/ipc/ContentParent.cpp:8058-8070):
mozilla::ipc::IPCResult ContentParent::RecvSetContainerPermissionsPolicy(
    const MaybeDiscardedBrowsingContext& aContainerContext,
    MaybePermissionsPolicyInfo&& aContainerPermissionsPolicyInfo) {
  if (aContainerContext.IsNullOrDiscarded()) { return IPC_OK(); }
  auto* context = aContainerContext.get_canonical();
  context->SetContainerPermissionsPolicy(
      std::move(aContainerPermissionsPolicyInfo));
  return IPC_OK();
}
  1. RecvSetReferrerPolicyForEmbedderFrame (:8087-8095):
mozilla::ipc::IPCResult ContentParent::RecvSetReferrerPolicyForEmbedderFrame(
    const MaybeDiscardedBrowsingContext& aContext,
    const ReferrerPolicy& aPolicy) {
  if (!aContext.IsNullOrDiscarded()) {
    auto* canonical = aContext.get_canonical();
    canonical->SetEmbedderFrameReferrerPolicy(aPolicy);
  }
  return IPC_OK();
}
  1. Neither checks that the named context is embedded in — a frame of — the sending process. The legitimate callers are the embedder process (dom/html/HTMLIFrameElement.cpp:~330 / :~269, dom/base/nsObjectLoadingContent.cpp:1891), and the parent already contains the correct relation check for a sibling message: DiscardBrowsingContext (:7009-7026) uses CheckBrowsingContextEmbedder / IsEmbeddedInProcess before acting.

Actual results

What happened (actual results)

  • Referrer policy downgrade / privacy leak: the victim frame's stored embedder referrer policy can be replaced (e.g. with unsafe-url), so loads attributed to that frame then send full URLs as the Referer — exactly the leakage the policy exists to prevent.
  • Permissions-policy falsification: the container policy consumed when constructing LoadInfo for the frame and its descendants is overwritten, so feature-access decisions for a foreign frame's tree are made against attacker-chosen policy state.
  • Both writes target contexts the attacker does not own, from a process that has no legitimate reason to name them.

Honest limits: static-only finding (no dynamic run in this pass); the contrast with DiscardBrowsingContext and the abuse sketch are in the attached lane report.

Evidence/attachments: FF160_VALID_SWEEP.md (handler table and rank-6 abuse sketch).

Expected results

What should have happened (expected results)

Both handlers should apply the same embedder-ownership validation DiscardBrowsingContext already performs (CheckBrowsingContextEmbedder / IsEmbeddedInProcess on the named context against the sender). A process should only be able to set policy state for frames it actually embeds.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Security' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Security
Product: Firefox → Core

The severity field is not set for this bug.
:freddy, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(fbraun)
Status: UNCONFIRMED → RESOLVED
Closed: 28 days ago
Duplicate of bug: 2045868
Flags: needinfo?(fbraun)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.