CVE-2021-23240
📋 TL;DR
CVE-2021-23240 is a privilege escalation vulnerability in Sudo's SELinux RBAC support that allows local unprivileged users to gain file ownership and escalate privileges by exploiting a symlink race condition in temporary file handling. Only systems with SELinux in permissive mode are affected; machines without SELinux or with SELinux in enforcing mode are not vulnerable.
💻 Affected Systems
- Sudo
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Solidfire by Netapp
Sudo by Sudo Project
Sudo by Sudo Project
⚠️ Risk & Real-World Impact
Worst Case
Local unprivileged user gains root privileges and full system control
Likely Case
Local user escalates privileges to gain unauthorized file access and execute arbitrary commands
If Mitigated
No impact if SELinux is disabled or in enforcing mode, or if Sudo is patched
🎯 Exploit Status
Exploitation requires local user access and SELinux in permissive mode. The vulnerability is in the sudoedit command's temporary file handling.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Sudo 1.9.5 and later
Vendor Advisory: https://www.sudo.ws/security/advisories/sudoedit_selinux/
Restart Required: No
Instructions:
1. Update Sudo to version 1.9.5 or later using your distribution's package manager. 2. For RHEL/CentOS: 'sudo yum update sudo'. 3. For Ubuntu/Debian: 'sudo apt update && sudo apt upgrade sudo'. 4. Verify the update with 'sudo --version'.
🔧 Temporary Workarounds
Set SELinux to enforcing mode
linuxChange SELinux from permissive to enforcing mode to prevent exploitation
sudo setenforce 1
Edit /etc/selinux/config to set SELINUX=enforcing
Disable SELinux temporarily
linuxCompletely disable SELinux (not recommended for production)
sudo setenforce 0
Edit /etc/selinux/config to set SELINUX=disabled
🧯 If You Can't Patch
- Set SELinux to enforcing mode instead of permissive mode
- Restrict sudoedit usage through sudoers configuration
🔍 How to Verify
Check if Vulnerable:
Check if SELinux is in permissive mode with 'getenforce' and check Sudo version with 'sudo --version | head -1'
Check Version:
sudo --version | head -1
Verify Fix Applied:
Verify Sudo version is 1.9.5 or later with 'sudo --version | head -1'
📡 Detection & Monitoring
Log Indicators:
- Failed privilege escalation attempts in sudo logs
- Unusual sudoedit usage patterns
- SELinux permission denials followed by successful operations
Network Indicators:
- None - this is a local privilege escalation
SIEM Query:
source="sudo" AND (event="COMMAND" OR event="FAILED") AND command="*sudoedit*"
🔗 References
- https://bugzilla.suse.com/show_bug.cgi?id=CVE-2021-23240
- https://lists.apache.org/thread.html/r58af02e294bd07f487e2c64ffc0a29b837db5600e33b6e698b9d696b%40%3Cissues.bookkeeper.apache.org%3E
- https://lists.apache.org/thread.html/rf4c02775860db415b4955778a131c2795223f61cb8c6a450893651e4%40%3Cissues.bookkeeper.apache.org%3E
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EE42Y35SMJOLONAIBNYNFC7J44UUZ2Y6/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GMY4VSSBIND7VAYSN6T7XIWJRWG4GBB3/
- https://security.gentoo.org/glsa/202101-33
- https://security.netapp.com/advisory/ntap-20210129-0010/
- https://www.sudo.ws/stable.html#1.9.5
- https://bugzilla.suse.com/show_bug.cgi?id=CVE-2021-23240
- https://lists.apache.org/thread.html/r58af02e294bd07f487e2c64ffc0a29b837db5600e33b6e698b9d696b%40%3Cissues.bookkeeper.apache.org%3E
- https://lists.apache.org/thread.html/rf4c02775860db415b4955778a131c2795223f61cb8c6a450893651e4%40%3Cissues.bookkeeper.apache.org%3E
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EE42Y35SMJOLONAIBNYNFC7J44UUZ2Y6/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GMY4VSSBIND7VAYSN6T7XIWJRWG4GBB3/
- https://security.gentoo.org/glsa/202101-33
- https://security.netapp.com/advisory/ntap-20210129-0010/
- https://www.sudo.ws/stable.html#1.9.5