Privilege Escalation via Mozilla Maintenance Service if Firefox is Installed to a Writable Location
The Firefox installer does not restrict permissions on a custom installation directory, so if the user chooses a writable location, the Firefox folder remains writable. During an update, the Mozilla Maintenance Service copies and executes a binary from that writable folder with SYSTEM privileges, allowing an attacker who can write to the folder to replace that binary and escalate privileges.
Originally disclosed on Mozilla
- Fixed in 4 days
- Paid in 49 days
- Disclosed after 4 days
Created attachment 9086436
poc.zip
The full Mozilla Firefox Installer allows a user to choose a custom install location. (Personally I have used this to install firefox on my secondary hard drive at D:\Firefox.)
The installer doesn't adjust the rights of the created firefox directory, so for example, if the user chooses a writable location the firefox directory is writable after the installation.
A writable firefox directory can be exploited to gain system rights via the mozilla maintenance service. During an update the maintenanceservice.exe from the firefox directory is copied to <mozilla-maintenance-service-directory>/maintenanceservice_tmp.exe and executed from there with system rights. By manipulating the maintenanceservice.exe during a update it is possible to escalate privileges.
POC (tested on Windows 10):
1.) install firefox via the full installer (http://archive.mozilla.org/pub/firefox/releases/68.0.2/win32/en-US/Firefox%20Setup%2068.0.2.exe) to a writable directory for example D:\Firefox
2.) unzip attached zip
3.) download https://archive.mozilla.org/pub/firefox/releases/68.0.2/update/win64/en-US/firefox-68.0.2.complete.mar to <unzipped-direcory>/update/0/update.mar
4.) change the firefox paths in copyloop.bat and mozupdate.bat to the firefox install location
5.) change the path to the update/0 directory in mozupdateservicetest.bat to your path
6.) start copyloop.bat (this will overwrite the maintenanceservice.exe in the firefox directory with a test.exe during the update) and mozupdate.bat (will run the update)
7.) After the update finished you will see that:
- the test.exe was copied to <mozilla-maintenance-service-directory>/maintenanceservice_tmp.exe.
- this maintenanceservice_tmp.exe is running as SYSTEM user
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 installer does not set restrictive permissions on the chosen installation directory, and the maintenance service later executes a binary from that user-writable location with SYSTEM rights.
Impact
An attacker who can write to the Firefox installation directory could gain SYSTEM privileges by replacing the maintenance service executable during an update.
What the attacker needed
Firefox installed to a writable location; Attacker can write to that location; An update is triggered
How it was found
- Install Firefox using the full installer into a writable directory.
- Unzip the provided proof-of-concept archive.
- Download the update file and place it in the expected update folder.
- Edit the batch scripts to point to the Firefox installation and update folder.
- Run the script that repeatedly overwrites the maintenance service executable during an update, and run the update script.
- Observe that the replaced executable is copied to the maintenance service directory and runs 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.
When you install Firefox, you can pick where it goes. If you pick a folder that normal users can write to, then any program running as your user can change files in that folder. The Mozilla Maintenance Service, which runs with high privileges to apply updates, copies a file from that folder and runs it as the system user. So an attacker who can write to the folder can swap that file for their own program and get 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.