CVE-2021-3156: Sudo Heap-Based Buffer Overflow Vulnerability
Sudo · Sudo · NVD published 2021-01-27 · posted 2026-10-21 · last modified 2026-06-17
What it is
Sudo before 1.9.5p2 contains an off-by-one error that can result in a heap-based buffer overflow, which allows privilege escalation to root via "sudoedit -s" and a command-line argument that ends with a single backslash character.
| Weakness | CWE-193CWE-122 |
|---|---|
| CVSS vector | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (source: [email protected]) |
| CISA due date | 2022-04-27 (for US federal agencies under BOD; a good deadline for everyone) |
| ATT&CK tactics | Execution → Privilege Escalation |
Exploitation evidence
First exploit evidence seen: 2021-01-26 (earliest date across the sources below).
Exploited in the wild
- CISA KEV: listed since 2022-04-06. Source
Public exploit code
Metasploit
exploit/linux/local/sudo_baron_samedit: Sudo Heap-Based Buffer Overflow (disclosure 2021-01-26)
Exploit-DB
- EDB-49521: Sudo 1.9.5p1 - 'Baron Samedit ' Heap-Based Buffer Overflow Privilege Escalation (1) (2021-02-03)
- EDB-49522: Sudo 1.9.5p1 - 'Baron Samedit ' Heap-Based Buffer Overflow Privilege Escalation (2) (2021-02-03)
GitHub proof-of-concept repositories
88 public repositories from 88 accounts, first seen 2021-01-26. Most starred: blasty/CVE-2021-3156 (1029 stars), view repository.
Verify before running: public PoCs can be malicious. Read the code and only run it in an isolated lab. A PoC means exploit code is public, not that this CVE is exploited in the wild.
Sources: CISA KEV · Rapid7 Metasploit Framework module metadata · Exploit-DB (OffSec) · nomi-sec/PoC-in-GitHub.
Defend the Chain
The attack chain for CVE-2021-3156 laid across the MITRE ATT&CK Enterprise tactics. Solid cards come from the MITRE CTID KEV mappings; dashed cards are inferred by CVERadar from the CWE or description. Correct defences are real ATT&CK mitigations for that technique.
Pick a red technique card on the board, then choose the defence that stops it.
Defend against T1203 Exploitation for Client Execution Inferred
Inferred from CWE CWE-122
How to fix it
CISA required action
Apply updates per vendor instructions. (source: CISA KEV)
Fixed versions
- sudo project sudo: upgrade to 1.8.32 or later (affected from 1.8.2)
- sudo project sudo: upgrade to 1.9.5 or later (affected from 1.9.0)
- beyondtrust privilege management for mac: upgrade to 21.1.1 or later
- beyondtrust privilege management for unix\/linux: upgrade to 10.3.2-10 or later
Derived from the NVD CPE configuration (versionEndExcluding / versionEndIncluding). Always confirm with the vendor advisory.
Vendor advisories and patches
- http://www.openwall.com/lists/oss-security/2021/09/14/2 (Mailing List, Patch, Third Party Advisory)
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CALA5FTXIQBRRYUA2ZQNJXB6OQMAXEII/ (Mailing List, Release Notes)
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LHXK6ICO5AYLGFK2TAX5MZKUXTUKWOJY/ (Mailing List, Release Notes)
- https://www.oracle.com//security-alerts/cpujul2021.html (Patch, Third Party Advisory)
- https://www.oracle.com/security-alerts/cpuapr2022.html (Patch, Third Party Advisory)
- https://www.oracle.com/security-alerts/cpuoct2021.html (Patch, Third Party Advisory)
- https://www.sudo.ws/stable.html#1.9.5p2 (Release Notes)
MITRE ATT&CK mitigations for this chain
- M1050 Exploit Protection (for T1203, T1068) : Security applications that look for behavior used during exploitation such as Windows Defender Exploit Guard (WDEG) and the Enhanced Mitigation Experience Toolkit (EMET) can be used to mitigate some exploitation behavior. Control flow integrity checking is another way to potentially identify and stop a software exploi
- M1051 Update Software (for T1203, T1068) : Perform regular software updates to mitigate exploitation risk. Keeping software up-to-date with the latest security patches helps prevent adversaries from exploiting known vulnerabilities in client software, reducing the risk of successful attacks.
- M1048 Application Isolation and Sandboxing (for T1203, T1068) : Browser sandboxes can be used to mitigate some of the impact of exploitation, but sandbox escapes may still exist. Other types of virtualization and application microsegmentation may also mitigate the impact of client-side exploitation. Risks of additional exploits and weaknesses in those systems may still exist.
- M1019 Threat Intelligence Program (for T1068) : Develop a robust cyber threat intelligence capability to determine what types and levels of threat may use software exploits and 0-days against a particular organization.
- M1038 Execution Prevention (for T1068) : Consider blocking the execution of known vulnerable drivers that adversaries may exploit to execute code in kernel mode. Validate driver block rules in audit mode to ensure stability prior to production deployment.
Detection Generic guidance
- Execution: Watch for the service process spawning shells or script interpreters (cmd.exe, powershell, sh, bash, python) via EDR process-tree rules.
- Privilege Escalation: Alert on processes gaining SYSTEM/root unexpectedly, and on exploitation crashes of privileged services.
Response checklist Generic guidance
- Inventory: find every instance of the affected product and version (include internet-facing and forgotten ones).
- Patch or mitigate per the vendor advisory; if you cannot patch, remove internet exposure or apply the vendor workaround.
- Assume compromise if the system was exposed before patching: hunt for the indicators in the advisory and review logs back to the disclosure date.
- Rotate credentials and secrets stored on or used by the affected system if compromise cannot be ruled out.
Sources
- NVD: CVE-2021-3156
- CVE.org record
- CISA Known Exploited Vulnerabilities catalog
- FIRST EPSS (2026-10-24)
- http://packetstormsecurity.com/files/161160/Sudo-Heap-Based-Buffer-Overflow.html (Exploit, Third Party Advisory, VDB Entry)
- http://packetstormsecurity.com/files/161230/Sudo-Buffer-Overflow-Privilege-Escalation.html (Exploit, Third Party Advisory, VDB Entry)
- http://packetstormsecurity.com/files/161270/Sudo-1.9.5p1-Buffer-Overflow-Privilege-Escalation.html (Exploit, Third Party Advisory, VDB Entry)
- http://packetstormsecurity.com/files/161293/Sudo-1.8.31p2-1.9.5p1-Buffer-Overflow.html (Exploit, Third Party Advisory, VDB Entry)
- http://packetstormsecurity.com/files/176932/glibc-syslog-Heap-Based-Buffer-Overflow.html (Exploit, Third Party Advisory, VDB Entry)
- http://seclists.org/fulldisclosure/2021/Feb/42 (Mailing List, Third Party Advisory)
- http://seclists.org/fulldisclosure/2021/Jan/79 (Exploit, Mailing List, Third Party Advisory)
- http://seclists.org/fulldisclosure/2024/Feb/3 (Exploit, Mailing List, Third Party Advisory)
- http://www.openwall.com/lists/oss-security/2021/01/26/3 (Exploit, Mailing List, Third Party Advisory)
- http://www.openwall.com/lists/oss-security/2021/01/27/1 (Mailing List, Third Party Advisory)
- http://www.openwall.com/lists/oss-security/2021/01/27/2 (Mailing List, Third Party Advisory)
- http://www.openwall.com/lists/oss-security/2021/02/15/1 (Exploit, Mailing List, Third Party Advisory)
- http://www.openwall.com/lists/oss-security/2024/01/30/6 (Exploit, Mailing List)
- http://www.openwall.com/lists/oss-security/2024/01/30/8 (Mailing List)
- https://kc.mcafee.com/corporate/index?page=content&id=SB10348 (Broken Link, Third Party Advisory)
- https://lists.debian.org/debian-lts-announce/2021/01/msg00022.html (Mailing List, Third Party Advisory)
- https://security.gentoo.org/glsa/202101-33 (Third Party Advisory)
- https://security.netapp.com/advisory/ntap-20210128-0001/ (Third Party Advisory)
- https://security.netapp.com/advisory/ntap-20210128-0002/ (Third Party Advisory)
- https://support.apple.com/kb/HT212177 (Third Party Advisory)
- https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-sudo-privesc-jan2021-qnYQfcM (Third Party Advisory)
- https://www.beyondtrust.com/blog/entry/security-advisory-privilege-management-for-unix-linux-pmul-basic-and-privilege-management-for-mac-pmm-affected-by-sudo-vulnerability (Third Party Advisory)
- https://www.debian.org/security/2021/dsa-4839 (Third Party Advisory)
- https://www.kb.cert.org/vuls/id/794544 (Third Party Advisory, US Government Resource)
- https://www.openwall.com/lists/oss-security/2021/01/26/3 (Exploit, Mailing List, Third Party Advisory)
- https://www.synology.com/security/advisory/Synology_SA_21_02 (Third Party Advisory)
- https://www.vicarius.io/vsociety/posts/sudoedit-pwned-cve-2021-3156 (Exploit, Third Party Advisory)
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2021-3156 (US Government Resource)