CVE-2021-3156· sudo project / sudo· CWE-193
Sudo Baron Samedit - Local Privilege Escalation
Exploited in the wild. Listed by CISA on 2022-04-06; known to be used by ransomware.
highseverity
7.8CVSS score
100%likelihood of exploitation, next 30 days
100%of all CVEs are less likely
Readycheck to confirm it
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.
Impact
Attackers can escalate privileges to root, potentially leading to full system compromise.
Fix
Upgrade Sudo to version 1.9.5p2 or later that fixes the heap-based buffer overflow vulnerability.
How to confirm it
Positive when: contains "malloc(): memory corruption" and "Aborted (core dumped)"Run it with nuclei: nuclei -id CVE-2021-3156 -u <target>
The full check
id: CVE-2021-3156
info:
name: Sudo Baron Samedit - Local Privilege Escalation
author: pussycat0x
severity: high
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.
remediation: |
Upgrade Sudo to version 1.9.5p2 or later that fixes the heap-based buffer overflow vulnerability.
impact: |
Attackers can escalate privileges to root, potentially leading to full system compromise.
reference:
- https://medium.com/mii-cybersec/privilege-escalation-cve-2021-3156-new-sudo-vulnerability-4f9e84a9f435
- https://blog.qualys.com/vulnerabilities-threat-research/2021/01/26/cve-2021-3156-heap-based-buffer-overflow-in-sudo-baron-samedit
- https://infosecwriteups.com/baron-samedit-cve-2021-3156-tryhackme-76d7dedc3cff
- http://packetstormsecurity.com/files/161160/Sudo-Heap-Based-Buffer-Overflow.html
- http://packetstormsecurity.com/files/176932/glibc-syslog-Heap-Based-Buffer-Overflow.html
classification:
cvss-metrics: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
cvss-score: 7.8
cve-id: CVE-2021-3156
cwe-id: CWE-193
epss-score: 0.99962
epss-percentile: 0.99975
cpe: cpe:2.3:a:sudo_project:sudo:*:*:*:*:*:*:*:*
metadata:
verified: true
vendor: sudo_project
product: sudo
tags: packetstorm,cve,cve2021,sudo,code,linux,privesc,local,kev,sudo_project,vkev,vuln
self-contained: true
code:
- engine:
- sh
- bash
source: |
sudoedit -s '\' $(python3 -c 'print("A"*1000)')
matchers:
- type: word
words:
- "malloc(): memory corruption"
- "Aborted (core dumped)"
condition: andReferences
- https://medium.com/mii-cybersec/privilege-escalation-cve-2021-3156-new-sudo-vulnerability-4f9e84a9f435
- https://blog.qualys.com/vulnerabilities-threat-research/2021/01/26/cve-2021-3156-heap-based-buffer-overflow-in-sudo-baron-samedit
- https://infosecwriteups.com/baron-samedit-cve-2021-3156-tryhackme-76d7dedc3cff
- http://packetstormsecurity.com/files/161160/Sudo-Heap-Based-Buffer-Overflow.html
- http://packetstormsecurity.com/files/176932/glibc-syslog-Heap-Based-Buffer-Overflow.html
Use this check only on systems you are authorised to test. Where the data comes from