Skip to content
RCE Write-up Beginner

DLL Hijacking – Finding Vulnerabilities In pestudio 9.52

PEStudio 9.52 attempts to load the DLL sensapi.dll from its own directory before falling back to System32, and because that directory is writable, an attacker can place a malicious DLL there to execute arbitrary code when the application starts.

Matei Josephs Follow

Published on securitycafe.ro

Lately, I have reported multiple DLL Hijacking vulnerabilities. These are quite straightforward, yet quite impactful.

Matei Josephs, on securitycafe.ro

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 application loads a DLL by name without specifying its full path, so Windows searches the application's own directory first, which is writable by the user.

Impact

An attacker who can write to the PEStudio installation folder could execute arbitrary code with the privileges of the user running PEStudio; the author notes this is not a privilege escalation because PEStudio is not normally run as admin.

What the attacker needed

Write access to the PEStudio installation folder; ability to place a file there; victim runs PEStudio

The fix

The application should specify full paths when loading DLLs, or otherwise ensure that DLLs are loaded only from trusted, non-writable locations.

How it was found

  1. Run Procmon with filters to show DLL loads by pestudio.exe that result in 'NAME NOT FOUND'.
  2. Start PEStudio and observe which DLLs are attempted from the application directory and then loaded from System32.
  3. Pick sensapi.dll as the target and confirm the search order in Procmon.
  4. Create a malicious DLL that exports the same functions as the original sensapi.dll, using a .def file generated from the original.
  5. Place the malicious DLL in the PEStudio folder and rename it to sensapi.dll.
  6. Launch pestudio.exe and observe that the malicious DLL is loaded and its code runs.

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 Windows program starts, it often needs extra code files called DLLs. Windows looks for these files in several folders, starting with the folder where the program itself sits. If a program asks for a DLL by name only, and an attacker can put a fake DLL with that name in the program's folder, the program will load the attacker's code instead of the real one. This is called DLL hijacking.

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.