Today, we'll be discussing a prevalent security vulnerability known as CVE-2023-22809 found in Sudo versions ranging from 1.8. to 1.9.12.p1. Sudo is a widely used software present in many Unix-based systems, allowing users to execute commands with the security privileges of another user, primarily with the superuser or root privileges. However, a significant flaw involving the sudoedit feature could potentially lead to privilege escalation for malicious users.


The problem revolves around the sudoedit feature (represented by the -e option). The vulnerability arises from the mishandling of extra arguments passed in the user-provided environment variables – specifically, SUDO_EDITOR, VISUAL, and EDITOR. With this flaw, local attackers can append arbitrary entries to the list of files to process, effectively allowing them to escalate their privileges on the affected system.

To better understand this, let's take a look at a code snippet that demonstrates the vulnerability

EDITOR='vim -- /path/to/extra/file'
sudoedit /path/to/target/file

In this example, we can see that the EDITOR environment variable has an additional "--" argument, which separates the normal command-line options from other arguments. This "--" argument should serve as a protection mechanism, but unfortunately, in affected versions of Sudo, this fails to work as intended, enabling malicious users to exploit the system.

For more information about this vulnerability, you can refer to the following resources

1. Original CVE details:
2. Security advisory from the Sudo project:

Exploit Details

To exploit the CVE-2023-22809 vulnerability, a local attacker can craft a specific command containing the EDITOR, VISUAL, or SUDO_EDITOR environment variable with the "--" argument, followed by an arbitrary entry, such as another file.

The attacker can then use the sudoedit feature to edit a file without actually opening the file. Instead, the attacker can create a new file with the desired content and root privileges. With this unparalleled access, the attacker can perform various malicious activities, compromise the system's security, or gain unauthorized access to sensitive data.


CVE-2023-22809 is a critical vulnerability in the sudoedit feature of Sudo, allowing local attackers to perform privilege escalation on various Unix-based systems. Affected versions range from 1.8. to 1.9.12.p1, and users are encouraged to update their Sudo software to the most recent version. Additionally, closely monitoring and restricting environment variables such as SUDO_EDITOR, VISUAL, and EDITOR can mitigate the exploitation risk. Staying informed and vigilant is crucial to protect your system from such threats.


Published on: 01/18/2023 17:15:00 UTC
Last modified on: 04/03/2023 20:15:00 UTC