Content process can forge DocumentChannel srcdoc load state to execute SystemPrincipal script in parent process
A compromised content process could forge the load state of a DocumentChannel srcdoc navigation so the parent process treated attacker-supplied srcdoc bytes as a privileged chrome:// document. The payload then ran JavaScript with the System Principal in the parent process and could call privileged XPCOM APIs.
Originally disclosed on Mozilla
- Fixed in 18 days
- Paid in 4 months
- Disclosed after 18 days
Created attachment 9587054
env-gated PoC harness simulating compromised content-process DocumentChannel load-state forgery.
Steps to reproduce:
1. Apply `validation-hook.diff` to current mozilla-central/Nightly and build:
'''bash
./mach build -j4
'''
2. From the attached finding directory, serve the reduced trigger page:
'''bash
python3 -m http.server 8765 --bind 127.0.0.1
'''
3. In the Firefox source tree, remove any stale marker and run Nightly with a
fresh temporary profile:
'''bash
rm -f /tmp/dc-srcdoc-poc-marker.txt
env MOZ_DC_SRCDOC_POC=1 \
MOZ_LOG='DocumentChannel:5,ProcessIsolation:5,nsDocShell:5' \
MOZ_LOG_FILE=/tmp/dc-srcdoc-poc.log \
timeout 60s ./mach run --temp-profile -- --headless --no-remote \
'http://127.0.0.1:8765/trigger.html'
'''
4. Observe the marker written by the attacker-controlled srcdoc payload:
'''bash
cat /tmp/dc-srcdoc-poc-marker.txt
'''
5. Negative control: directly opening `https://example.com/dc-srcdoc-poc` from
the command line with the same harness is rejected with:
'''text
IPDL protocol error: nsDocShellLoadState URI changed while in content process
'''
This demonstrates that the parent-side pending-load validation catches a
parent-originated top-level load. The successful path is the content-initiated
navigation, where there is no pending original state to compare against and the
parent falls back to only checking `TriggeringRemoteType`. No
`/tmp/dc-srcdoc-poc-marker.txt` marker is written on the negative-control path.
Actual results:
The srcdoc payload executes with system privileges in the parent/default process
and writes:
'''text
principal=[System Principal] system=true
processType=0
uri=chrome://global/content/mozilla.html
'''
Relevant parent log excerpt:
'''text
DocumentChannelParent Init [... uri=chrome://global/content/mozilla.html]
DocumentLoadListener [...] OpenDocument [uri=chrome://global/content/mozilla.html]
IsolationOptionsForNavigation principal:[System Principal], uri:chrome://global/content/mozilla.html
Using IsolationBehavior Parent for [System Principal]
Process Switch: Changing Remoteness from 'webIsolated=http://127.0.0.1' to ''
'''
The payload also successfully uses privileged XPCOM APIs from the supplied
srcdoc JavaScript:
'''javascript
Components.classes["@mozilla.org/preferences-service;1"]
Components.classes["@mozilla.org/file/local;1"]
Components.classes["@mozilla.org/network/file-output-stream;1"]
'''
So the post-condition is not only a visual navigation or wrong-process load. It
is attacker-controlled JavaScript executing as `SystemPrincipal` in
`processType=0`.
Expected results:
The parent process should reject a content-supplied `nsDocShellLoadState` that
attempts to load a privileged `chrome://` document, uses `SystemPrincipal`,
supplies `PrincipalToInherit` or `PartitionedPrincipalToInherit` with a
privileged principal, or supplies `SrcdocData`/`IS_SRCDOC` unless the parent can
prove this load state was parent-originated and unchanged.
At minimum, a compromised content process should not be able to create a
parent-process document whose bytes come from attacker-controlled `SrcdocData`,
and should not be able to cause `SEC_FORCE_INHERIT_PRINCIPAL` to select
`SystemPrincipal` as the result principal for that document.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the parent-side validation of a content-initiated DocumentChannel load only checked the triggering remote type and had no original parent-side load state to compare against, so a forged srcdoc load state with a privileged principal was trusted.
Impact
Attacker-controlled JavaScript could execute as SystemPrincipal in the parent process, giving access to privileged XPCOM APIs; the text notes the negative control shows parent-originated loads are still rejected, so the flaw is limited to content-initiated navigations.
What the attacker needed
Compromised content process; custom patched Nightly build
The fix
The parent process should reject content-supplied load states that target privileged chrome:// documents, use SystemPrincipal, inherit a privileged principal, or carry srcdoc data unless it can prove the state was parent-originated and unchanged.
How it was found
- Apply the validation hook patch and build Nightly.
- Serve the reduced trigger page from a local HTTP server.
- Run Nightly headless with a fresh temporary profile and the proof-of-concept environment variable set, loading the trigger page.
- Check the marker file written by the srcdoc payload.
- As a negative control, open a normal URL directly and confirm the parent rejects it with an IPDL protocol error.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Firefox splits its work into a sandboxed 'content' process that renders web pages and a more trusted 'parent' process. The content process is supposed to ask the parent to start navigations, and the parent is meant to check those requests. Here the parent accepted a forged request that claimed a page came from a trusted internal source, so untrusted code ended up running with the highest privileges.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.