CVE-2021-3156

HIGH(7.8)KEVLikely Exploited

Sudo Heap-Based Buffer Overflow Vulnerability

Description

CVE-2021-3156, known as "Baron Samedit," is a heap-based buffer overflow vulnerability in Sudo that allows any local user to escalate privileges to root without requiring a valid password. The vulnerability has existed in Sudo for nearly 10 years, affecting versions 1.8.2 through 1.9.5p1, and is exploitable on default installations of major Linux distributions. It was added to CISA's Known Exploited Vulnerabilities (KEV) catalog, confirming active exploitation. With an EPSS score of 96.8% (99.8th percentile), this is one of the most significant local privilege escalation vulnerabilities discovered in recent years.

KEV Information

Vendor
Sudo
Product
Sudo
Date Added
April 6, 2022
Due Date
April 27, 2022
Required Action
Apply updates per vendor instructions.

CVSS Score

Vector String
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HOpen in Calculator
Attack Vector
LOCAL
Attack Complexity
LOW
Privileges Required
LOW
User Interaction
NONE
Scope
UNCHANGED
Confidentiality Impact
HIGH
Integrity Impact
HIGH
Availability Impact
HIGH
Exploitability Score
1.8
Impact Score
5.9

CWEs

Affected Products

VendorProductVersion
sudo projectsudo>= 1.8.2, < 1.8.32; >= 1.9.0, < 1.9.5; 1.9.5
fedoraprojectfedora32; 33
debiandebian linux9.0; 10.0
netappactive iq unified manager-
netappcloud backup-
netapphci management node-
netapponcommand unified manager core package-
netappontap select deploy administration utility-
netappontap tools9
netappsolidfire-
mcafeeweb gateway8.2.17; 9.2.8; 10.0.4
synologydiskstation manager unified controller3.0
synologydiskstation manager6.2
synologyskynas firmware-
synologyvs960hd firmware-
beyondtrustprivilege management for mac< 21.1.1
beyondtrustprivilege management for unix\/linux< 10.3.2-10
oraclemicros compact workstation 3 firmware310
oraclemicros es400 firmware>= 400, <= 410
oraclemicros kitchen display system firmware210

Multiple CVSS Assessments

Source: [email protected](Primary)
7.8
HIGH

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Source: 134c704f-9b21-4f2e-91b3-4a467353bcc0(Secondary)
7.8
HIGH

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

References

Weakness Type

CWE-122: Heap-based Buffer Overflow

A heap-based buffer overflow occurs when a program writes data beyond the bounds of allocated heap memory, potentially corrupting adjacent memory structures and enabling arbitrary code execution. In CVE-2021-3156, the overflow occurs during command-line argument parsing in Sudo's sudoedit mode, allowing controlled heap corruption that leads to root privilege escalation. For more details, see CWE-122.

Impact Analysis

This vulnerability allows any unprivileged local user to gain full root access on affected systems without requiring knowledge of the root password or being listed in the sudoers file. The impact is catastrophic for system security as it completely bypasses the privilege separation model that Sudo is designed to enforce. Organizations with multi-user Linux systems, shared hosting environments, or containerized workloads face significant risk, as any compromised low-privilege account can be escalated to full root access. The near-decade-long presence of this vulnerability means that a vast number of Linux systems in production environments were affected.

Exploit Maturity

CVE-2021-3156 (Baron Samedit) was added to CISA's KEV catalog on April 6, 2022, confirming active exploitation in the wild. The EPSS score of 96.8% (99.8th percentile) reflects the extremely high exploitation activity. Multiple reliable public exploits are available, and the vulnerability has been successfully demonstrated on Ubuntu, Debian, Fedora, and other major distributions. The straightforward exploitation path and universal presence of Sudo make this vulnerability highly attractive to attackers performing post-compromise privilege escalation.

Remediation

  1. Update Sudo to version 1.9.5p2 or later immediately, as required by CISA's KEV catalog. All major Linux distributions have released patched packages.
  2. Verify the patch is applied by running sudo --version and confirming the version is 1.9.5p2 or higher, or the distribution-specific patched version.
  3. Audit systems for signs of exploitation, including unexpected root process activity, suspicious modifications to system files, and unusual entries in authentication logs.
  4. Implement additional monitoring for privilege escalation attempts using security tools such as auditd or Falco.
  5. As a defense-in-depth measure, restrict local login access to only authorized users who require interactive system access.

Technical Details

The vulnerability resides in Sudo's argument parsing logic when operating in sudoedit mode. When Sudo processes command-line arguments containing a trailing backslash character, a logic error in the set_cmnd() function causes a heap-based buffer overflow. Specifically, the code fails to properly escape backslashes when constructing the command string, writing beyond the allocated buffer boundary. An attacker can trigger this by invoking sudoedit with a carefully crafted argument ending in a single backslash. The resulting heap overflow can be leveraged to overwrite Sudo's internal data structures, ultimately achieving arbitrary code execution as root. The vulnerability does not require the attacker to have any sudo privileges.

Frequently Asked Questions

What is CVE-2021-3156 (Baron Samedit)?

CVE-2021-3156, nicknamed "Baron Samedit," is a heap-based buffer overflow in Sudo's sudoedit mode that allows any local user to escalate to root privileges without needing a valid password. It was discovered by the Qualys Research Team and had been present in Sudo for nearly 10 years.

How widespread is this vulnerability?

Extremely widespread. Sudo is installed by default on virtually every Linux and Unix-like system. The vulnerability affects Sudo versions 1.8.2 through 1.9.5p1, which covers nearly a decade of releases. All major Linux distributions were affected including Ubuntu, Debian, Red Hat, Fedora, and SUSE.

Does exploitation require sudo privileges?

No. This is particularly dangerous because it does not require the attacker to have any sudo privileges or to be listed in the sudoers file. Any local user with shell access can exploit this vulnerability to become root.

How can I test if my system is vulnerable?

Run sudoedit -s '\' $(python3 -c 'print("A"*1000)') from a non-root user. If the system is vulnerable, Sudo will crash with a segmentation fault. If patched, Sudo will display a usage error. Always test in a non-production environment first.

CVSS Score

7.8
HIGH(7.8)

EPSS Score

EPSS Score99.30%
EPSS Percentile99.9%

Dates

PublishedJanuary 26, 2021
Last ModifiedJune 17, 2026
StatusAnalyzed
CVSS Versionv3.1

Need Help With Vulnerability Management?

Our security experts can help you prioritize and remediate vulnerabilities effectively.