CVERadar
HIGH · CVSS 3.1 7.8CISA KEV · added 2022-04-06Metasploit moduleExploit-DBPublic PoCEPSS 99.96% (p100)Threat level 84

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.

WeaknessCWE-193CWE-122
CVSS vectorCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (source: [email protected])
CISA due date2022-04-27 (for US federal agencies under BOD; a good deadline for everyone)
ATT&CK tacticsExecution → 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-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.

Threat level 84/100
Defender level 1 · 0 XP
Chain links broken: 0/2

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

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

  1. Inventory: find every instance of the affected product and version (include internet-facing and forgotten ones).
  2. Patch or mitigate per the vendor advisory; if you cannot patch, remove internet exposure or apply the vendor workaround.
  3. Assume compromise if the system was exposed before patching: hunt for the indicators in the advisory and review logs back to the disclosure date.
  4. Rotate credentials and secrets stored on or used by the affected system if compromise cannot be ruled out.

Sources