SandboxBroker proc-fd rebind poisons ScriptPreloader cache
A compromised Firefox content process could turn a read-only inherited ScriptPreloader cache file descriptor into a writable one by abusing the Linux sandbox broker's symlink handling of /proc/<pid>/fd magic links. This let the attacker write attacker-controlled XDR bytes into the child script cache, which the parent process then decoded and executed as privileged chrome JavaScript.
Originally disclosed on Mozilla
- Fixed in 16 days
- Paid in 2 months
- Disclosed after 16 days
Created attachment 9587447
Self-contained same-session exploit PoC
Steps to reproduce:
Tested on a fresh mozilla-central / Nightly checkout with the default Linux content sandbox policy.
Source tested:
'''
hg id: 7ecf6404b86d
node: 7ecf6404b86dfbf101ebf4b67062a3dbb09fd4ee
date: 2026-05-18 06:35 +0000
Firefox version: Mozilla Firefox 152.0a1
BuildID: 20260518165944
'''
No content sandbox prefs were relaxed. Marionette is used only by the harness to launch a URL and shut Firefox down cleanly. The sandbox broker policy and content sandbox level are the Nightly defaults.
Download the attached PoC script:
'''
scriptpreloader_procfd_same_session_poc.sh
'''
Then run:
'''
chmod +x scriptpreloader_procfd_same_session_poc.sh
FIREFOX=/path/to/firefox/firefox \
MACH=/path/to/mozilla-central/mach \
./scriptpreloader_procfd_same_session_poc.sh
'''
The PoC has one setup launch and one exploit launch:
1. Build `libsp_rebind_live.so`, an `LD_PRELOAD` compromised-content-process simulator. Its constructor exits unless the command line contains `-contentproc`.
2. Setup launch: start stock Nightly once with a temporary profile so a realistic existing `startupCache/scriptCache-child.bin` is present, then shut it down cleanly.
3. Parse that child ScriptPreloader cache and dynamically find the current offset and size of `moz-src:///toolkit/modules/FaviconUtils.sys.mjs`.
4. Exploit launch: start stock Nightly on a `data:` stager page. The stager waits 10 seconds before navigating to `http://127.0.0.1:<port>/favicon_trigger.html`.
5. In the live web content process, after seccomp mode 2 is active, capture the read-only `scriptCache-child-current.bin` fd sent by `ScriptCacheParent`.
6. Attempt two negative controls:
- Direct `pwrite()` to the inherited read-only cache fd.
- Direct symlink creation to `/proc/self/fd/100` while fd 100 already points at the cache fd.
7. Create a broker-authorized symlink under the default-writable `$XDG_RUNTIME_DIR/dconf/` policy path while fd 100 points at a normal allowed seed file.
8. Rebind fd 100 to the inherited ScriptPreloader cache fd and broker-open the symlink for write. The kernel follows the symlink to `/proc/<content-pid>/fd/100`, now pointing at the cache fd.
9. Write the replacement `FaviconUtils.sys.mjs` XDR bytes into `startupCache/scriptCache-child-current.bin`.
10. In the same browser session, the stager navigates to `favicon_trigger.html`. Its icon link triggers `LinkHandlerParent.sys.mjs`, which statically imports `FaviconUtils.sys.mjs`.
11. The parent process decodes the modified `FaviconUtils.sys.mjs` stencil from the child ScriptPreloader cache and runs attacker-controlled chrome JavaScript in `processType=0`.
There is no post-write browser restart in the exploit run. The first launch only creates the pre-existing profile cache that a real user profile would already have.
Relevant source paths reviewed:
'''
dom/ipc/ContentParent.cpp:3080-3090
Parent creates a Linux SandboxBroker for content and sends the broker fd to the child.
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp:770-776
Default GTK content policy grants rdwrcr to $XDG_RUNTIME_DIR/dconf/.
security/sandbox/linux/SandboxBrokerClient.cpp:29-82
Client-side broker wrapper rewrites only the first path from /proc/self/... to /proc/<content-pid>/...
security/sandbox/linux/broker/SandboxBroker.cpp:806-819
Broker looks up the first path and only runs SymlinkPermissions when that lookup returns no permissions.
security/sandbox/linux/broker/SandboxBroker.cpp:860-866
SANDBOX_FILE_OPEN authorizes the path string and then calls open(pathBuf, ...).
security/sandbox/linux/broker/SandboxBroker.cpp:912-916
SANDBOX_FILE_SYMLINK is allowed when the intersected string permissions satisfy W_OK | X_OK.
security/sandbox/linux/broker/SandboxBrokerRealpath.cpp:197-214 and :271-272
Symlink target resolution can authorize a /proc/<pid>/fd/N target based on what that fd points to at symlink creation time.
js/xpconnect/loader/ScriptPreloader.cpp:198-233
Parent clones and sends the child ScriptPreloader cache fd to each content process.
js/xpconnect/loader/AutoMemMap.h:34-39
js/xpconnect/loader/AutoMemMap.cpp:39-55 and :79-84
The received cache fd is imported and mapped read-only by default.
js/xpconnect/loader/ScriptPreloader.cpp:1077-1082
Parent lookup can satisfy shared parent/child scripts from the child ScriptPreloader cache.
browser/actors/LinkHandlerParent.sys.mjs:5-10
LinkHandlerParent statically imports FaviconUtils.sys.mjs.
'''
Actual results:
The same-session stock content-process harness passed on the Nightly build above.
Harness output:
'''
firefox_rc=0
firefox_rc=0
PASS: same-session fast favicon path executed modified cache in parent
Broker/preload log: /tmp/sp-rebind-favicon-fast.log
Live stdout: /tmp/fx-sp-favicon-fast-live.stdout
Live log: /tmp/fx-sp-favicon-fast-live.log.moz_log
'''
The broker/preload log shows the two negative controls and the successful write after the proc-fd rebind:
'''
content preload initialized runtime=/run/user/1000
loaded payload path=.../poc/payload-favicon-xpcom-stdout-2916.xdr size=2916 offset=662276
captured script cache fd original=29 dup=200 target=/tmp/fx-sp-favicon-fast-live/startupCache/scriptCache-child-current.bin
seccomp mode is 2
direct pwrite on read-only cache fd rv=-1 errno=9
direct proc-fd symlink while fd points at cache rv=-1 errno=13
staged proc-fd symlink rv=0 errno=13 link=/run/user/1000/dconf/sp-rebind-link-<pid> -> /proc/self/fd/100
SUCCESS wrote 2916 bytes at offset 662276 through rebound link
'''
The harness also verifies that the live cache bytes exactly match the payload:
'''
cmp -n 2916 -i 662276:0 \
/tmp/fx-sp-favicon-fast-live/startupCache/scriptCache-child-current.bin \
poc/payload-favicon-xpcom-stdout-2916.xdr
cmp exited 0
'''
The same exploit session then loads `FaviconUtils.sys.mjs` in both content and parent. The parent marker proves privileged chrome JS execution in `processType=0`; `xpcomLocalFile=true` proves the payload can resolve a privileged XPCOM contract:
'''
FaviconUtils marker processType=2 xpcomLocalFile=true
FaviconUtils marker processType=0 xpcomLocalFile=true
'''
The parent-side ScriptPreloader log confirms the target module came from cache:
'''
[Parent ...]: D/JSModuleLoader Successfully loaded resource:///actors/LinkHandlerParent.sys.mjs from cache
[Parent ...]: I/ScriptPreloader Decoding stencil moz-src:///toolkit/modules/FaviconUtils.sys.mjs on main thread...
[Parent ...]: D/JSModuleLoader Successfully loaded moz-src:///toolkit/modules/FaviconUtils.sys.mjs from cache
'''
Root cause:
The broker authorizes a mutable proc-fd symlink target at one time, then later authorizes the symlink path string without binding that decision to the same file object.
For `symlink("/proc/self/fd/100", "$XDG_RUNTIME_DIR/dconf/link")`, the client rewrites the first path to `/proc/<content-pid>/fd/100`. While fd 100 points at a normal writable seed file under the default-allowed `dconf/` directory, the broker resolves the proc-fd magic link and allows the symlink creation.
After the symlink exists, the content process rebinds fd 100 to the inherited read-only ScriptPreloader cache fd. A later brokered `open("$XDG_RUNTIME_DIR/dconf/link", O_WRONLY)` is authorized by the writable `dconf/` path. Because the direct policy lookup for the link path succeeds, the broker does not run the symlink-target fallback. The broker then calls `open(pathBuf, ...)`; the kernel follows the symlink to the now-rebound `/proc/<content-pid>/fd/100`, and the returned fd is writable to the ScriptPreloader cache file.
Expected results:
A compromised content process should not be able to convert a read-only inherited file descriptor for a parent-trusted cache file into a writable fd through the sandbox broker.
The broker should not authorize symlinks to mutable `/proc/<content-pid>/fd/N` magic links based only on the fd target at symlink creation time. It should either reject these magic-link targets, bind authorization to a stable object identity, or ensure the final target is revalidated at the same point as the operation that opens it.
For brokered open of paths under writable/creatable directories, the broker should not skip final symlink target authorization merely because the link path itself matches an allowed writable prefix. On Linux, using `openat2`-style constraints such as no magic links / no symlinks where available would reduce this class of time-of-check/time-of-use mismatch.
ScriptPreloader should also avoid sharing a live disk-backed fd for a parent-trusted cache file with sandboxed content if the parent can later execute code from that same cache. A sealed immutable object, memfd-style copy, or non-profile-backed read-only snapshot would reduce the blast radius.
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
The broker authorizes a mutable proc-fd symlink target at one time, then later authorizes the symlink path string without binding that decision to the same file object.
Impact
A compromised content process could gain privileged chrome JavaScript execution in the parent process, escaping the content sandbox, though the exploit requires an already-compromised content process and a same-session navigation to trigger the cached import.
What the attacker needed
Compromised content process; Linux with default content sandbox; same-session navigation to trigger import
The fix
The report recommends rejecting or binding authorization for mutable proc-fd magic links, revalidating the final symlink target at open time (for example with openat2-style constraints), and avoiding sharing a live disk-backed cache fd with sandboxed content.
How it was found
- Build an LD_PRELOAD library that only activates inside a content process.
- Run a setup launch of stock Nightly with a temporary profile to create a realistic child script cache, then shut it down.
- Parse the cache to find the offset and size of the target module.
- Launch Nightly on a stager page that waits then navigates to a favicon trigger page.
- In the content process, capture the inherited read-only cache fd and confirm direct writes and direct proc-fd symlinks fail.
- Create a broker-authorized symlink under the writable dconf runtime path while fd 100 points at an allowed seed file, then rebind fd 100 to the cache fd and broker-open the symlink for write.
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 runs web pages in a locked-down child process and uses a helper called the sandbox broker to do file operations the child is not allowed to do itself. The broker checked a shortcut (symlink) to a file once, then later opened it without rechecking, so the child could swap what the shortcut pointed at in between. That let the child write into a cache file the parent trusts, and the parent then ran the tampered code with full browser 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.