Privilege Escalation Vulnerability in Sudo Package: CVE-2021-23240
Summary
ALPINE-CVE-2021-23240: selinux_edit_copy_tfiles in sudoedit in Sudo before 1.9.5 allows a local unprivileged user to gain file ownership and escalate privileges by replacing a temporary file with a symlink to an arbitrary file target. Affects sudo versions < 1.9.5p2-r0. Fixed in 1.9.5p2-r0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Sudo is a widely used program that allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. It is an essential tool for system administration, providing a way to grant limited administrative privileges to users without giving them full access to the system. The vulnerability CVE-2021-23240 affects multiple versions of Sudo across various Alpine Linux distributions, allowing local unprivileged users to escalate their privileges under certain conditions.
Vulnerability Detail
The vulnerability arises from the 'selinux_edit_copy_tfiles' function in the sudoedit component of Sudo versions prior to 1.9.5. It allows a local unprivileged user to gain file ownership and escalate privileges by replacing a temporary file with a symlink to an arbitrary file target. This issue specifically affects systems with SELinux RBAC support in permissive mode, while machines without SELinux are not vulnerable. The CVSS score for this vulnerability is 7.8, indicating a high severity level.
How To Fix
Minimum fixed version
1.9.5p2-r0
This is the first release that contains the fix.
sudo apk add --upgrade sudo
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If immediate patching is not feasible, consider disabling SELinux or switching to a more restrictive mode until the package can be updated. However, this is not recommended as a long-term solution.
Conclusion
CVE-2021-23240 is a significant vulnerability in the Sudo package that can lead to privilege escalation for local unprivileged users. It is crucial to update to the patched versions to mitigate this risk. Users are encouraged to utilize tools like Vulert to monitor their applications for vulnerabilities.
See every vulnerability recorded for sudo →
FAQ
CVE-2021-23240 is a vulnerability in the Sudo package that allows local unprivileged users to escalate their privileges by exploiting a flaw in the sudoedit functionality.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.
If exploited, this vulnerability can allow an unprivileged user to gain elevated privileges, potentially leading to unauthorized access and control over the system.
While the best solution is to update the package, you can temporarily disable SELinux or switch to a more restrictive mode as a workaround.
Sudo versions prior to 1.9.5 are affected across multiple Alpine Linux distributions, including v3.10, v3.11, v3.12, v3.13, v3.14, and v3.15.
References
Related vulnerabilities
Recent vulnerabilities recorded for sudo.