RecvSetDocumentDomain missing Permissions Policy check — document.domain relaxation bypass from compromised renderer
Categories
(Core :: DOM: Security, defect)
Tracking
()
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
- top.example.com sets
document.domain = "example.com"for legacy interop. - top.example.com embeds an iframe from evil.sub.example.com with
<iframe allow="document-domain none">or viaPermissions-Policy: document-domain=()header. - The iframe's renderer is compromised (e.g. via a memory corruption bug in a prior step of a chain).
- Compromised renderer sends
SendSetDocumentDomain(URI("example.com"))directly via IPC. - Parent process accepts — sandbox check passes, domain suffix validation passes, but Permissions Policy check is missing.
mDocumentPrincipal->SetDomain("example.com")is called.- The iframe's WGP now has a principal with domain=example.com, matching the top-level page's relaxed domain.
- 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
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Description
•