Skip to content
RCE Write-up Intermediate

DLL hijacking vulnerabilities in Nirsoft tools

The Nirsoft tools load DLLs from their own directory without validating their origin, allowing a local attacker to place a malicious DLL with the expected name. When a user runs the tool with elevated privileges, the malicious DLL is also loaded with those privileges, enabling privilege escalation.

borncity.com

Published on borncity.com

Posted on 2020-04-16 by guenni

The author, on borncity.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The applications use the default DLL search order, which includes the application's own directory, without restricting or validating the DLLs that are loaded.

Impact

A local attacker could place a malicious DLL in the tool's folder and, when the user runs the tool with elevated privileges, the DLL would execute with those privileges, potentially leading to privilege escalation.

What the attacker needed

Local access to the tool's folder; user runs the tool with elevated privileges

The fix

The developer should specify safe paths for loading system DLLs, for example by using SetDefaultDllDirectories or SetDllDirectory, to prevent loading from the application directory.

How it was found

  1. Download the Nirsoft tool and place it in a folder.
  2. Run the tool and observe warnings about DLLs being loaded from its own directory.
  3. Place a malicious DLL with the expected name in the tool's folder.
  4. Start the tool with elevated privileges; the malicious DLL is loaded and executed with those privileges.

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 write-up has not been written yet. The Original tab links to the source.

When a program starts, it often needs extra code from files called DLLs. If the program looks for these DLLs in its own folder before the safe system folder, an attacker who can put a file there can make the program run their code. If the program is started with administrator rights, the attacker's code also gets those rights.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.