CVE-2021-3156

7.8 HIGH

📋 TL;DR

CVE-2021-3156 is a heap-based buffer overflow vulnerability in Sudo that allows local users to escalate privileges to root. The exploit involves using 'sudoedit -s' with a command-line argument ending in a backslash. Any system running vulnerable Sudo versions is affected.

💻 Affected Systems

Products:
  • Sudo
Versions: All versions before 1.9.5p2
Operating Systems: Linux, Unix-like systems
Default Config Vulnerable: ⚠️ Yes
Notes: Affects default Sudo installations on most Linux distributions. Some distributions backported fixes to earlier versions.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full root privilege escalation leading to complete system compromise, data theft, and persistent backdoor installation.

🟠

Likely Case

Local privilege escalation allowing attackers to gain root access on compromised systems.

🟢

If Mitigated

Limited impact if proper patching and least privilege principles are followed.

🌐 Internet-Facing: LOW - This is a local privilege escalation requiring existing access to the system.
🏢 Internal Only: HIGH - Internal attackers or compromised accounts can exploit this to gain root privileges.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: CONFIRMED
Unauthenticated Exploit: ✅ No
Complexity: LOW

Multiple public exploits available. Requires local user access but no special privileges.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.9.5p2 or later

Vendor Advisory: https://www.sudo.ws/security/advisories/unescape_overflow/

Restart Required: No

Instructions:

1. Update Sudo package using your distribution's package manager. 2. For RHEL/CentOS: 'sudo yum update sudo'. 3. For Ubuntu/Debian: 'sudo apt update && sudo apt upgrade sudo'. 4. For source installations: Download and compile Sudo 1.9.5p2 or later.

🔧 Temporary Workarounds

Remove sudoedit symlink

linux

Temporarily remove the sudoedit symlink to prevent exploitation

sudo rm -f /usr/bin/sudoedit

Restrict sudoedit usage

linux

Modify sudoers to restrict sudoedit command usage

# Edit /etc/sudoers to remove or restrict sudoedit permissions

🧯 If You Can't Patch

  • Implement strict least privilege principles and limit sudo access
  • Monitor for sudoedit usage patterns and implement behavioral detection

🔍 How to Verify

Check if Vulnerable:

Run: sudoedit -s / 2>&1 | grep 'usage:' || echo 'Vulnerable'

Check Version:

sudo --version | head -1

Verify Fix Applied:

Check Sudo version: sudo --version | head -1

📡 Detection & Monitoring

Log Indicators:

  • Unusual sudoedit commands with backslash characters
  • Failed sudoedit attempts with specific patterns

Network Indicators:

  • N/A - Local privilege escalation

SIEM Query:

source="sudo" AND (command="sudoedit" OR command="sudoedit -s") AND args="*\\"

🔗 References

📤 Share & Export