RecvSetContainerFeaturePolicy: no embedder-process check allows Permissions Policy bypass for cross-origin iframes
Categories
(Core :: DOM: Security, defect)
Tracking
()
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 deniedmAttributeEnabledFeatureNames— features enabled viaallow=;MaybeSetAllowedPolicyis called for each, adding them withAllowsAll()mDeclaredString— the raw policy string, parsed bySetDeclaredPolicy
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).
Updated•7 months ago
|
Updated•7 months ago
|
Updated•7 months ago
|
Updated•2 months ago
|
Description
•