Skip to content
Memory corruption Disclosed report Advanced CVE-2026-16351

Content process can forge BrowsingContext BrowserId and trigger parent-process UAF through stale sCurrentTopByBrowserId entry

A type mismatch in the parent-side validator for the synced BrowsingContext BrowserId field let a compromised content process change a top-level context's browser id after registration. Because the parent's browser-id map was keyed on the original id but unregistered by the mutated id, a stale raw pointer remained and was later dereferenced during permission expiry, causing a parent-process use-after-free.

Yaqoub Aldurayhim Follow

Originally disclosed on Mozilla

  • Fixed in 33 days
  • Paid in 3 months
  • Disclosed after 33 days

Created attachment 9594332 oldPoc.patch

Overview

BrowsingContext::BrowserId is a synced uint64_t field, but its specialized parent-side CanSet(FieldIndex<IDX_BrowserId>) validator takes const uint32_t&. When a content-sourced CommitBrowsingContextTransaction validates the actual uint64_t value, overload resolution selects the generic allowing CanSet template instead of the restrictive BrowserId validator.

A compromised content process can therefore mutate the top-level BrowserId after the parent has registered the context. The parent stores top-level content BrowsingContext objects in sCurrentTopByBrowserId as raw BrowsingContext* values. Registration inserts under the original id, but teardown unregisters by the current attacker-mutated id, leaving the original key mapped to a freed object.

Default browser-scoped permission expiry later re-resolves the original browser id through BrowsingContext::GetCurrentTopByBrowserId, which calls do_AddRef on the stale raw pointer in the parent process.

Build / Environment

Validated build:

Text
Firefox Nightly 153.0a1
moz:buildID: 20260606101250
Platform: Linux x86_64 / Ubuntu 24.04
Build config: default source build, no mozconfig
buildtype: opt
nightly_build: True
official: False
asan: False
debug: False
e10s: True
fission: True
has_sandbox: True

Steps To Reproduce

  1. Apply poc.patch to a clean Firefox Nightly source checkout.
  2. Build Firefox with the default source-build configuration:
Bash
./mach build
  1. Run the PoC browser test:
Bash
./mach test --force docshell/test/browser/browser_browsingContext_browserId_permission_expiry_uaf_poc.js

The patch adds a test-only nsIDOMWindowUtils hook callable only from the content process. The hook models the compromised-content-process threat model by committing:

C++
BrowsingContext::Transaction txn;
txn.SetBrowserId(aBrowserId);
return txn.Commit(bc);

This exercises the same synced-context transaction path that reaches ContentParent::RecvCommitBrowsingContextTransaction.

Actual Results

The PoC first proves the content transaction changed the top-level BrowserId while the old BrowserId still maps to the same mutated BrowsingContext:

Text
PASS content transaction saw old id
PASS old BrowserId still maps to the mutated BrowsingContext

After tab removal and GC/CC, the default PermissionManager browser-scoped expiry path re-resolves the old BrowserId and crashes the parent process:

Text
CRASH: pid:3509498. Process type: main.
Signature:[@ libxul.so + 0x00000000094a8c3e]
Crash reason: SIGSEGV / SI_KERNEL
Non-canonical address detected: 0xe5e5e5e5e5e5e5ed
Crashing instruction: call qword [rax + 0x8]
rax = 0xe5e5e5e5e5e5e5e5
rbx = 0x000070d5283a7d00
rdi = 0x000070d5283a7d00
TEST_END: Test CRASH, expected PASS. Subtests passed 2/2.

Symbolized stack:

Text
mozilla::RefPtrTraits<mozilla::dom::BrowsingContext>::AddRef
mozilla::dom::BrowsingContext::GetCurrentTopByBrowserId
nsObserverList::NotifyObservers
mozilla::PermissionManager::NotifyBrowserObservers
mozilla::PermissionManager::ScheduleBrowserPermissionExpiry(...)::$_0::operator()

Reliability testing on the same default opt build reached the same crash site 16/16 times. Most runs dereferenced freed-memory poison (0xe5e5e5e5e5e5e5e5), confirming UAF; several runs dereferenced non-poison reclaimed values, confirming the freed chunk is reused.

Expected Results

The parent must reject content-sourced attempts to mutate an already-initialized top-level BrowsingContext::BrowserId.

The browser-id map must also not retain stale raw pointers if a BrowsingContext identity field changes or the object is destroyed.

Security Impact

This is a sandbox escape primitive under the compromised content process model.

A content process can mutate a privileged BrowsingContext identity field over real IPC, causing the parent to retain a dangling raw pointer. Later default parent code dereferences the stale pointer. The crash site is a virtual AddRef dispatch:

ASM
mov  (%rbx),%rax
mov  %rbx,%rdi
call *0x8(%rax)

If the freed chunk is reclaimed with attacker-shaped bytes, this becomes a fake-vtable indirect call in the parent process with controlled this in rdi. I am not claiming a complete native payload; the submitted PoC demonstrates the content-reachable parent UAF, default-code trigger, exact crash primitive, and reliable reproduction.

The original report as published on Mozilla's Bugzilla, by Yaqoub Aldurayhim. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 specialised parent-side CanSet validator for the BrowserId field took a 32-bit reference while the field is 64-bit, so overload resolution picked the generic permissive template and content-sourced transactions could mutate an already-initialised top-level BrowserId.

Impact

Under the compromised content process model this is a sandbox escape primitive: a stale pointer is dereferenced in the parent, and if the freed chunk is reclaimed with attacker-shaped bytes it could become a fake-vtable indirect call, though the author does not claim a complete native payload.

What the attacker needed

Compromised content process; Firefox Nightly with fission and sandbox; tab closed and GC/CC run; permission expiry path runs

The fix

The parent should reject content-sourced attempts to mutate an already-initialised top-level BrowserId, and the browser-id map should not retain stale raw pointers when an identity field changes or the object is destroyed.

How it was found

  1. Apply the provided patch to a clean Firefox Nightly source checkout.
  2. Build Firefox with the default source-build configuration.
  3. Run the PoC browser test through the test harness.
  4. The test-only hook commits a BrowserId transaction from the content process, changing the top-level id.
  5. Remove the tab and force GC/CC so the context is freed while the old id still maps to it.
  6. Wait for the default browser-scoped permission expiry path to re-resolve the old id and crash the parent.

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 locked-down 'content' process that renders web pages and a more powerful 'parent' process. The parent kept a lookup table of browser windows using a number that the content process was wrongly allowed to change. After the window was closed, the table still pointed at freed memory, and later normal code followed that pointer and crashed, which could potentially be turned into code execution in the parent.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Yaqoub Aldurayhim

View all

16 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.