MITRE ATT&CKsub-technique
T1548.003 Sudo and Sudo Caching
- Domain
- enterprise
- Tactics
- Privilege Escalation
- Platforms
- Linux, macOS
- Version
- 2.0
- Created
- 2020-01-30
Description
Adversaries may perform sudo caching and/or use the sudoers file to elevate privileges. Adversaries may do this to execute commands as other users or spawn processes with higher privileges.
Within Linux and MacOS systems, sudo (sometimes referred to as "superuser do") allows users to perform commands from terminals with elevated privileges and to control who can perform these commands on the system. The sudo command "allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments." Since sudo was made for the system administrator, it has some useful configuration features such as a timestamp_timeout, which is the amount of time in minutes between instances of sudo before it will re-prompt for a password. This is because sudo has the ability to cache credentials for a period of time. Sudo creates (or touches) a file at /var/db/sudo with a timestamp of when sudo was last run to determine this timeout. Additionally, there is a tty_tickets variable that treats each new tty (terminal session) in isolation. This means that, for example, the sudo timeout of one tty will not affect another tty (you will have to type the password again).
The sudoers file, /etc/sudoers, describes which users can run which commands and from which terminals. This also describes which commands users can run as other users or groups. This provides the principle of least privilege such that users are running in their lowest possible permissions for most of the time and only elevate to other users or permissions as needed, typically by prompting for a password. However, the sudoers file can also specify when to not prompt users for passwords with a line like user1 ALL=(ALL) NOPASSWD: ALL. Elevated privileges are required to edit this file though.
Adversaries can also abuse poor configurations of these mechanisms to escalate privileges without needing the user's password. For example, /var/db/sudo's timestamp can be monitored to see if it falls within the timestamp_timeout range. If it does, then malware can execute sudo commands without needing to supply the user's password. Additional, if tty_tickets is disabled, adversaries can do this from any tty for that user.
In the wild, malware has disabled tty_tickets to potentially make scripting easier by issuing echo \'Defaults !tty_tickets\' >> /etc/sudoers. In order for this change to be reflected, the malware also issued killall Terminal. As of macOS Sierra, the sudoers file has tty_tickets enabled by default.
Related
Subtechnique of · MITRE ATT&CK (1)
- T1548 Abuse Elevation Control Mechanism technique
Tactic · MITRE ATT&CK (1)
- TA0004 Privilege Escalation tactic
Referenced by MITRE ATT&CK · mitigates (3)
Referenced by MITRE ATT&CK · uses (9)
- S9045 BACKUPOSINT v9.0 APEX PREDATOR software (malware)
- S9042 CanisterWorm software (malware)
- S9041 TeamPCP Cloud Stealer software (malware)
- S9008 Shai-Hulud software (malware)
- G1045 Salt Typhoon group
- G0082 APT38 group
- S0279 Proton software (malware)
- S0281 Dok software (malware)
- S0154 Cobalt Strike software (malware)
Referenced by Compliance · mitigates (15)
- CIS-5.4 Restrict Administrator Privileges to Dedicated Administrator Accounts CIS Safeguard v8.1
- CIS-6.8 Define and Maintain Role-Based Access Control CIS Safeguard v8.1
- NIST-AC-16 Security and Privacy Attributes NIST 800-53 control
- NIST-AC-2 Account Management NIST 800-53 control
- NIST-AC-3 Access Enforcement NIST 800-53 control
- NIST-AC-5 Separation of Duties NIST 800-53 control
- NIST-AC-6 Least Privilege NIST 800-53 control
- NIST-CA-7 Continuous Monitoring NIST 800-53 control
- NIST-CM-2 Baseline Configuration NIST 800-53 control
- NIST-CM-5 Access Restrictions for Change NIST 800-53 control
- NIST-CM-6 Configuration Settings NIST 800-53 control
- NIST-CM-7 Least Functionality NIST 800-53 control
- NIST-IA-2 Identification and Authentication (Organizational Users) NIST 800-53 control
- NIST-RA-5 Vulnerability Monitoring and Scanning NIST 800-53 control
- NIST-SI-4 System Monitoring NIST 800-53 control
References
- https://www.cybereason.com/blog/labs-proton-b-what-this-mac-malware-actually-does cybereason osx proton
- https://blog.malwarebytes.com/threat-analysis/2017/04/new-osx-dok-malware-intercepts-web-traffic/ OSX.Dok Malware
- https://www.sudo.ws/ sudo man page 2018