PRIMARY CATEGORY → LINUX PRIVESC

Theory

Capability Values
Sets

e, p & i

SETDESCRIPTION
Effective ( e )Currently enabled capabilities for the process
Permitted ( p )*Maximum set of capabilities for the process
Inheritable ( i )Capabilities that can be inherited by child processes
Operators

= & +

OPERATORDESCRIPTION
=epEnabled for the Effective ( e ) and Permitted ( p ) sets. It also disables the Inheritable ( i ) set
+epAdd the given capability to the Effective ( e ) and Permitted ( p ) sets, without altering the Inheritable ( i ) set
Sensitive Capabilities
CAPABILITYDESCRIPTION
cap_sys_adminPerform actions with admin privileges ( e.g. Modify system files, change system settings… )
cap_sys_chrootChange the root directory for the current process, allowing it to access any file and directory
cap_sys_traceAttach and debug other processes, allowing it to gain access to sensitive information
cap_sys_niceRaise or lower the process priority, potentially allowing it to gain access to restricted resources
cap_sys_timeModify the System Clock, so it can modify timestamps and so on
cap_resourceModify system resource limits, such as the maximum number of open FD
cap_sys_moduleLoad and unload kernel modules, potentially allowing it to gain access to sensitive data
cap_net_bind_serviceBind to network ports, allowing it to gain access to sensitive information
Privesc Capabilites
CAPABILITYDESCRIPTION
cap_setuidThe given process is able to set its effective user ID
cap_setgidThe given process is able to set its effective group ID
cap_sys_adminPerform actions with admin privileges ( e.g. Modify system files, change system settings… )
cap_dac_overrideAllows bypassing of file read, write and execute permissions check

Enumeration

getcap -r / 2> /dev/null

Abuse

CAP_DAC_OVERRIDE

Imagine we land on a target through a reverse shell as a non-privileged user, then we initialize our enumeration process in order to achieve a quick privilege escalation

We start by listing the system binaries with an assigned capability and its corresponding sets

This time there is a binary with the cap_dac_override capability set, which allows the process to bypass file permissions such as read, write and execute for the given resource

The binary in question is a text editor, namely vim.basic

Therefore, we could edit a file such as /etc/passwd and delete the x in the second column of the row corresponding to the ROOT user, so that we can subsequently use the su command without being asked for a password

/usr/bin/vim.basic /etc/passwd
su -