Introduction to Linux: Advanced Permissions
Philipp Fruck & Pius Walter Advanced Permissions ██ Goal of this lecture • Learn how to safely elevate privileges • Understand fine-grained access control beyond classic permissions (ACLs) • Understand Linux capabilities as a safer alternative to full root access ██ Why? • Classic permissions are often not granular enough • Minimizing granted privileges reduces the security impact of bugs and exploits Introduction to Linux: Advanced Permissions 2 / 29
sudo ██ Security • sudo is typically a setuid root binary
• Runs with effective UID 0, regardless of the invoking user's privileges • Part of the system's trusted computing base • Vulnerabilities can lead to local privilege escalation • Overly permissive rules can effectively grant unrestricted root access Introduction to Linux: Advanced Permissions 3 / 29
sudo ██ Security ██ Configuration
• sudo is typically a setuid root binary • /etc/sudoers and /etc/sudoers.d/
• Runs with effective UID 0, regardless of the • Defines who can execute what, as which user
invoking user's privileges • visudo: syntax checking and file locking
• Part of the system's trusted computing base ◦ Use sudo visudo when editing!
• Vulnerabilities can lead to local privilege escalation
• Overly permissive rules can effectively grant # who where=(as_whom:as_group) options: cmd
unrestricted root access # Allow wheel group to execute any command
%wheel ALL=(ALL:ALL) ALL
# Allow command execution without password
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
Introduction to Linux: Advanced Permissions 4 / 29
sudo ██ Security ██ Configuration
• sudo is typically a setuid root binary • /etc/sudoers and /etc/sudoers.d/
• Runs with effective UID 0, regardless of the • Defines who can execute what, as which user
invoking user's privileges • visudo: syntax checking and file locking
• Part of the system's trusted computing base ◦ Use sudo visudo when editing!
• Vulnerabilities can lead to local privilege escalation
• Overly permissive rules can effectively grant # who where=(as_whom:as_group) options: cmd
unrestricted root access # Allow wheel group to execute any command
%wheel ALL=(ALL:ALL) ALL
# Allow command execution without password
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
sudo-rs: Rust implementation of sudo
• Memory safety reduces certain risks, but does not eliminate privilege-escalation risk • Shipped by Ubuntu by default as of 25.10 / 26.04 LTS • Not 1:1 compatible with original sudo!
Introduction to Linux: Advanced Permissions 5 / 29
sudo ██ Security ██ Configuration
• sudo is typically a setuid root binary • /etc/sudoers and /etc/sudoers.d/
• Runs with effective UID 0, regardless of the • Defines who can execute what, as which user
invoking user's privileges • visudo: syntax checking and file locking
• Part of the system's trusted computing base ◦ Use sudo visudo when editing!
• Vulnerabilities can lead to local privilege escalation
• Overly permissive rules can effectively grant # who where=(as_whom:as_group) options: cmd
unrestricted root access # Allow wheel group to execute any command
%wheel ALL=(ALL:ALL) ALL
# Allow command execution without password
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
sudo-rs: Rust implementation of sudo Q: Which permission does this rule grant?
ALL=(ALL:ALL) /usr/bin/vim /etc/groups • Memory safety reduces certain risks, but does not eliminate privilege-escalation risk • Shipped by Ubuntu by default as of 25.10 / 26.04 LTS • Not 1:1 compatible with original sudo!
Introduction to Linux: Advanced Permissions 6 / 29
sudo ██ Security ██ Configuration
• sudo is typically a setuid root binary • /etc/sudoers and /etc/sudoers.d/
• Runs with effective UID 0, regardless of the • Defines who can execute what, as which user
invoking user's privileges • visudo: syntax checking and file locking
• Part of the system's trusted computing base ◦ Use sudo visudo when editing!
• Vulnerabilities can lead to local privilege escalation
• Overly permissive rules can effectively grant # who where=(as_whom:as_group) options: cmd
unrestricted root access # Allow wheel group to execute any command
%wheel ALL=(ALL:ALL) ALL
# Allow command execution without password
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
sudo-rs: Rust implementation of sudo Q: Which permission does this rule grant?
ALL=(ALL:ALL) /usr/bin/vim /etc/groups • Memory safety reduces certain risks, but does not eliminate privilege-escalation risk • Read and write the file as root
• Shipped by Ubuntu by default as of 25.10 / 26.04 LTS • But also: shell via :sh
• Not 1:1 compatible with original sudo! ◦ ⚠️ Privilege escalation
Introduction to Linux: Advanced Permissions 7 / 29
run0 run0 is the systemd (>=256) native privilege escalation tool. It uses polkit instead of setuid.
Introduction to Linux: Advanced Permissions 8 / 29
run0 run0 is the systemd (>=256) native privilege escalation tool. It uses polkit instead of setuid.
██ Basic usage Similar to sudo, but you might need --via-shell
run0 id
run0 -u daemon id
run0 printenv PATH
run0 --via-shell printenv PATH
Introduction to Linux: Advanced Permissions 9 / 29
run0 run0 is the systemd (>=256) native privilege escalation tool. It uses polkit instead of setuid.
██ Basic usage ██ Sandboxing
Similar to sudo, but you might need --via-shell
# read-only except /tmp
run0 --property=ProtectSystem=strict \
run0 id --property=ReadWritePaths=/tmp \
run0 -u daemon id touch /tmp/1
run0 printenv PATH # Hide /home
run0 --via-shell printenv PATH run0 --property=ProtectHome=true ls /home
cd /tmp && !!
Introduction to Linux: Advanced Permissions 10 / 29
run0 run0 is the systemd (>=256) native privilege escalation tool. It uses polkit instead of setuid.
██ Basic usage ██ Sandboxing
Similar to sudo, but you might need --via-shell
# read-only except /tmp
run0 --property=ProtectSystem=strict \
run0 id --property=ReadWritePaths=/tmp \
run0 -u daemon id touch /tmp/1
run0 printenv PATH # Hide /home
run0 --via-shell printenv PATH run0 --property=ProtectHome=true ls /home
cd /tmp && !!
▍ run0 does not automatically make commands safe. The actual isolation depends on the systemd properties applied.
Introduction to Linux: Advanced Permissions 11 / 29
Access Control Lists (ACLs) Problem: Traditional permissions only allow control for a single owner, group and others
Solution: Access Control Lists (ACLs) let you define per-user or per-group permissions
Introduction to Linux: Advanced Permissions 12 / 29
Access Control Lists (ACLs) Problem: Traditional permissions only allow control for a single owner, group and others
Solution: Access Control Lists (ACLs) let you define per-user or per-group permissions
# Show ACLs
$ getfacl secret.txt
# Add a new user permission
$ setfacl -m u:bob:r secret.txt
# Remove an ACL entry
$ setfacl -x u:bob secret.txt
# Notice the little + sign in ls -l
$ ls -l secret.txt
-rw-r--r--+ 1 demo demo 0 Nov 10 16:19 secret.txt
Introduction to Linux: Advanced Permissions 13 / 29
Access Control Lists (ACLs) Problem: Traditional permissions only allow control for a single owner, group and others
Solution: Access Control Lists (ACLs) let you define per-user or per-group permissions
# Show ACLs $ getfacl secret.txt
$ getfacl secret.txt # file: secret.txt
# Add a new user permission # owner: alice
$ setfacl -m u:bob:r secret.txt # group: staff
# Remove an ACL entry user::rw-
$ setfacl -x u:bob secret.txt user:bob:r--
# Notice the little + sign in ls -l group::r--
$ ls -l secret.txt mask::r--
-rw-r--r--+ 1 demo demo 0 Nov 10 16:19 secret.txt other::---
Introduction to Linux: Advanced Permissions 14 / 29
Access Control Lists (ACLs) Problem: Traditional permissions only allow control for a single owner, group and others
Solution: Access Control Lists (ACLs) let you define per-user or per-group permissions
# Show ACLs $ getfacl secret.txt
$ getfacl secret.txt # file: secret.txt
# Add a new user permission # owner: alice
$ setfacl -m u:bob:r secret.txt # group: staff
# Remove an ACL entry user::rw-
$ setfacl -x u:bob secret.txt user:bob:r--
# Notice the little + sign in ls -l group::r--
$ ls -l secret.txt mask::r--
-rw-r--r--+ 1 demo demo 0 Nov 10 16:19 secret.txt other::---
Default ACLs: If set on directories, ACLs apply to all new files inside: setfacl -d -m u:bob:rw project/
💡 ACLs offer fine-grained control -> especially useful for multi-user servers. Still, they are rather hidden and rarely used. Introduction to Linux: Advanced Permissions 15 / 29
Linux Capabilities Problem: setuid root gives full root privileges -> too powerful
Solution: Linux Capabilities split root privileges into fine-grained pieces
• Each process can get only the privileges it needs
Introduction to Linux: Advanced Permissions 16 / 29
Linux Capabilities Problem: setuid root gives full root privileges -> too powerful
Solution: Linux Capabilities split root privileges into fine-grained pieces
• Each process can get only the privileges it needs
Example Capability │ What it Allows │ Example command ─────────────────────┼───────────────────────────────────────────┼────────────────────────────── CAP_NET_ADMIN │ Manage network interfaces, routing tables │ ip link set eth0 down
CAP_NET_RAW │ Use raw and packet sockets │ ping 1.1
CAP_SYS_ADMIN │ "Catch-all" - system-wide administration │ mount /dev/sda /mnt
CAP_DAC_OVERRIDE │ Bypass file read/write permission checks │ cat /root/secret.txt
CAP_SYS_TIME │ Change the system clock │ date -s "2026-11-10 12:00:00"
CAP_NET_BIND_SERVICE │ Bind to ports < 1024 │ python3 -m http.server 80
Introduction to Linux: Advanced Permissions 17 / 29
Linux Capabilities Problem: setuid root gives full root privileges -> too powerful
Solution: Linux Capabilities split root privileges into fine-grained pieces
• Each process can get only the privileges it needs
Example Capability │ What it Allows │ Example command ─────────────────────┼───────────────────────────────────────────┼────────────────────────────── CAP_NET_ADMIN │ Manage network interfaces, routing tables │ ip link set eth0 down
CAP_NET_RAW │ Use raw and packet sockets │ ping 1.1
CAP_SYS_ADMIN │ "Catch-all" - system-wide administration │ mount /dev/sda /mnt
CAP_DAC_OVERRIDE │ Bypass file read/write permission checks │ cat /root/secret.txt
CAP_SYS_TIME │ Change the system clock │ date -s "2026-11-10 12:00:00"
CAP_NET_BIND_SERVICE │ Bind to ports < 1024 │ python3 -m http.server 80
▍ As always: See man capabilities for details
Introduction to Linux: Advanced Permissions 18 / 29
Overview: The Five Capability Sets in Linux Permitted (P) This is the list of all privileges a process is allowed to have. Anything not on this list can never be obtained by the process. Introduction to Linux: Advanced Permissions 19 / 29
Overview: The Five Capability Sets in Linux Permitted (P) This is the list of all privileges a process is allowed to have. Anything not on this list can never be obtained by the process. Effective (E) The privileges that are currently active. Only these are checked by the kernel when, e.g., a program tries to access port 80 or modify system files. Introduction to Linux: Advanced Permissions 20 / 29
Overview: The Five Capability Sets in Linux Permitted (P) This is the list of all privileges a process is allowed to have. Anything not on this list can never be obtained by the process. Effective (E) The privileges that are currently active. Only these are checked by the kernel when, e.g., a program tries to access port 80 or modify system files. Inheritable (I) The privileges that can be passed on to a child process (after exec()). This allows a program to give another
program certain privileges. Introduction to Linux: Advanced Permissions 21 / 29
Overview: The Five Capability Sets in Linux Permitted (P) Bounding (B)
This is the list of all privileges a process is allowed This is the maximum limit of all possible privileges.
to have. Anything not on this list can never be obtained Once a privilege is removed, it is permanently gone, even
by the process. root cannot bring it back.
Effective (E) The privileges that are currently active. Only these are checked by the kernel when, e.g., a program tries to access port 80 or modify system files. Inheritable (I) The privileges that can be passed on to a child process (after exec()). This allows a program to give another
program certain privileges. Introduction to Linux: Advanced Permissions 22 / 29
Overview: The Five Capability Sets in Linux Permitted (P) Bounding (B)
This is the list of all privileges a process is allowed This is the maximum limit of all possible privileges.
to have. Anything not on this list can never be obtained Once a privilege is removed, it is permanently gone, even
by the process. root cannot bring it back.
Effective (E) Ambient (A)
The privileges that are currently active. Only these are Newer addition (since kernel 4.3): privileges that are
checked by the kernel when, e.g., a program tries to automatically retained when starting a new program, if
access port 80 or modify system files. the program is not setuid and the privilege is present in
both P and I. Used, for example, by containers or
Inheritable (I) systemd.
The privileges that can be passed on to a child process (after exec()). This allows a program to give another
program certain privileges. Introduction to Linux: Advanced Permissions 23 / 29
Linux Capabilities ██ View capabilities getcap /usr/bin/arping
██ Set or remove capabilities # add effective + permitted net raw capability
run0 setcap cap_net_raw+ep /usr/bin/arping
# remove net raw again
run0 setcap cap_net_raw-ep /usr/bin/arping
# remove all capabilities
run0 setcap -r /usr/bin/arping
Introduction to Linux: Advanced Permissions 24 / 29
Linux Capabilities ██ View capabilities ██ Interactively
capsh can interactively set/drop permissions
getcap /usr/bin/arping
run0 capsh --drop=cap_net_bind_service -- \
██ Set or remove capabilities -c 'python3 -m http.server 80'
# add effective + permitted net raw capability
run0 setcap cap_net_raw+ep /usr/bin/arping
# remove net raw again
run0 setcap cap_net_raw-ep /usr/bin/arping
# remove all capabilities
run0 setcap -r /usr/bin/arping
Introduction to Linux: Advanced Permissions 25 / 29
Linux Capabilities ██ View capabilities ██ Interactively
capsh can interactively set/drop permissions
getcap /usr/bin/arping
run0 capsh --drop=cap_net_bind_service -- \
██ Set or remove capabilities -c 'python3 -m http.server 80'
# add effective + permitted net raw capability ██ Revocation limitation
run0 setcap cap_net_raw+ep /usr/bin/arping
# remove net raw again • Once a process has a capability, the kernel cannot
run0 setcap cap_net_raw-ep /usr/bin/arping revoke it mid-execution
# remove all capabilities • You must terminate or restart the process to remove
run0 setcap -r /usr/bin/arping privileges
◦ Fun fact: This is different on BSD
Introduction to Linux: Advanced Permissions 26 / 29
Linux Capabilities ██ View capabilities ██ Interactively
capsh can interactively set/drop permissions
getcap /usr/bin/arping
run0 capsh --drop=cap_net_bind_service -- \
██ Set or remove capabilities -c 'python3 -m http.server 80'
# add effective + permitted net raw capability ██ Revocation limitation
run0 setcap cap_net_raw+ep /usr/bin/arping
# remove net raw again • Once a process has a capability, the kernel cannot
run0 setcap cap_net_raw-ep /usr/bin/arping revoke it mid-execution
# remove all capabilities • You must terminate or restart the process to remove
run0 setcap -r /usr/bin/arping privileges
◦ Fun fact: This is different on BSD
▍ More about ACLs and Linux Capabilities: https://media.ccc.de/v/why2025-192-linux-permissions-and-hardening
Introduction to Linux: Advanced Permissions 27 / 29
Exercise ██ Capabilities ██ Access Control Lists
Let's use /usr/bin/tar as an example: 1. Create a file and set restrictive permissions
1. Check if it currently has any capabilities
2. Give it a test capability (CAP_DAC_READ_SEARCH) touch project.txt
chmod 600 project.txt
sudo setcap cap_dac_read_search+ep /usr/bin/tar
getcap /usr/bin/tar 2. Add read access for another user (replace <user>)
3. Try reading a file you normally couldn't (as sudo setfacl -m u:<user>:r project.txt
non-root) getfacl project.txt
tar -cvf /tmp/test.tar /tmp/rootfile.txt 3. Verify that <user> can now read the file even
though group/others cannot.
4. Remove the ACL entry again 4. ⚠️ Important: Remove the capability again with sudo
setcap -r /usr/bin/tar
5. What could go wrong if tools like tar permanently sudo setfacl -x u:<user> project.txt
kept this capability?
Introduction to Linux: Advanced Permissions 28 / 29
Thank you! Thank you for your attention! Don't forget the feedback in Moodle please! Introduction to Linux: Advanced Permissions 29 / 29