Skip to content
Race condition Disclosed report Advanced CVE-2019-17021

Race condition in firefox!sandbox::CopyPolicyToTarget leading to Information Disclosure of broker heap address

On Windows, Firefox's renderer sandbox uses a token and integrity level that let one renderer process open and duplicate handles into another renderer while it is still bootstrapping. Because the broker copies a policy structure containing its own heap pointers into shared memory before rewriting those pointers to offsets, a compromised renderer can read the raw broker heap addresses during that window.

Thomas Imbert Follow

Originally disclosed on Mozilla

  • Fixed in 35 days
  • Paid in 42 days
  • Disclosed after 35 days

Created attachment 9111149 race.zip

Hi,

These issues only affects Windows client, I found two race condition in the shared memory of Firefox sandbox implementation.

  • Information Disclosure of broker heap address in CopyPolicyToTarget (described in this issue)
  • Memory corruption (Sandbox escape) in sandbox::SharedMemIPCServer::ThreadPingEventReady (described in issue 1599005)

Vulnerability:

Since Firefox (current version tested 70.0.1) configures the renderer sandbox with USER_LIMITED and Initial Integrity Level == Delayed Integrity Level (INTEGRITY_LEVEL_LOW), any renderer process can interact with other renderers process (read/write/createthread/duplicatehandles) even while new renderer process bootstrapping (when a new tab process is spawned). Google Chrome is not affected because the renderer processes runs with a USER_LOCKDOWN token (also the initial integrity level = LOW and delayed IL is UNTRUSTED) which prevent access to other renderer processes.

The race condition vulnerability happens during new process bootstrapping, when a new tab process is created, the broker does: 1/ CreateProcess SUSPENDED with the lockdown token (USER_LIMITED for Firefox renderer) and low IL in TargetProcess::Create 2/ Assign target process to JOB object 3/ Change target thread token to initial token (USER_RESTRICTED_SAME_ACCESS) for initialisation later 4/ Create IPCServer shared memory in TargetProcess::Init 5/ DuplicateHandle the shared memory with the target in TargetProcess::Init 6/ Copy policy and update pointers in CopyPolicyToTarget

So, the target process is suspended but other tabs are not and they can access the target process (thanks to USER_LIMITED token and same IL) and duplicate the IPC shared memory handle. A race condition exists when the policy is copied to the shared memory (containing broker heap addresses) before it updates policy->entry[i] pointers in CopyPolicyToTarget (6): void CopyPolicyToTarget(const void* source, size_t size, void* dest) { if (!source || !size) return; memcpy(dest, source, size); // (A) dest is shared memory and source contains broker heap pointers sandbox::PolicyGlobal* policy = reinterpret_castsandbox::PolicyGlobal*(dest);

size_t offset = reinterpret_cast<size_t>(source);

for (size_t i = 0; i < sandbox::kMaxServiceCount; i++) { size_t buffer = reinterpret_cast<size_t>(policy->entry[i]); if (buffer) { buffer -= offset; policy->entry[i] = reinterpret_castsandbox::PolicyBuffer*(buffer); // (B) remove the pointer base (race condition allows disclosure of heap address) } } }

Source code: https://github.com/mozilla/gecko-dev/blob/master/security/sandbox/chromium/sandbox/win/src/target_process.cc#L33

So, a compromised renderer can read the policy entries pointers before they are updated and it discloses broker heap addresses.

Repro:

The provided POC (attachment payload_infoleak) often triggers the vulnerability. Install Python 2.7 64 bits and PythonForWindows (https://github.com/hakril/PythonForWindows) then run inject.py with the payload_infoleak.dll path. Debug the injected tab to verify the information disclosure (in debug output). Then start new tabs to trigger the vulnerability (like a regular user would do) until it works.

RaceItLeak entry Leaked worked: dp payload_infoleak!leak_heap L1: 0000022D3486B198 (4220.3bdc): Break instruction exception - code 80000003 (first chance) KERNELBASE!wil::details::DebugBreak+0x2: 00007ff9`b3720192 cc int 3

The address is a valid heap address in the broker process (you can verify using !address in the broker). This information disclosure vulnerability allows an attacker to collect information that discloses the memory layout. In turn the attacker could use this information to deliver tailored exploits to bypass memory protection technologies such as ASLR for an additional LPE/RCE vulnerability.

Thank you

The original report as published on Mozilla's Bugzilla, by Thomas Imbert. 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 broker copies a policy structure full of its own heap pointers into shared memory and only afterwards converts those pointers to offsets, leaving a window where raw addresses are readable by another renderer.

Impact

A compromised renderer could learn the broker's memory layout, which the author says could help tailor exploits that bypass ASLR for a separate local privilege escalation or remote code execution flaw; the issue is Windows-only.

What the attacker needed

Windows target; Renderer already compromised; Race won during new tab start

How it was found

  1. Inject a payload into a renderer tab process using the provided injector script.
  2. Debug the injected tab to observe the leaked heap address in debug output.
  3. Open new tabs as a normal user would, to trigger the bootstrapping race until the leak fires.

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.

A sandbox is meant to keep a hacked browser tab from touching anything else. Here, while a new tab process is starting up, an already-hacked tab is allowed to reach into it and read a shared memory block. That block briefly holds real memory addresses from the more privileged broker process, which helps an attacker plan further attacks.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by Thomas Imbert

View all

3 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.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.