Skip to content
Access control Disclosed report Advanced

MozillaMaintenance service arbitrary file creation privilege escalation on Windows

The MozillaMaintenance service creates update files in a user-controlled directory with SYSTEM privileges, allowing an unprivileged user to redirect file creation to arbitrary locations. This can be exploited to create a malicious DLL in System32 and escalate to SYSTEM.

clem Follow

Originally disclosed on Mozilla

  • Fixed in 20 days
  • Paid in 22 days
  • Disclosed after 20 days
Text
Created attachment 8998602
Proof of concept (source and binaries)

SUMMARY

The the privileged status/log file creation performed by the MozillaMaintenance update service on Windows can be abused to create arbitrary files with write access. This can be used by an unprivileged user to obtain SYSTEM privileges.


VERSION

Firefox Version tested: 61.0.1 stable
MozillaMaintenance service version: 61.0.1.6759
Operating System: Windows 10 1803 (10.0.17134.112) x64


VULNERABILITY DETAILS

The MozillaMaintenance service creates files in a user-provided update location:
- maintenanceservice.exe creates an update.status file when it runs alone (no updater.exe)
- (Firefox's) updater.exe creates update.status and update.log

These files are actually created as temporary files via GetTempFileName (with 'svc', 'sta' and 'log' prefixes respectively + 3 or 4 hexadecimal digits + '.tmp' extension), then renamed/moved.
They are created and renamed/moved with SYSTEM privileges, without impersonation, in a user-provided directory (absolute path that must end with ...\updates\0).

This can be abused by an unprivileged user to create files as SYSTEM.

Indeed, because the user has control over the directory where these operations take place, an unprivileged user can change it to an NTFS junction that points to an arbitrary directory like C:\Windows\System32, and/or change its content to links targeting other files.

A quick illustration of this problem can be obtained with the following PowerShell commands:
New-Item -Type Junction -Force -Path C:\Temp\updates\0 -Value C:\Windows\System32
(Get-Service MozillaMaintenance).Start(@("MozillaMaintenance", "software-update", "updater.exe", "C:\Temp\updates\0", "C:\X", "C:\X"))

The above commands make the MozillaMaintenance service create an update.status file in C:\Windows\System32, because C:\Temp\updates\0 "points to" (reparses to) that directory.

Now, creating files with no control over the content isn't really that interesting, so we have to do it in a way that gives us control over the content and (optionally) the path of the resulting file.

One way to do this is by using symbolic links with the name of the manipulated files, e.g. predict/bruteforce the name of the temporary file (or change its content before the rename/move operation), and use a link with the name of the final file to choose the destination path.

Unprivileged users can't create "real" NTFS symbolic links on the filesystem by default, but they can create something close enough to work in most instances (including this case), by leveraging a technique found by James Forshaw of Google Project Zero.
Indeed, the parent directory (some\path\updates\0 in our case) can be made a junction to the \RPC Control\ object directory, where users can create symbolic link with arbitrary name and target path. The CreateFile call will reparse as needed (one time for the junction and another for the symlink), resulting in the application opening the desired file.
So, with the following setup:
C:\Temp\updates\0 -> \RPC Control\ (NTFS junction)
\RPC Control\update.status -> C:\Windows\System32\evil.dll (object manager symbolic link)
A CreateFile operation on C:\Temp\updates\0\update.status will actually open the file C:\Windows\System32\evil.dll

By making the temporary file creation in a user-writable location, before moving it to System32, we keep the file's access rights, so its content can then be replaced at will after it has moved to System32 even from our unprivileged user account.

We also need to create a symbolic link for the temporary file. The additional benefit of using object manager symlinks is that we don't have to guess or "bruteforce" the name of the temporary file. Indeed, the temporary file name creation (GetTempFileName), will cycle through 0000-FFFF for us when trying to create the name svcXXXX.tmp, as it gets REPARSE results when there is no symlink in \RPC Control\ with that name, because of the way GetTempFileName works.
So we just have to create one single link, e.g. svcAAAA.tmp, pointing to a file that does not yet exist in a user-writable location (C:\Temp\updates\moz_svc.tmp in the PoC).

Once these links are set up, we just have to call the MozillaMaintenance service with our trap directory to have it create our target file (arbitrary path) with SYSTEM privileges, and then we can replace its content with our evil payload (arbitrary content).


There are several ways to escalate privileges given an arbitrary file creation, for this PoC I chose to create the wow64log.dll file in C:\Windows\System32, which on x64 systems is loaded in 32-bits WOW64 processes. Because the MozillaMaintenance executable is 32-bits, we just start the service a second time to have it load the DLL and run our payload as SYSTEM.


PROOF OF CONCEPT

I've provided a PoC that implement the above step in order to spawn a shell running as SYSTEM from an unprivileged user session.

This PoC has the following components:
- CreateSymlink.exe: a tool by James Forshaw that implements the pseudo-symlink technique described above. Part of https://github.com/google/symboliclink-testing-tools
- wow64log.dll: the DLL that gets written to System32, gets loaded in MM service, and runs our final payload (SpawnShell.exe) with SYSTEM privileges (before the service trims down its privileges)
- SpawnShell.exe: the payload, spawns a SYSTEM shell in the user's session
- poc.ps1: a PowerShell scripts to automate the attack

I've separated the arbitrary file creation and its use for privilege escalation into 2 functions in the script, so that you can reproduce the former without the latter if you'd like to.

Usage instructions:
1) Unzip the poc
2) Execute the poc.ps1 PowerShell script by running the command "powershell -exec bypass path\to\poc.ps1" (or right-clicking on poc.ps1 in explorer and choosing "Run with PowerShell")

Tested on Windows 10 1703 & 1803 x64

The original report as published on Mozilla's Bugzilla, by clavoillotte. 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 service creates files in a user-writable directory without impersonation, allowing junction and symbolic link redirection to arbitrary paths.

Impact

An unprivileged user could escalate to SYSTEM privileges by creating and loading a malicious DLL.

What the attacker needed

Local unprivileged user account; Windows 10 x64

How it was found

  1. Create a junction from the expected updates directory to the RPC Control object directory.
  2. Create an object manager symbolic link for the temporary file name pointing to a user-writable location.
  3. Create an object manager symbolic link for the final file name pointing to the target path in System32.
  4. Start the MozillaMaintenance service with the trap directory to create the file as SYSTEM.
  5. Replace the content of the created file with a malicious DLL.
  6. Start the service again to load the DLL and execute the payload as SYSTEM.

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 background service that runs with high privileges creates files in a folder that a normal user can control. By replacing that folder with a special link, the user can trick the service into creating files anywhere, including system folders, and then use that to gain full control of the computer.

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