Maintenance Service updater PatchFile file manipulation
The updater's PatchFile::Execute uses an attacker-controlled callback path to load a source file when the path is shorter than the original file's path and has the same filename. This allows manipulation of files in the Firefox directory, including maintenanceservice.exe, leading to privilege escalation to SYSTEM during a partial update.
Originally disclosed on Mozilla
- Fixed in 41 days
- Paid in 2 months
- Disclosed after 41 days
Created attachment 8848862
poc.up.zip
During a partial update some files are updated by reading the old file as a source file and do some modifications to it. A vulnerability exists because under certain conditions instead of the path of the original file in the firefox installation directory the attacker chosen callback parameter path is used for loading the source file (see PatchFile::Execute in updater.cpp). The conditions are that the callback parameter path must have the length <path of original file>-1 and has to point to a file with the same name as the original file.
This can be used to manipulate a file in the firefox directory and further to escalate privileges during a partial update with the maintenance service by manipulating the maintenanceservice.exe which will be executed with system rights during an update.
Steps to reproduce (tested with windows 7 64bit):
1.) install firefox 51 from https://ftp.mozilla.org/pub/firefox/releases/51.0.1/win32/en-US/Firefox%20Setup%2051.0.1.exe to C:\Program Files (x86)\Mozilla Firefox
2.) create a C:\updatework directory and download https://ftp.mozilla.org/pub/firefox/releases/52.0/update/win32/en-US/firefox-51.0.1-52.0.partial.mar as update.mar to it
3.) download and extract poc.up.zip
4.) create a C:\a directory and copy 123.dll (payload which executes calc.exe) from the poc directory to it
5.) create a C:\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa directory and copy maintenanceservice.exe (manipulated to load the 123.dll) from the poc directory to it
6.) execute poc.bat
Some time after executing poc.bat you will see a calc.exe running with system rights in the process list.
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 updater fails to validate that the callback path points to the intended file within the installation directory, allowing path substitution when the path length condition is met.
Impact
An attacker could manipulate files in the Firefox directory and escalate privileges to SYSTEM during a partial update by replacing maintenanceservice.exe.
What the attacker needed
Windows 7 64-bit (tested); Firefox 51 installed in default location; Ability to create directories and files; Partial update triggered
How it was found
- Install Firefox 51 to the default Program Files directory.
- Create a working directory and download the partial update MAR file as update.mar.
- Download and extract the proof-of-concept archive.
- Create a short-named directory and place a malicious DLL payload in it.
- Create another short-named directory and place a manipulated maintenanceservice.exe that loads the DLL.
- Execute the provided batch file; after some time, a calculator process runs with system rights.
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.
The Firefox updater sometimes modifies existing files by reading them from a path given by a callback parameter. If an attacker can control that path and make it point to a file with the same name but in a shorter directory, the updater will use the attacker's file instead of the real one. This lets the attacker replace a critical program that runs with high privileges, so they can run their own code as the system administrator.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.