DLL Hijacking - Firefox installer on Windows 7
The Firefox and Thunderbird installers on Windows 7 load a DLL named RpcRtRemote.dll or dwmapi.dll from a location the attacker can control. If an attacker places a malicious DLL with that name where the installer looks, running the setup executes the attacker's code with the user's privileges.
Originally disclosed on Mozilla
- Fixed in 7 months
- Paid in 7 months
- Disclosed after 7 months
Created attachment 8814324
fake trojan DLL. Show the msg, no harm.
+++ This bug is recurrence of Bug #883165 and Bug #811557 and Bug #792106 +++
Windows 7 64-bit
Firefox/50.0
Steps to reproduce:
1.The attacker will let the target download the trojan DLL named "RpcRtRemote.dll" or "dwmapi.dll".
2.The Target download the Installer of Firefox or Thunderbird .
3.When the user runs Setup, arbitrary code is executed.
Actual results:
Arbitrary code is executed with the authority of the user who executed setup.
Expected results:
The installer should not load the trojan dll.
What the report shows
The target is the Firefox installer on Windows, and the report is filed against the Firefox installer component of the Mozilla program. The researcher reports a DLL hijacking issue: the installer loads a DLL from a location an attacker can control, so running Setup executes attacker-supplied code.
The report states the environment as Windows 7 64-bit with Firefox/50.0, and notes that the issue is a recurrence of earlier bugs (Bug #883165, Bug #811557 and Bug #792106).
The steps to reproduce are given as:
- The attacker will let the target download the trojan DLL named "RpcRtRemote.dll" or "dwmapi.dll".
- The Target download the Installer of Firefox or Thunderbird .
- When the user runs Setup, arbitrary code is executed.
The attachment is described as a fake trojan DLL that shows a message and does no harm:
fake trojan DLL. Show the msg, no harm.
The actual result is that arbitrary code is executed with the authority of the user who executed setup. The expected result is that the installer should not load the trojan DLL. The report gives no bounty figure and no fix details; the platform records the severity as high and the weakness as privilege escalation, disclosed on 2017-06-22.
Root cause
The report does not state the cause; it only says the installer should not load the trojan DLL. When a process loads a library by name alone, the loader searches a set of directories, and if one of those directories is writable by the attacker, a planted file with the expected name is loaded instead of the legitimate one. The two names in the report, RpcRtRemote.dll and dwmapi.dll, are the names the attacker plants. The report does not say which search path the planted file was placed in, so the exact directory is not established here.
Impact
As described, the consequence is code execution with the authority of the user who ran Setup. The code runs with the authority of the user who ran Setup. The report does not claim escalation beyond the running user's rights, and the demonstration DLL only displays a message.
How this kind of bug works
On Windows, when a module is loaded by name, the loader resolves it through a search order that includes the directory of the executable, the current working directory, the system directories and directories listed in the PATH environment variable. Any location in that order that a lower-privileged user can write to becomes a planting ground. A classic variant is the current working directory: a user who opens a document or runs an installer from a folder they control causes the process to look there first. Another variant is a missing dependency: the application expects a DLL that is not present on the system, and the loader falls through to a writable directory.
Installers are attractive because they often run elevated, so a hijack during setup can yield code at the installer's privilege level. The defence is to load libraries from absolute, trusted paths, to use APIs that restrict the search (for example loading with a full path or with search flags that exclude the current directory), and to ensure the installer's working directory and any temporary extraction directory are not attacker-writable. Application whitelisting and safe DLL search mode reduce exposure but do not replace correct loading.
How to test for it
- Identify the executable under test and the DLLs it loads. Static inspection of the import table and dynamic tracing of module loads during a normal run both help. Tools that log loaded modules with their full paths are the practical way to see which names are resolved rather than pinned.
- For each name resolved from a relative or search-path location, determine whether the resolved directory is writable by a low-privileged user. The current working directory, the user's profile, temporary folders and any directory the installer extracts into are the usual candidates.
- Place a harmless test DLL with the expected name and export in the candidate directory, run the application from that context, and observe whether your code is loaded. A message box or a log line is enough to prove execution; do not use anything destructive.
- Repeat with the process started from a different working directory and with the file placed in each search location in turn, so you can state precisely which path is abused.
A positive result is a controlled DLL being loaded and executed by the target process. Common false positives are a DLL that is loaded but whose code never runs, a load that only succeeds because the tester already had administrator rights, and a hit that depends on a directory the attacker could not actually write to in a real scenario. Confirm writability from the low-privileged context, not from an elevated shell.
How it is fixed
The standard fixes are to load every dependency from a fully qualified trusted path, to use loader flags that remove the current directory and other writable locations from the search, to avoid depending on DLLs that may be absent, and to run the installer with a working directory and extraction path that ordinary users cannot write to. Where a dependency is optional, the code should handle its absence rather than letting the loader search for it.
Hunting notes
This class hides in installers, updaters, service binaries and anything that runs elevated. Recon signals include executables that import libraries by bare name, installers that extract to user-writable temporary directories, and applications that expect DLLs not present on a clean system. State the privilege level the code runs at, and keep the proof minimal so the triager can reproduce it quickly.
What happened, in plain words
This report is about the installer for Firefox on Windows. An installer is the program you download and run to put an application on your computer. The researcher found that the installer could be tricked into running code that did not come from Mozilla.
The trick is called DLL hijacking. A DLL is a file full of ready-made code that a program loads and uses, a bit like a recipe book a cook opens while working. Normally the program opens the official copy. If an attacker can put a file with the same name somewhere the program looks, the program may open the attacker's copy instead.
The report says the attacker gets the target to download a fake DLL named RpcRtRemote.dll or dwmapi.dll. The target then downloads the Firefox or Thunderbird installer, and when they run Setup, the attacker's code runs. The attachment is described as a fake trojan DLL that only shows a message and does no harm:
fake trojan DLL. Show the msg, no harm.
That harmless payload matters: it proves the code ran without damaging anything.
The report lists three steps to reproduce:
- The attacker will let the target download the trojan DLL named "RpcRtRemote.dll" or "dwmapi.dll".
- The Target download the Installer of Firefox or Thunderbird .
- When the user runs Setup, arbitrary code is executed.
Step 1 is the planting: the attacker gets the target to download the fake DLL. Step 2 is ordinary user behaviour, downloading the installer. Step 3 is the moment of failure: Setup loads the fake file and runs it.
The actual result is that arbitrary code is executed with the authority of the user who ran Setup. "Arbitrary code" means any code the attacker chose, not just the message box in the demonstration. "With the authority of the user" means the code runs with the same permissions as that person. The code runs with the same permissions as the user who ran Setup. The expected result is simple: the installer should not load the trojan DLL.
The report states the environment as Windows 7 64-bit with Firefox/50.0, and notes that this is a recurrence of earlier bugs (Bug #883165, Bug #811557 and Bug #792106). In other words, the same kind of problem had been reported before, and it came back. The platform records the severity as high and the weakness as privilege escalation, disclosed on 2017-06-22. No bounty figure or fix detail is given.
In general, how this kind of bug works
When a Windows program needs a DLL, it usually asks for it by name only, for example dwmapi.dll, without saying which folder it lives in. Windows then searches a list of folders in a fixed order until it finds a file with that name. This is like asking a assistant to fetch "the blue folder" without saying which shelf, so they check the shelves in a set order and stop at the first match.
If any folder early in that order can be written to by an ordinary user, an attacker can drop a file with the expected name there. Windows finds it first and loads it. The program never notices the difference.
Installers are especially attractive targets because they often run with elevated rights. A hijack during setup can therefore give the attacker code at the installer's permission level. The report itself does not claim escalation beyond the running user's rights, and the demonstration DLL only displays a message.
The report does not say which folder the planted file was placed in, so the exact search location is not established here.
The usual defences are to load libraries from absolute, trusted paths, to use loading options that keep writable folders out of the search, and to make sure the installer's working folder and any temporary extraction folder cannot be written to by ordinary users. Application whitelisting and safe DLL search mode reduce exposure but do not replace correct loading.
If you want to test for this kind of issue, the practical approach is:
- Find out which DLLs the program loads and whether it names them by bare name or by full path. Tools that log loaded modules with their full paths show this.
- For each name resolved through a search path, check whether an ordinary user can write to the folder where it was found. The current working directory, the user's profile and temporary folders are the usual candidates.
- Put a harmless test DLL with the expected name in that folder, run the program from that context, and see whether your code is loaded. A message box or a log line is enough proof; nothing destructive is needed.
- Repeat from different working directories and with the file in each search location in turn, so you can state precisely which path is abused.
A positive result is your controlled DLL being loaded and run by the target program. Watch for false positives: a DLL that loads but whose code never runs, a load that only works because the tester already had administrator rights, and a hit that depends on a folder the attacker could not really write to. Confirm writability from the low-privileged account, not from an elevated shell.
The standard fixes are to load every dependency from a fully qualified trusted path, to use loader options that remove the current directory and other writable locations from the search, to avoid depending on DLLs that may be absent, and to run the installer with a working directory and extraction path that ordinary users cannot write to. Where a dependency is optional, the code should handle its absence rather than letting the loader search for it.
This class of bug hides in installers, updaters, service programs and anything that runs elevated. Signals worth looking for include programs that import libraries by bare name, installers that extract to user-writable temporary folders, and applications that expect DLLs not present on a clean system. State the privilege level the code runs at, and keep the proof minimal so it can be reproduced quickly.
Glossary
- DLL: a file of ready-made code that a Windows program loads and uses while it runs.
- DLL hijacking: tricking a program into loading an attacker's DLL instead of the legitimate one, usually by placing a file with the expected name in a folder the program searches.
- Installer: the program you download and run to put an application on your computer.
- Setup: the part of the installer that performs the installation when run.
- Trojan: a file that looks legitimate but carries unwanted code; here the demonstration DLL only shows a message.
- Arbitrary code execution: running code the attacker chose, rather than only what the program intended.
- Privilege escalation: gaining more permission or authority than the starting account should have.
- Authority / privilege level: the set of things an account is allowed to do; administrator accounts can do more than standard users.
- Elevated: running with higher permissions, typically administrator rights.
- Search order: the fixed list of folders Windows checks, in order, when a DLL is requested by name only.
- Working directory: the folder a program is considered to be running from, which can be included in the DLL search.
- Absolute path: a full location that names the exact folder and file, leaving no room for searching.
- Import table: the list inside a program of the libraries and functions it expects to use.
- Application whitelisting: allowing only approved programs to run.
- Safe DLL search mode: a Windows setting that changes the DLL search order to reduce hijacking risk.
- False positive: a test result that looks like a finding but is not a real, exploitable issue.
- Payload: the code an attacker wants to run; in this report, a harmless message box.