Sudo Heap-Based Buffer Overflow
CVE-2021-3156 is a high-severity off-by-one error vulnerability in Sudo from Sudo Project, with a CVSS 3.1 base score of 7.8 out of 10. It can be exploited with local access to the system by an attacker with a low-privileged account, without any action from a user. The record lists versions 1.8.32, 1.9.5 as the first without the flaw, so updating Sudo to one of those releases or later removes the exposure. CISA added it to the Known Exploited Vulnerabilities catalogue on April 6, 2022, which means attacks have been observed in the wild.
Attackers are already exploiting this vulnerability, according to CISA.
What to do
- Update Sudo to 1.8.32 or 1.9.5, whichever matches your release line, or a later version.
- Update Privilege Management For Mac to 21.1.1 or a later version.
- Update Privilege Management For Unix/linux to 10.3.2-10 or a later version.
- CISA's required action: Apply updates per vendor instructions.
- Read the advisory on beyondtrust.com for workarounds and exact fixed builds.
Affected products and versions
| Vendor | Product | Affected versions | Fixed in |
|---|---|---|---|
| Sudo Project | Sudo | 1.8.2 up to, but not including, 1.8.32; 1.9.0 up to, but not including, 1.9.5; 1.9.5 | 1.8.32, 1.9.5 |
| Fedora Project | Fedora | 32; 33 | Not stated |
| Debian | Debian Linux | 9.0; 10.0 | Not stated |
| NetApp | Active Iq Unified Manager | Not specified in the record | Not stated |
| NetApp | Cloud Backup | Not specified in the record | Not stated |
| NetApp | Hci Management Node | Not specified in the record | Not stated |
| NetApp | Oncommand Unified Manager Core Package | Not specified in the record | Not stated |
| NetApp | Ontap Select Deploy Administration Utility | Not specified in the record | Not stated |
| NetApp | Ontap Tools | 9 | Not stated |
| NetApp | Solidfire | Not specified in the record | Not stated |
| McAfee | Web Gateway | 8.2.17; 9.2.8; 10.0.4 | Not stated |
| Synology | Diskstation Manager Unified Controller | 3.0 | Not stated |
| Synology | Diskstation Manager | 6.2 | Not stated |
| Synology | Skynas Firmware | Not specified in the record | Not stated |
| Synology | Vs960hd Firmware | Not specified in the record | Not stated |
| Beyondtrust | Privilege Management For Mac | before 21.1.1 | 21.1.1 |
| Beyondtrust | Privilege Management For Unix/linux | before 10.3.2-10 | 10.3.2-10 |
| Oracle | Micros Compact Workstation 3 Firmware | 310 | Not stated |
| Oracle | Micros Es400 Firmware | 400 through 410 | Not stated |
| Oracle | Micros Kitchen Display System Firmware | 210 | Not stated |
| Oracle | Micros Workstation 5a Firmware | 5a | Not stated |
| Oracle | Micros Workstation 6 Firmware | 610 through 655 | Not stated |
| Oracle | Communications Performance Intelligence Center | 10.3.0.0.0 through 10.3.0.2.1; 10.4.0.1.0 through 10.4.0.3.1 | Not stated |
| Oracle | Tekelec Platform Distribution | 7.4.0 through 7.7.1 | Not stated |
Version data comes from NVD's product matching. Confirm against the vendor advisory before deciding you are unaffected.
How the severity score breaks down
- Attack vector
- LocalThe attacker needs local access or must trick a user into running something.
- Attack complexity
- LowNo special conditions are needed; the attack works reliably.
- Privileges required
- LowA basic user account is enough.
- User interaction
- NoneNo action by a victim is required.
- Scope
- UnchangedImpact stays within the vulnerable component.
- Confidentiality
- HighAll data handled by the component can be read.
- Integrity
- HighData or code can be modified at will.
- Availability
- HighThe component can be taken down completely.
Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H. Scored by NVD.
| Scoring system | Score | Severity | Scored by |
|---|---|---|---|
| CVSS 3.1 | 7.8 | High | NVD |
| CVSS 3.1 | 7.8 | High | CISA (ADP) |
| CVSS 2.0 | 7.2 | High | NVD |
Official description
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.
Source: the CVE record as published by its numbering authority, via NVD and CVE.org.
The underlying weakness: Off-by-one Error
A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.
How developers prevent this class of flaw
- When copying character arrays or using character manipulation methods, the correct size parameter must be used to account for the null terminator that needs to be added at the end of the array. Some examples of functions susceptible to this weakness in C include strcpy(), strncpy(), strcat(), strncat(), printf(), sprintf(), scanf() and sscanf().
Timeline
- CVE record published.
- Added to CISA's Known Exploited Vulnerabilities catalogue.
- Deadline for US federal agencies to remediate, set by CISA.
- CISA published its SSVC assessment (exploitation: active, automatable: no, technical impact: total).
- Record last changed materially (score, affected products, status or references).
References
Advisories
Patches and release notes
- openwall.com/lists/oss-security/2021/09/14/2Mailing List, Third Party Advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CALA5FTXIQBRRYUA2ZQN…Mailing List, Release Notes
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LHXK6ICO5AYLGFK2TAX5…Mailing List, Release Notes
- oracle.com//security-alerts/cpujul2021.htmlThird Party Advisory
- oracle.com/security-alerts/cpuapr2022.htmlThird Party Advisory
- oracle.com/security-alerts/cpuoct2021.htmlThird Party Advisory
- sudo.ws/stable.html#1.9.5p2Release Notes
Third-party and government advisories
- seclists.org/fulldisclosure/2021/Feb/42Mailing List, Third Party Advisory
- openwall.com/lists/oss-security/2021/01/27/1Mailing List, Third Party Advisory
- openwall.com/lists/oss-security/2021/01/27/2Mailing List, Third Party Advisory
- lists.debian.org/debian-lts-announce/2021/01/msg00022.htmlMailing List, Third Party Advisory
- security.gentoo.org/glsa/202101-33Third Party Advisory
- security.netapp.com/advisory/ntap-20210128-0001/Third Party Advisory
- security.netapp.com/advisory/ntap-20210128-0002/Third Party Advisory
- support.apple.com/kb/HT212177Third Party Advisory
- tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-sudo-privesc-jan2021-qnYQfcMThird Party Advisory
- debian.org/security/2021/dsa-4839Third Party Advisory
- kb.cert.org/vuls/id/794544Third Party Advisory, US Government Resource
- synology.com/security/advisory/Synology_SA_21_02Third Party Advisory
- cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2021-3156US Government Resource
Technical write-ups (may include proof of concept)
- packetstormsecurity.com/files/161160/Sudo-Heap-Based-Buffer-Overflow.htmlExploit, Third Party Advisory, VDB Entry
- packetstormsecurity.com/files/161230/Sudo-Buffer-Overflow-Privilege-Escalation.htmlExploit, Third Party Advisory, VDB Entry
- packetstormsecurity.com/files/161270/Sudo-1.9.5p1-Buffer-Overflow-Privilege-Escalation.htmlExploit, Third Party Advisory, VDB Entry
- packetstormsecurity.com/files/161293/Sudo-1.8.31p2-1.9.5p1-Buffer-Overflow.htmlExploit, Third Party Advisory, VDB Entry
- packetstormsecurity.com/files/176932/glibc-syslog-Heap-Based-Buffer-Overflow.htmlExploit, Third Party Advisory, VDB Entry
- seclists.org/fulldisclosure/2021/Jan/79Exploit, Mailing List, Third Party Advisory
- seclists.org/fulldisclosure/2024/Feb/3Exploit, Mailing List, Third Party Advisory
- openwall.com/lists/oss-security/2021/01/26/3Exploit, Mailing List, Third Party Advisory
- openwall.com/lists/oss-security/2021/02/15/1Exploit, Mailing List, Third Party Advisory
- openwall.com/lists/oss-security/2024/01/30/6Exploit, Mailing List
- openwall.com/lists/oss-security/2021/01/26/3Exploit, Mailing List, Third Party Advisory
- vicarius.io/vsociety/posts/sudoedit-pwned-cve-2021-3156Exploit, Third Party Advisory
Other references
- openwall.com/lists/oss-security/2024/01/30/8Mailing List
Other vulnerabilities in Sudo
- 7.8 High severity
- 7.8 High severity
- 7.8 High severity
- 8.8 High severity
- 7.8 High severity
- 7.1 High severity
Spotted an error? Tell us.