Privilege Escalation Vulnerability in Sudo Package: CVE-2021-23240

sudo Updated 02 Oct 2025

Summary

12/01/2021
N/A
Yes i
High
7.8

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for sudo.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback