CVE DatabaseCVE-2021-3156
한국어 권고문 →
CVE-2021-31567.8/HIGHCISA KEVCWE-193CWE-193

Sudo Heap-Based Buffer Overflow Local Privilege Escalation Vulnerability (CVE-2021-3156, Baron Samedit)

⚡ Jump to Patch
Affected Vendors
sudo
Affected Components
sudo
Published Date
2021-01-26
CVSS v3.1
7.8
HIGH
EPSS (30d)
100.0%
FIRST.org
CISA KEV
Exploited

Executive & SecOps Summary

SECOPS ASSESSMENT
Affected Scope

Unix-like operating systems running Sudo versions 1.8.2 through 1.8.31p2, and 1.9.0 through 1.9.5p1

Impact

A local non-privileged attacker can exploit this vulnerability via 'sudoedit -s' with a trailing backslash to escalate privileges to root

Mitigation

Immediately upgrade Sudo to version 1.9.5p2 or later, or restrict execution permissions for sudoedit as a temporary workaround

Affected Products & Version Scope

All Sudo versions from 1.8.2 to 1.8.31p2, and 1.9.0 to 1.9.5p1 (prior to version 1.9.5p2)

Remediation & Live Workaround Commands

PATCH & WORKAROUND

1. Official Patch & Version Upgrade Commands

Update Sudo to the latest patched version (1.9.5p2 or later) using your operating system's package manager.

bash
# For Debian/Ubuntu-based systems
sudo apt-get update && sudo apt-get install --only-upgrade -y sudo

# For RHEL/CentOS/Rocky Linux-based systems
sudo yum update -y sudo

2. Temporary Workaround & Hardening Configuration

If patching cannot be applied immediately, mitigate the risk by disabling or restricting the execution of sudoedit.

bash
# Disable SetUID permission on the sudo binary to prevent exploitation
sudo chmod 0711 /usr/bin/sudo

# Alternatively, restrict sudoedit usage in the sudoers configuration using 'visudo'

3. Log Audit & IoC Verification Commands

Verify if your current Sudo version is vulnerable and inspect system logs for potential exploitation attempts.

bash
# 1. Self-test for vulnerability (if it outputs 'VULNERABLE', the system is at risk)
sudoedit -s '/' 2>&1 | grep -q 'invalid' && echo 'SAFE' || echo 'VULNERABLE'

# 2. Search system logs for suspicious sudoedit execution attempts
sudo grep -r 'sudoedit' /var/log/auth.log /var/log/secure 2>/dev/null
Interactive SecOps Remediation Checklist
0/4 (0%)
Recommended Security Control & Mitigation Partner
SentinelOne Singularity AI EDR
Immediately upgrade Sudo to version 1.9.5p2 or later to mitigate the risk of local privilege escalation.

Block Kernel Privilege Escalation & Ransomware Payloads Before You Can Reboot

Protect unpatched Windows, Linux, and macOS workloads against in-memory exploitation and lateral movement with autonomous EDR.

100% MITRE ATT&CK Detection · 1-Click Rollback

Technical Root Cause & Exploitation Mechanics

1. Vulnerability Overview & Root Cause

This vulnerability (CVE-2021-3156, known as 'Baron Samedit') is a heap-based buffer overflow caused by an off-by-one error (CWE-193) in Sudo's command-line argument parsing logic. When Sudo is executed in shell mode (using the '-s' or '-i' flags), it fails to properly escape meta-characters. If a command-line argument ends with a single backslash ('\') character, the parser incorrectly increments the string pointer past the terminating null byte, leading to an out-of-bounds write and corrupting adjacent heap memory.

2. Exploitation Mechanics & Attack Scenario

An attacker with local access executes 'sudoedit -s' and passes a crafted argument array where the last argument ends with a backslash character. Sudo's internal 'set_arguments' function processes the backslash and attempts to escape the next character, but since it is the null terminator, the pointer advances into unallocated or adjacent heap space. By carefully structuring the heap layout, the attacker can overwrite Sudo's internal structures, bypass authentication checks, and spawn a root shell.

3. Infrastructure & Business Impact

With a CVSS score of 7.8 (High) and an EPSS score of 0.9996, this vulnerability is highly critical and is actively exploited in the wild (listed in CISA KEV). It poses a severe threat to multi-user environments, shared hosting servers, and container hosts. If an attacker gains initial access via a web application vulnerability, they can leverage this flaw to achieve full system compromise, install persistent backdoors, or exfiltrate sensitive data.

Official Vendor Advisories & References

Frequently Asked SecOps Questions (CVE-2021-3156)

FAQ

Q1. How critical is CVE-2021-3156 and is it actively exploited in the wild?

CVE-2021-3156 is rated CVSS 7.8 (HIGH) with a 30-day EPSS exploitation probability of 100.0%. It is listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, requiring immediate emergency remediation.

Q2. Which vendors and products are affected by CVE-2021-3156?

Primary impacted vendors include sudo across sudo. Scope summary: All Sudo versions from 1.8.2 to 1.8.31p2, and 1.9.0 to 1.9.5p1 (prior to version 1.9.5p2)

Q3. What temporary mitigations or workarounds exist for CVE-2021-3156 before patching?

[Mitigation] Immediately upgrade Sudo to version 1.9.5p2 or later, or restrict execution permissions for sudoedit as a temporary workaround Follow the CLI remediation commands and interactive SecOps checklist on this page to restrict exposure prior to your maintenance window.

SECOPS WORKBENCH INTEGRATION

Generate an Internal Engineering Notice or CISO Report for CVE-2021-3156

Instantly format this advisory into an executive CISO summary or engineering patch ticket.

Generate Report →

🔗 Related Advisories in Similar Stack (sudo)

View Category →
SecOps Advisory Dispatch & RSS Feed

Subscribe to Daily Vulnerability Briefings & KEV Alerts

Concise morning briefings for SecOps, DevSecOps, and SRE teams covering newly exploited CVEs and mitigation priorities.

Slack / Teams / RSS Feed:
PatchKO
CVE-2021-3156 Sudo Heap-Based Buffer Overflow Local Privilege Escalation Vulnerability (CVE-2021-3156, Baron Samedit) (CVSS 7.8) - Patch & Workaround | CVE Pulse