Very High
CVE-2021-3156 "Baron Samedit"
Add Reference
Description
URL
Type
CVE-2021-3156 "Baron Samedit"
MITRE ATT&CK
Collection
Command and Control
Credential Access
Defense Evasion
Discovery
Execution
Exfiltration
Impact
Initial Access
Lateral Movement
Persistence
Privilege Escalation
Description
Sudo before 1.9.5p2 has a Heap-based Buffer Overflow, allowing privilege escalation to root via “sudoedit -s” and a command-line argument that ends with a single backslash character.
Add Assessment
Ratings
-
Attacker ValueVery High
-
ExploitabilityVery High
Technical Analysis
Sudo is vulnerable to a local privilege escalation that enables any local user to gain root privileges. This is due to a heap-based buffer overflow when unescaping backslashes in the command’s arguments. This vulnerable code has been introduced in July 2011. According to the advisory, legacy versions from 1.8.2 to 1.8.31p2 and stable versions from 1.9.0 to 1.9.5p1 are vulnerable in their default configurations. Note that the local user password is not required to successfully exploit this vulnerability.
The exploitation is done by invoking “sudoedit -s” command to reach the vulnerable code and do an out-of-bounds write in heap memory. The security researchers were able to exploit this vulnerability and get a shell as root using 3 different methods. One of them, which seems to be the easiest and the most reliable, is demo’ed in this video.
I couldn’t find any PoC available, but there are enough technical details in the advisory to write an exploit. It is a critical bug and sudo should be patched immediately. It is very likely a working exploit will be publicly available soon.
Ratings
-
Attacker ValueVery High
-
ExploitabilityVery High
Technical Analysis
Proof of Concept
https://github.com/lockedbyte/CVE-Exploits/tree/master/CVE-2021-3156
Ratings
-
Attacker ValueVery High
-
ExploitabilityVery High
Ratings
-
Attacker ValueLow
-
ExploitabilityLow
CVSS V3 Severity and Metrics
General Information
References
Advisory
Miscellaneous
Additional Info
Technical Analysis
Description
On Tuesday, January 26, 2021, the Qualys Research Team published a blog post on CVE-2021-3156, a privilege escalation vulnerability in the sudo
command that enables any local user to gain root privileges without using a password, even if the user is not listed in the sudoers
file. The vulnerability arises from a heap-based buffer overflow when unescaping backslashes in a supplied command’s arguments. The vulnerable code was introduced in July 2011 and affects most Linux-based operating systems. See the project maintainers’ advisory on the vulnerability for further details.
Affected Products
According to the advisory, legacy versions of sudo
from 1.8.2 to 1.8.31p2 and stable versions from 1.9.0 to 1.9.5p1 are vulnerable in their default configurations. Depending on the Linux distribution, the version number might be different. Please check the Guidance section for details.
Rapid7 analysis
CVE-2021-3156 is a local privilege escalation vulnerability, which means an attacker requires existing access to a target (such as through remote code execution) in order to exploit the bug. Exploitation is achieved by invoking the sudoedit -s
command to reach the vulnerable code and perform an out-of-bounds (OOB) write in heap memory. Upon successful exploitation, the attacker would gain root access, resulting in full compromise of the system.
At the time of this writing, a crash PoC is available from Qualys. Rapid7 researchers have reliably reproduced the crash using the supplied PoC. The advisory contains enough technical detail to develop the PoC into an exploit. Researchers will have to bypass any memory protections in place, though the bug allows for a great amount of control over the OOB write, reducing the burden of exploitation. It is only a matter of time before exploits begin to surface.
Guidance
Rapid7 recommends that sudo
users update to version 1.9.5p2 immediately. The legacy release stream 1.8.x has not yet received a critical bug fix for CVE-2021-3156. There is no effective mitigation for this vulnerability. Patched versions are listed below.
Official maintainer:
- Stable release has been patched in version 1.9.5p2: https://github.com/sudo-project/sudo/releases/tag/SUDO_1_9_5p2
- Legacy release has not been patched already: https://www.sudo.ws/legacy.html
Linux distributions:
- Ubuntu: https://ubuntu.com/security/CVE-2021-3156
- Debian: https://security-tracker.debian.org/tracker/CVE-2021-3156
- RHEL: https://access.redhat.com/security/cve/CVE-2021-3156
- Fedora: https://bodhi.fedoraproject.org/updates/FEDORA-2021-2cb63d912a
- Arch Linux: https://security.archlinux.org/CVE-2021-3156
- Gentoo: https://security.gentoo.org/glsa/202101-33
References
Report as Exploited in the Wild
What do we mean by "exploited in the wild"?
By selecting this, you are verifying to the AttackerKB community that either you, or a reputable source (example: a security vendor or researcher), has observed an active attempt by attackers, or IOCs related, to exploit this vulnerability outside of a research environment.
A vulnerability should also be considered "exploited in the wild" if there is a publicly available PoC or exploit (example: in an exploitation framework like Metasploit).