Closed Bug 961676 (CVE-2014-1520) Opened 6 years ago Closed 6 years ago

Unsafe temp directory usage in maintenservice_installer.exe lead to possible privilege escalation


(Toolkit :: NSIS Installer, defect)

Windows Phone 7
Not set



Tracking Status
firefox28 --- wontfix
firefox29 + verified
firefox30 + verified
firefox31 + verified
firefox-esr24 + verified
b2g18 --- unaffected
b2g-v1.1hd --- unaffected
b2g-v1.2 --- unaffected
b2g-v1.3 --- unaffected
b2g-v1.3T --- unaffected
b2g-v1.4 --- unaffected
b2g-v2.0 --- unaffected


(Reporter: hofusec, Assigned: bbondy)


(Keywords: csectype-priv-escalation, sec-high, Whiteboard: [adv-main29+][adv-esr24.5+] local privilege escalation)


(2 files)

Attached file poc.rar
I have seen the following behavior with windows 7 32bit and the maintenservice_installer.exe which is for example executed during an update process with the mozilla maintenance service.

The installer creates during execution a file with the following name format and executes the file:

C:\Windows\Temp\ns{random character a-z generated with GetTickCount%26}{16bit hex value from GetTickCount()}.tmp\ns{16bit hex value from GetTickCount()}.tmp

For example: C:\Windows\Temp\nscFF1B.tmp\nsFFCA.tmp

It is possible to force the executable to load dlls from the current directory with an „executable.local” dirctory in the directory of the executable (windows specific feature). 
For the example with a ”C:\Windows\Temp\nsFF1B.tmp\nsFFCA.tmp.local” directory, the dlls loaded from the nsFFCA.tmp executable will be first searched in the nsFFCA.tmp.local directory, then in the nscFF1B.tmp directory and at least at the system path.

Because the temp directory is writable for normal users and the path is easy to  guess because of the use of GetTickCount() there is a privilege escalation vulnerability.


To try out the poc you need firefox 26.0 with the maintenance service installed and a 32bit windows.  I used windows 7. My poc tries to force the executable to load a fake mcrvrt.dll from the directory to start a calc.exe with system rights. Because of GetTickCount() this attack is timing dependent.


1.) download poc and extract the files
2.) copy the updater.exe from the firefox directory to the poc/update directory
3.) download and save the file as update.mar in the poc/update directory
4.) alter the paths in update.bat to your paths
5.) start poc.exe
6.) start update.bat
7.) wait for output from poc.exe
8.) check for calc.exe
9.) if no calc.exe found, start update again

With windows 7 64bit no executable is loaded in the temp directory, so this will not work but maybe there is another way. Maybe the source of this vulnerability is in the nullsoft installer system and not in the script to create the installer, so maybe it's a general nsis problem.
Flags: needinfo?(robert.bugzilla)
I've asked Brian to take a look.
Flags: needinfo?(robert.bugzilla)
I'm not sure why the maintenservice_installer.exe installer does this, it's definitely not something we do manually in NSIS script.  I think the safest way to get around this is to not run a binary created from an NSIS script and to just do the steps manually inside updater code.
Ever confirmed: true
Whiteboard: local privilege escalation
Group: toolkit-core-security
Hey, Brian, can you take this? I know there are several issues around maintenance service.
Assignee: nobody → netzen
(In reply to Al Billings [:abillings] from comment #3)
> Hey, Brian, can you take this? I know there are several issues around
> maintenance service.

Yes, which issues?
I don't recall. Stream of bug consciousness says you and Rob have looked at / are working on various issues with the installer and maintenance service security.
I ask because we're considering removing the pref for whether or not to use the maintenance service in another bug.  We consider the maintenance service to be more secure in some cases.

You mentioned that you know of several issues around the maintenance service, and if that is the case, please ping me on them because they will factor into the above decision. 

(In reply to Al Billings [:abillings] from comment #5)
> I don't recall. Stream of bug consciousness says you and Rob have looked at
> / are working on various issues with the installer and maintenance service
> security.

The installer and the maintenance service are very different things.
rstrong and I discussed this bug.

- Removing the maintenance service pref probably wouldn't have any benefit because they could disable the maintenance service if they really wanted to in other ways like simulating failed updates so it falls back to not using the service.
- The only known way to fix this, is very risky and would probably affect update uptake in general.
- If we implemented this bug the secure way, and accepted that there would be a decrease in update uptake, this would introduce a new security issue that someone could easily stop updates from happening by simply opening a handle to the firefox update directory.  In which case we wouldn't be able to lock it and would fail the updates.
- We should check on new OS releases to make sure no new dlls are being injected to updates.

Since this bug has no known exploits, we think it is better to close as WONTFIX.  
The only known way to fix this in general is to do 1-off fixes like we've been doing.

If there is any disagreement please feel free to re-open for discussion.
Closed: 6 years ago
Resolution: --- → WONTFIX
That comment was meant for bug 884806
Resolution: WONTFIX → ---
Attached patch patch v1.Splinter Review
Does the maintenance service upgrade via the same method as the maintenance service installer. I.e. copies the installdir's maintenance service to maintenanceservice_tmp.exe alongside the maintenance service. Then executes it with the upgrade command line param.

It doesn't update the registry with new maintenance service info on upgrades, but this info is not correct anyway already.  Cleanup for not showing the version in registry should be done in a different bug that is reported about that (it exists already)
Attachment #8397948 - Flags: review?(robert.strong.bugs)
Attachment #8397948 - Flags: review?(robert.strong.bugs) → review+
Comment on attachment 8397948 [details] [diff] [review]
patch v1.

Approval request for landing on Oak for testing and on mozilla-inbound.

[Security approval request comment]
How easily could an exploit be constructed based on the patch?
Hard to tell what the change is for.

Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
I don't think so.

Which older supported branches are affected by this flaw?
All since the maintenance service in bug 481815

If not all supported branches, which bug introduced the flaw?

Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
Backports should be the same

How likely is this patch to cause regressions; how much testing does it need?
Attachment #8397948 - Flags: sec-approval?
Comment on attachment 8397948 [details] [diff] [review]
patch v1.

sec-approval+. Let's get this on Aurora, Beta, and ESR24 if it works fine on trunk.
Attachment #8397948 - Flags: sec-approval? → sec-approval+
Comment on attachment 8397948 [details] [diff] [review]
patch v1.

[Approval Request Comment]
Bug caused by (feature/regressing bug #): 481815
User impact if declined: local privilege escalation attacks can be exploited due to nsis
Testing completed (on m-c, etc.): Will land later today, after a couple days of updates it'll be safe. Manually tested on Oak.
Risk to taking this patch (and alternatives if risky): low
String or IDL/UUID changes made by this patch: none.
Attachment #8397948 - Flags: approval-mozilla-esr24?
Attachment #8397948 - Flags: approval-mozilla-beta?
Attachment #8397948 - Flags: approval-mozilla-aurora?
Attachment #8397948 - Flags: approval-mozilla-esr24?
Attachment #8397948 - Flags: approval-mozilla-esr24+
Attachment #8397948 - Flags: approval-mozilla-beta?
Attachment #8397948 - Flags: approval-mozilla-beta+
Attachment #8397948 - Flags: approval-mozilla-aurora?
Attachment #8397948 - Flags: approval-mozilla-aurora+
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
Group: toolkit-core-security
Whiteboard: local privilege escalation → [adv-main29+][adv-esr24.5+] local privilege escalation
QA Contact: kamiljoz
Alias: CVE-2014-1520
I've reproduced the original issue using the STR and the POC in comment #0 (Win 7 x86 using FF 26). I noticed that the calc.exe was runing under maintenanceservice_installer.exe using session 0. (used Process Explorer)

* Nightly:
- build:
- mar:

* Aurora:
- build:
- mar:

- build: Setup 29.0b9.exe
- mar:

* ESR 24:
- build: Setup 24.5.0esr.exe
- mar:

Went through all of the above builds using the STR and the POC from comment #0 several times (5x on each build) and couldn't reproduce the original issue. maintenanceservice_installer.exe is launched using session 0 and then updater.exe right beneath it. The maintenanceservice_installer.exe process than disappears and calc.exe doesn't launch.
Flags: sec-bounty?
Flags: sec-bounty? → sec-bounty+
Group: core-security
You need to log in before you can comment on or make changes to this bug.