UXSS via PDocumentChannel IPC — ValidateWithOriginalState does not check PrincipalToInherit or SrcdocData (sibling of Bug 2046558, different entry point)
Categories
(Core :: DOM: Navigation, defect)
Tracking
()
People
(Reporter: satyamasd, Unassigned)
References
Details
(Keywords: reporter-external, Whiteboard: [client-bounty-form])
Attachments
(4 files)
Description
This is a sibling of Bug 2046558 that I filed yesterday. That bug showed that session history IPC lets a compromised renderer inject an arbitrary principal via RecvSetActiveSessionHistoryEntry. While tracing through related code paths, I found that the same class of injection is possible through the DocumentChannel IPC path — and would require a separate fix.
The problem
When a content process initiates a document load, it sends a DocShellLoadStateInit to the parent via PDocumentChannelConstructor. The parent validates some fields but not all of them.
I looked at ValidateWithOriginalState() in nsDocShellLoadState.cpp and found that for parent-initiated loads that round-trip through the content process, it compares the returned state against the original. It checks URI, triggering principal, sandbox flags, remote type, and a few others — but it does not check PrincipalToInherit, SrcdocData, or InternalLoadFlags. There are FIXME comments in the code acknowledging this gap.
For child-initiated loads (where there's no original state to compare against), the only validation is that TriggeringRemoteType matches the sender, plus the srcdoc/URI consistency check added by Bug 2040160 (which passes here since we set URI = about:srcdoc). PrincipalToInherit is accepted as-is.
How it's exploited
A compromised renderer targets any of its own iframes. The crafted load request contains:
- URI =
about:srcdoc - SrcdocData = attacker's HTML with script
- PrincipalToInherit = victim origin (e.g.
https://victim.com) - The IS_SRCDOC internal load flag
The parent accepts these fields without validation. Since the URI is about:srcdoc and there's a PrincipalToInherit, the channel gets SEC_FORCE_INHERIT_PRINCIPAL. CheckForIncoherentResultPrincipal doesn't catch this because it doesn't have a condition for about:srcdoc inheriting an HTTP principal — same gap that Bug 2046558 relies on. The attacker's HTML then executes with full access to the victim's origin, cookies, and DOM.
Relationship to Bug 2046558
Both bugs exploit the same fundamental gap — PrincipalToInherit flows from IPC to document principal without validation. But they enter through different doors:
- Bug 2046558 enters through the session history IPC handlers (
RecvSetActiveSessionHistoryEntry). - This bug enters through the DocumentChannel IPC path (
PDocumentChannelConstructorviaPNecko). The attacker targets its own BC, so ownership checks alone don't help — the missing piece is thatValidateWithOriginalStateand the child-initiated load path don't validatePrincipalToInherit.
Fixing Bug 2046558 at its entry point does not fix this path — they need separate fixes.
Steps to Reproduce
The attached poc.patch adds a test-only method testOnlyCraftedDocChannelLoad to Element (same pattern as the PoC for Bug 2046558). This method simulates what a compromised renderer would do: it calls nsDocShell::InternalLoad with a crafted nsDocShellLoadState containing a victim-origin PrincipalToInherit. The load goes through the full DocumentChannel IPC pipeline to the parent, which accepts it without validating the principal.
Note on PoC method: The method calls InternalLoad directly instead of LoadURI because LoadURI calls SetupInheritingPrincipal() which unconditionally overwrites PrincipalToInherit with TriggeringPrincipal — a content-process-side safety measure. A real compromised renderer would bypass this entirely by crafting the PDocumentChannelConstructor IPC message directly. Calling InternalLoad simulates that bypass.
Build & run
cd mozilla-unified
git apply poc.patch
./mach build
# Start two HTTP servers (attacker on 8000, victim on 8001):
python3 serve_poc.py
# Open the PoC:
./mach run http://localhost:8000/poc_validate.html
The attacker page at localhost:8000 creates an iframe, then calls testOnlyCraftedDocChannelLoad on it. This sends an about:srcdoc load through DocumentChannel IPC with PrincipalToInherit set to http://localhost:8001 (the victim). After ~1 second, the iframe displays injected content running as the victim's origin.
Expected Results
ValidateWithOriginalStateshould also validatePrincipalToInherit,SrcdocData, andInternalLoadFlagsagainst the original state- For child-initiated loads,
PrincipalToInheritshould be validated against the sender's process CheckForIncoherentResultPrincipalshould catchabout:srcdocinheriting an HTTP principal as defense-in-depth
Actual Results
The iframe shows:
window.origin: http://localhost:8001 ← victim origin
document.URI: about:srcdoc
Same-origin fetch to victim succeeded, length: 166
Cookies (victim origin): poc_injected=true
The attacker page at localhost:8000 injected HTML+JS that executes with full victim-origin (localhost:8001) privileges — including same-origin fetch and cookie access. The parent page can no longer access iframe.contentDocument (returns null), confirming the iframe genuinely became cross-origin.
Affected Versions
Tested on Firefox Nightly (latest as of 2026-06-11).
Impact
- Prerequisites: Compromised renderer (standard Fission threat model). No user interaction needed. No special page structure needed — any iframe owned by the attacker's process works.
- Impact: Full UXSS — attacker-controlled JavaScript executes in victim origin with access to cookies, localStorage, and same-origin DOM
Updated•5 months ago
|
Comment 4•5 months ago
|
||
vhilla: is this a dupe of bug 2034682 / bug 2035756? We knew those were still problems even when we fixed the bug 2040160 part.
Comment 5•5 months ago
|
||
Yes, it's a duplicate. Though the PoC is broken as it has to be <\/script> instead of <\\/script>.
Updated•4 months ago
|
Updated•4 months ago
|
Updated•1 month ago
|
Description
•