cve.bz

CVE-2021-3156 (Baron Samedit) Sudo Heap-Based Buffer Overflow Vulnerability

7.8 highKEVExploitEPSS >99.9%Fix available

Known as Baron Samedit

High (7.8) in Sudo Sudo. In CISA KEV since 2022-04-06. EPSS >99.9% estimated probability of exploitation activity in the next 30 days.

On this page
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.

Severity

CVSS 3.1

7.8 high
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
EPSS
>99.9% (unchanged from >99.9% a week ago; >99.9% 30 days ago) estimated probability of exploitation activity in the next 30 days; 100th percentile. Scored 2026-11-21. A forecast for this CVE across the internet, not for your own systems.
CISA KEV
listed 2022-04-06, due 2022-04-27
CISA's assessment (SSVC)
Exploitation: active · Automatable: no · Technical impact: total, assessed 2025-02-03. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWE
CWE-193 Off-by-one Error
Published
Modified
NVD analysis
Analyzed
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2021-3156 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2021-3156?via=ask-ai-copy and https://cve.bz/cve/CVE-2021-3156?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2021-3156 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
sudo_project:sudofrom 1.8.2 before 1.8.32
sudo_project:sudofrom 1.9.0 before 1.9.5
sudo_project:sudo1.9.5
sudo_project:sudo1.9.5:patch1
fedoraproject:fedora32
fedoraproject:fedora33
debian:debian_linux9.0
debian:debian_linux10.0
netapp:ontap_tools9
mcafee:web_gateway8.2.17
mcafee:web_gateway9.2.8
mcafee:web_gateway10.0.4
synology:diskstation_manager_unified_controller3.0
synology:diskstation_manager6.2
beyondtrust:privilege_management_for_macbefore 21.1.1
beyondtrust:privilege_management_for_unix/linuxbefore 10.3.2-10
oracle:micros_compact_workstation_3_firmware310
oracle:micros_es400_firmwarefrom 400 through 410
oracle:micros_kitchen_display_system_firmware210
oracle:micros_workstation_5a_firmware5a
oracle:micros_workstation_6_firmwarefrom 610 through 655
oracle:communications_performance_intelligence_centerfrom 10.3.0.0.0 through 10.3.0.2.1
oracle:communications_performance_intelligence_centerfrom 10.4.0.1.0 through 10.4.0.3.1
oracle:tekelec_platform_distributionfrom 7.4.0 through 7.7.1

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian9sudo1.8.19p1-2.1+deb9u3DLA-2534-1
Debian10sudo1.8.27-1+deb10u3DSA-4839-1
Debian12, 13, 14sudo1.9.5p1-1.1DEBIAN-CVE-2021-3156
Ubuntu16.04:LTSsudo1.8.16-0ubuntu1.10UBUNTU-CVE-2021-3156 USN-4705-1
Ubuntu18.04:LTSsudo1.8.21p2-3ubuntu1.4UBUNTU-CVE-2021-3156 USN-4705-1
Ubuntu20.04:LTSsudo1.8.31-1ubuntu1.2UBUNTU-CVE-2021-3156 USN-4705-1
UbuntuPro:14.04:LTSsudo1.8.9p5-1ubuntu1.5+esm6UBUNTU-CVE-2021-3156 USN-4705-2
Red Hatenterprise_linux:7::client, enterprise_linux:7::server, enterprise_linux:7::workstationsudo, sudo-devel, sudo-debuginfo0:1.8.23-10.el7_9.1RHSA-2021:0221
Red Hatenterprise_linux:7::computenodesudo-devel, sudo-debuginfo0:1.8.23-10.el7_9.1RHSA-2021:0221
Red Hatenterprise_linux:7::hypervisorredhat-virtualization-host, redhat-virtualization-host-image-update0:4.3.13-20210127.0.el7_9RHSA-2021:0395
Red Hatenterprise_linux:8::baseossudo, sudo-debuginfo, sudo-debugsource0:1.8.29-6.el8_3.1RHSA-2021:0218
Red Hatrhel_aus:7.2::serversudo, sudo-devel, sudo-debuginfo0:1.8.6p7-17.el7_2.3RHSA-2021:0226
Red Hatrhel_aus:7.3::serversudo, sudo-devel, sudo-debuginfo0:1.8.6p7-23.el7_3.3RHSA-2021:0225
Red Hatrhel_aus:7.4::server, rhel_e4s:7.4::server, rhel_tus:7.4::serversudo, sudo-devel, sudo-debuginfo0:1.8.19p2-12.el7_4.2RHSA-2021:0224
Red Hatrhel_els:6sudo, sudo-devel, sudo-debuginfo0:1.8.6p3-29.el6_10.4RHSA-2021:0227
Red Hatrhel_eus:7.6::computenode, rhel_eus:7.6::serversudo, sudo-devel, sudo-debuginfo0:1.8.23-3.el7_6.2RHSA-2021:0223
Red Hatrhel_eus:7.7::computenode, rhel_eus:7.7::serversudo, sudo-devel, sudo-debuginfo0:1.8.23-4.el7_7.3RHSA-2021:0222
Red Hatrhel_eus:8.1::baseossudo, sudo-debuginfo, sudo-debugsource0:1.8.25p1-8.el8_1.2RHSA-2021:0220
Red Hatrhel_eus:8.2::baseossudo, sudo-debuginfo, sudo-debugsource0:1.8.29-5.el8_2.1RHSA-2021:0219
1 more for Red Hat in the JSON and on Red Hat's page.
SUSEEnterprise Storage 5, HPE Helion OpenStack 8, Linux Enterprise Server 12 SP3-BCL and 8 moresudo1.8.20p2-3.20.1SUSE-SU-2021:0226-1
SUSEEnterprise Storage 6, Linux Enterprise High Performance Computing 15 SP1-ESPOS, Linux Enterprise High Performance Computing 15 SP1-LTSS and 12 moresudo1.8.22-4.18.1SUSE-SU-2021:1275-1
SUSEEnterprise Storage 6, Linux Enterprise High Performance Computing 15 SP1-ESPOS, Linux Enterprise High Performance Computing 15 SP1-LTSS and 12 moresudo1.8.22-4.15.1SUSE-SU-2021:0227-1
SUSEHPE Helion OpenStack 8, Linux Enterprise Server 12 SP3-BCL, Linux Enterprise Server 12 SP3-LTSS and 7 moresudo1.8.20p2-3.23.1SUSE-SU-2021:1273-1
SUSELinux Enterprise Server 12 SP2-BCLsudo1.8.10p3-10.35.1SUSE-SU-2021:1267-1
SUSELinux Enterprise Server 12 SP2-BCL, Linux Enterprise Server 12 SP2-LTSS, Linux Enterprise Server for SAP Applications 12 SP2 and 1 moresudo1.8.10p3-10.29.1SUSE-SU-2021:0232-1
SUSELinux Enterprise Server 12 SP2-BCL, Linux Enterprise Server 12 SP2-LTSS, Linux Enterprise Server for SAP Applications 12 SP2 and 1 moresudo1.8.10p3-10.32.1SUSE-SU-2021:0928-1
SUSELinux Enterprise Server 12 SP5, Linux Enterprise Server for SAP Applications 12 SP5, Linux Enterprise Software Development Kit 12 SP5sudo1.8.27-4.15.1SUSE-SU-2021:1274-1
SUSELinux Enterprise Server 12 SP5, Linux Enterprise Server for SAP Applications 12 SP5, Linux Enterprise Software Development Kit 12 SP5sudo1.8.27-4.6.1SUSE-SU-2021:0225-1
SUSELinux Enterprise Server 12 SP5-LTSS, Linux Enterprise Server LTSS Extended Security 12 SP5sudo1.8.27-4.51.1SUSE-SU-2024:4389-1
openSUSELeap 15.1sudo1.8.22-lp151.5.12.1openSUSE-SU-2021:0169-1
openSUSELeap 15.2sudo1.8.22-lp152.8.6.1openSUSE-SU-2021:0170-1
openSUSELeap 15.2sudo1.8.22-lp152.8.9.1openSUSE-SU-2021:0602-1
openSUSETumbleweedsudo1.9.7p2-1.4openSUSE-SU-2024:11413-1
Alpinev3.10, v3.12, v3.13 and 5 moresudo1.9.5p2-r0ALPINE-CVE-2021-3156
Alpinev3.11sudo1.8.31-r1ALPINE-CVE-2021-3156
Alpinev3.19, v3.20, v3.21 and 3 moresudo1.9.5_p2-r0ALPINE-CVE-2021-3156

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Red Hat Security Data © Red Hat, Inc., CC BY 4.0; SUSE security data, CC BY 4.0; the Alpine secdb, CC BY-SA 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Red Hat · SUSE · openSUSE · Alpine.

Red Hat

Red Hat rates this Important.

Red Hat's statement

This flaw does not affect the versions of sudo shipped with Red Hat Enterprise Linux 5, because the vulnerable code was not present in these versions.

Red Hat's mitigation

Red Hat Product Security strongly recommends customers to update to fixed sudo packages once they are available. For customers who cannot update immediately, the following interim partial mitigation using systemtap is suggested:

1. Install required systemtap packages and dependencies:

```

systemtap yum-utils kernel-devel-"$(uname -r)"

```

Then for RHEL 7 install kernel debuginfo, using:

```

debuginfo-install -y kernel-"$(uname -r)"

```

Then for RHEL 8 & 6 install sudo debuginfo, using:

```

debuginfo-install sudo

```

2. Create the following systemtap script: (call the file as sudoedit-block.stap)

```

probe process("/usr/bin/sudo").function("main") {

command = cmdline_args(0,0,"");

if (isinstr(command, "edit")) {

raise(9);

}

}

```

3. Install the script using the following command: (using root)

```

# nohup stap -g sudoedit-block.stap &

```

(This should output the PID number of the systemtap script)

This script will cause the vulnerable sudoedit binary to stop working. The sudo command will still work as usual.

The above change does not persist across reboots and must be applied after each reboot.

Please consult How to make a systemtap kernel module load persistently across reboots? (https://access.redhat.com/solutions/5752521) to learn how to

turn this into a service managed by initd.

4. Once the new fixed packages are installed, the systemtap script can be removed by killing the systemtap process. For example, by using:

```

# kill -s SIGTERM 7590

```

(where 7590 is the PID of the systemtap process)

ProductPackageStateAdvisory
Red Hat Enterprise Linux 6 Extended Lifecycle Supportsudo-0:1.8.6p3-29.el6_10.4Fixed 2021-01-26RHSA-2021:0227
Red Hat Enterprise Linux 7sudo-0:1.8.23-10.el7_9.1Fixed 2021-01-27RHSA-2021:0221
Red Hat Enterprise Linux 7.2 Advanced Update Supportsudo-0:1.8.6p7-17.el7_2.3Fixed 2021-01-26RHSA-2021:0226
Red Hat Enterprise Linux 7.3 Advanced Update Supportsudo-0:1.8.6p7-23.el7_3.3Fixed 2021-01-26RHSA-2021:0225
Red Hat Enterprise Linux 7.4 Advanced Update Supportsudo-0:1.8.19p2-12.el7_4.2Fixed 2021-01-26RHSA-2021:0224
Red Hat Enterprise Linux 7.4 Telco Extended Update Supportsudo-0:1.8.19p2-12.el7_4.2Fixed 2021-01-26RHSA-2021:0224
Red Hat Enterprise Linux 7.4 Update Services for SAP Solutionssudo-0:1.8.19p2-12.el7_4.2Fixed 2021-01-26RHSA-2021:0224
Red Hat Enterprise Linux 7.6 Extended Update Supportsudo-0:1.8.23-3.el7_6.2Fixed 2021-01-27RHSA-2021:0223
Red Hat Enterprise Linux 7.7 Extended Update Supportsudo-0:1.8.23-4.el7_7.3Fixed 2021-01-26RHSA-2021:0222
Red Hat Enterprise Linux 8sudo-0:1.8.29-6.el8_3.1Fixed 2021-01-26RHSA-2021:0218
Red Hat Enterprise Linux 8.1 Extended Update Supportsudo-0:1.8.25p1-8.el8_1.2Fixed 2021-01-26RHSA-2021:0220
Red Hat Enterprise Linux 8.2 Extended Update Supportsudo-0:1.8.29-5.el8_2.1Fixed 2021-01-26RHSA-2021:0219
Red Hat Virtualization 4 for Red Hat Enterprise Linux 7redhat-virtualization-host-0:4.3.13-20210127.0.el7_9Fixed 2021-02-03RHSA-2021:0395
Red Hat Virtualization 4 for Red Hat Enterprise Linux 8redhat-virtualization-host-0:4.4.4-20210201.0.el8_3Fixed 2021-02-03RHSA-2021:0401
Red Hat Enterprise Linux 5sudoNot affected
Red Hat Enterprise Linux 9sudoNot affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2021-3156.

ICS advisories (CISA)

AdvisoryTitlePublishedSectorsAffectedFixed
ICSA-22-256-01Hitachi Energy TXpert Hub CoreTec 4 Sudo Vulnerability2022-09-13EnergyTXpert Hub CoreTec 4: version 2.0.0 2.0.1, TXpert Hub CoreTec 4: version 2.1.0 2.1.1 2.1.2 2.1.3, TXpert Hub CoreTec 4: version 2.2.0 2.2.1none listed
ICSA-21-334-04Johnson Controls CEM Systems AC20002021-11-30Critical ManufacturingCEM Systems AC2000: All versions prior to Version 10.6none listed
ICSA-21-245-01Johnson Controls Sensormatic Electronics Illustra2021-09-02Critical ManufacturingInsight: All versions prior to 1.4.0, Pro 2: All versions, Flex Gen 2: All versions prior to 1.9.4 and 1 morenone listed
ICSA-21-147-02Johnson Controls Sensormatic Electronics VideoEdge2021-05-27Critical ManufacturingVideoEdge: versions prior to 5.7.0none listed
ICSA-21-133-02Johnson Controls Sensormatic Tyco AI2021-05-13Critical ManufacturingTyco AI: All versions up to and including v1.2none listed
ICSA-21-119-03Johnson Controls Exacq Technologies exacqVision2021-04-29Critical ManufacturingexacqVision - Linux based Z-Series and A-Series, exacqVision - Q-Series, exacqVision - G-Series and 5 morenone listed

From CISA's ICS advisories (CSAF), provided under CISA's notification. Only the facts are shown; each advisory is on CISA's page. Credits.

Public exploits

GitHub PoC

Repositories on GitHub named after this CVE or listed for it by the PoC-in-GitHub index. For those marked Harbor Check: matches CVE, Flawharbor read the code and found it implements this CVE's exploitation technique: read, not run, and its dependencies only checked for warning signs, so a pointer and no guarantee. The rest are unverified: some hold a working proof of concept, some nothing useful, and some malware made to look like one. Read the code before you run any of it. How Harbor Check reads them, and what it found.

  • TheLeopard65/CVE-2021-3156-Baron-Samedit Harbor Check: matches CVE 2 stars, C, created
    A simple Docker lab and Exploit setup for CVE-2021-3156 - "Baron Samedit".
  • d4ytox/CVE-2021-3156 Harbor Check: matches CVE 1 star, C, created
    Baron Samedit (CVE-2021-3156): sudo heap-based buffer overflow giving local root. PoC packaged with a static/musl launcher so it runs again…
  • Kranti08/CVE-2021-3156-Baron-Samedit Harbor Check: matches CVE 0 stars, C, created
    Exploitation and mitigation analysis of CVE-2021-3156 heap-based buffer overflow in sudo
  • calonnuotcabe/CVE-2021-3156 Harbor Check: matches CVE 0 stars, created
    Exploiting heap-based buffer overflow in sudo for privilege escalation
  • ngtuonghung/CVE-2021-3156 Harbor Check: matches CVE 0 stars, Python, created
    POC for CVE-2021-3156 - Heap-based buffer overflow in sudo
9 more

References

Check your stackJSON