T1574.007

Path Interception by PATH Environment Variable

Adversaries may intercept execution by placing a malicious binary in an earlier directory of the PATH environment variable than the legitimate binary. When a program calls another program without specifying its full path, the OS searches PATH entries sequentially and executes the first matching binary found. On Windows, if an adversary creates C:\evil\net.exe and the PATH includes C:\evil before C:\Windows\System32, the malicious net.exe runs instead of the legitimate one. DarkGate abused this by setting HKCU\Environment\windir to a malicious path, causing DiskCleanup scheduled tasks to execute its payload. On Linux/macOS, modifying ~/.bashrc, /etc/profile, or /etc/paths.d achieves similar results. PowerSploit and Empire include PATH interception modules for privilege escalation.

Microsoft Sentinel / Defender
kusto
let SuspiciousPathChanges = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has "Environment"
| where RegistryValueName in~ ("PATH", "Path", "windir", "SystemRoot", "TEMP", "TMP")
| where not(InitiatingProcessFileName in~ ("msiexec.exe", "setup.exe", "svchost.exe", "services.exe"))
| project Timestamp, DeviceName, AccountName, RegistryKey, RegistryValueName, RegistryValueData, InitiatingProcessFileName;
SuspiciousPathChanges
| join kind=leftouter (
    DeviceProcessEvents
    | where Timestamp > ago(24h)
    | where FolderPath !has "C:\\Windows\\"
    | where FolderPath !has "C:\\Program Files"
    | project DeviceId, ProcessId, FileName, FolderPath, AccountName
) on DeviceId
| project Timestamp, DeviceName, AccountName, RegistryKey, RegistryValueName, RegistryValueData, InitiatingProcessFileName
| sort by Timestamp desc
high severity medium confidence

Data Sources

Windows Registry: Registry Key Modification Process: Process Creation Microsoft Defender for Endpoint

Required Tables

DeviceRegistryEvents DeviceProcessEvents

False Positives

  • Software installers legitimately adding their installation directory to the PATH variable
  • Developer tools (Node.js, Python, Go, Rust toolchain) adding binary directories to PATH during installation
  • Enterprise configuration management tools (Ansible, Chef, Puppet) modifying PATH as part of software provisioning
  • Virtual environment tools (virtualenv, conda) that modify PATH to prioritize their own Python interpreter

Unlock Pro Content

Get the full detection package for T1574.007 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections