Skip to content
Access control Disclosed report Advanced CVE-2023-23597

Privilege escalation from web to file process

A sandbox escape in Firefox's Windows content process: by hooking two internal checks and loading a local file in an iframe, a renderer exploit could open a new window that runs as a file:// process with broader privileges. That file process can read all files and, on Windows, runs with a less restricted token, so an attacker with a renderer exploit could reach the whole filesystem.

Niklas Baumstark Follow

Originally disclosed on Mozilla

  • Fixed in 3.7 years
  • Paid in 10 months
  • Disclosed after 3.7 years
Text
This was found via manual analysis of the sandbox code of Firefox 65. I am currently not able to get a Windows debug build for Firefox 66, but I assume the flaw still exists.

Given a renderer exploit, we can perform the following steps:

1. Hook CheckLoadURIWithPrincipal to always return true.
2. Hook PopupBlocker::CanShowPopupByPermission to always allow.
3. Load file:///path/to/stage1.html in an iframe.
   stage1.html file must be readable from within the web sandbox,
   either drop it to temp dir sContentTempDir, or use a UNC path on Windows.
   Every action performed from this document will be associated with
   a security principal for a file:/// origin.
4. In stage1.html, we can do window.open('file:///path/to/stage2.html')
   This will create a new FILE_REMOTE_TYPE process.
5. Now re-exploit the new renderer from stage2.html.

Similar to my Pwn2Own bug, steps 1-4 can probably be replaced by appropriate IPC/message manager/XPCOM usage which I have not investigated in detail.

We escalated privileges, because a file process can:

* Access all files [1]
* On Windows, access a USER_NON_ADMIN token, rather than USER_PROTECTED [2]


[1]: https://github.com/mozilla/gecko-dev/blob/177fb00ebaaf69857d8f04334b46a107feb212ac/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp#L505
[2]: https://github.com/mozilla/gecko-dev/blob/177fb00ebaaf69857d8f04334b46a107feb212ac/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp#L419

The original report as published on Mozilla's Bugzilla, by Niklas Baumstark. 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

Likely the file:// process type is granted broader filesystem and token access than the web content process, and the checks that should stop web content from loading file:// URLs and opening popups can be bypassed from within a compromised renderer.

Impact

An attacker who already has a renderer exploit could escalate to a file process that can access all files and, on Windows, runs with a less restricted token.

What the attacker needed

A renderer exploit; ability to write or read a local HTML file; Windows target for the token gain

How it was found

  1. Hook the URI-loading check so it always allows the load.
  2. Hook the popup permission check so popups are always allowed.
  3. Load a local stage1.html file in an iframe from within the web sandbox.
  4. From stage1.html, open a second local file in a new window, which starts a file process.
  5. Exploit the new renderer to gain the file process's privileges.

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 inside a restricted 'sandbox' so that a hacked page cannot touch your files. This report shows that a page could trick Firefox into opening a local file in a new window, and that new window runs with fewer restrictions. So an attacker who already broke into the page process could then read files on the machine.

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.

More by Niklas Baumstark

View all

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

Broken access control

The lesson behind this report.

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.