Closed Bug 2078152 Opened 1 month ago Closed 1 month ago

RecvSetDocumentDomain missing Permissions Policy check — document.domain relaxation bypass from compromised renderer

Categories

(Core :: DOM: Security, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2062703

People

(Reporter: nguyentuanhung1149, Unassigned)

Details

(Keywords: reporter-external)

Summary

WindowGlobalParent::RecvSetDocumentDomain (dom/ipc/WindowGlobalParent.cpp line 1667) does not enforce the "document-domain" Permissions Policy. A compromised content process can bypass the Permissions-Policy: document-domain=() restriction and relax its document.domain, potentially gaining same-origin access to a parent page or sibling frames that share the relaxed domain.

Root Cause

The child-side enforcement in Document::SetDomain (dom/base/Document.cpp line 9961) checks:

if (!PermissionsPolicyUtils::IsFeatureAllowed(this, u"document-domain"_ns)) {
  rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
  return;
}

But the parent-side IPC handler has a TODO comment explicitly acknowledging the missing check:

IPCResult WindowGlobalParent::RecvSetDocumentDomain(NotNull<nsIURI*> aDomain) {
  if (mSandboxFlags & SANDBOXED_DOMAIN) {
    return IPC_FAIL(this, "Sandbox disallows domain setting.");
  }
  // Might need to do a permissions policy check here, like we currently do in
  // the child process?
  ...
  mDocumentPrincipal->SetDomain(aDomain);
  return IPC_OK();
}

A compromised renderer bypasses the child-side check and sends SendSetDocumentDomain() directly to the parent process, which accepts it.

Attack Scenario

  1. top.example.com sets document.domain = "example.com" for legacy interop.
  2. top.example.com embeds an iframe from evil.sub.example.com with <iframe allow="document-domain none"> or via Permissions-Policy: document-domain=() header.
  3. The iframe's renderer is compromised (e.g. via a memory corruption bug in a prior step of a chain).
  4. Compromised renderer sends SendSetDocumentDomain(URI("example.com")) directly via IPC.
  5. Parent process accepts — sandbox check passes, domain suffix validation passes, but Permissions Policy check is missing.
  6. mDocumentPrincipal->SetDomain("example.com") is called.
  7. The iframe's WGP now has a principal with domain=example.com, matching the top-level page's relaxed domain.
  8. Parent-process security checks that compare principals (ClickHandlerParent, ContextMenuParent, storage principal decisions, etc.) now see same-origin where cross-origin was intended.

Impact

  • Permissions Policy bypass: the "document-domain" policy restriction is not enforced at the IPC boundary.
  • In the Fission threat model, a compromised content process should not be able to bypass permissions policy restrictions set by the embedder.
  • Enables same-origin determination for the principal in parent-process security decisions.
  • The fix is straightforward: add the same PermissionsPolicyUtils check (or equivalent parent-side check) before mDocumentPrincipal->SetDomain() in RecvSetDocumentDomain.

Affected Code

File: dom/ipc/WindowGlobalParent.cpp
Function: WindowGlobalParent::RecvSetDocumentDomain (line 1667)
TODO comment at lines 1674-1675.

Testing

Code-level analysis only (compromised renderer not simulated). The missing check and TODO comment are clearly visible in the source.

Credit

Nguyen Tuan Hung (nguyentuanhung1149@gmail.com)
VNU HCM - UIT

Group: core-security
No longer blocks: permissions-policy
Status: UNCONFIRMED → RESOLVED
Closed: 1 month ago
Duplicate of bug: 2062703
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.