CVE-2023-28486 Overview
CVE-2023-28486 is an Improper Encoding or Escaping of Output vulnerability (CWE-116) affecting Sudo versions prior to 1.9.13. The vulnerability exists because Sudo does not properly escape control characters in log messages, potentially allowing attackers to inject malicious content into system logs or manipulate log output for obfuscation purposes.
Critical Impact
Attackers can inject control characters into sudo log messages, enabling log injection attacks that could corrupt log integrity, hide malicious activity, or potentially exploit log processing tools through terminal escape sequences.
Affected Products
- Sudo Project Sudo (versions before 1.9.13)
- NetApp Active IQ Unified Manager for VMware vSphere
Discovery Timeline
- 2023-03-16 - CVE-2023-28486 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2023-28486
Vulnerability Analysis
This vulnerability stems from insufficient output encoding in Sudo's logging functionality. When Sudo logs command execution, it writes various details including the username, TTY, working directory, and executed commands to either syslog or a local log file. Prior to version 1.9.13, these log entries did not properly escape control characters, meaning any control characters present in logged data would be written verbatim.
The lack of proper encoding creates multiple security concerns. Terminal escape sequences embedded in log data could manipulate terminal output when administrators review logs, potentially hiding malicious entries or displaying misleading information. Additionally, log processing tools that parse sudo logs might be vulnerable to injection attacks if they interpret unescaped control characters.
Root Cause
The root cause is the absence of proper output encoding when writing to log destinations. Sudo versions before 1.9.13 failed to sanitize control characters (such as carriage returns #015, horizontal tabs #011, and other non-printable characters) before writing them to syslog or local log files. This allowed arbitrary control sequences to be preserved in log output, violating the principle of proper output encoding (CWE-116).
Attack Vector
The attack vector is network-accessible and requires no authentication or user interaction. An attacker who can influence data that gets logged by sudo (such as command arguments, usernames, or paths) could inject control characters into these fields. When these control characters are written to logs without escaping, they can:
- Corrupt log file integrity by injecting carriage returns that overwrite previous log lines
- Execute terminal escape sequences when logs are viewed in a terminal
- Potentially exploit vulnerabilities in log parsing tools
- Obfuscate malicious activity by manipulating how log entries appear
The fix implemented in Sudo 1.9.13 formats control characters in octal notation with a leading # character. For example, a horizontal tab becomes #011 and a carriage return becomes #015. Additionally, space characters in command paths are stored as #040, and command line arguments containing spaces are enclosed in single quotes for disambiguation.
syslog(3),
to a local log file, or both.
The log format is almost identical in both cases.
+Any control characters present in the log data are formatted in octal
+with a leading
+\(oq#\(cq
+character.
+For example, a horizontal tab is stored as
+\(oq#011\(cq
+and an embedded carriage return is stored as
+\(oq#015\(cq.
+In addition, space characters in the command path are stored as
+\(oq#040\(cq.
+Command line arguments that contain spaces are enclosed in single quotes
+('').
+This makes it possible to distinguish multiple command line arguments
+from a single argument that contains spaces.
+Literal single quotes and backslash characters
+(\(oq\e\(cq)
+in command line arguments are escaped with a backslash.
.SS "Accepted command log entries"
Commands that sudo runs are logged using the following format (split
into multiple lines for readability):
.nf
.sp
.RS 4n
-date hostname progname: username : TTY=ttyname ; PWD=cwd ; \e
- USER=runasuser ; GROUP=runasgroup ; TSID=logid ; \e
+date hostname progname: username : TTY=ttyname ; CHROOT=chroot ; \e
+ PWD=cwd ; USER=runasuser ; GROUP=runasgroup ; TSID=logid ; \e
Source: GitHub Commit 334daf92
Detection Methods for CVE-2023-28486
Indicators of Compromise
- Presence of raw control characters (bytes 0x00-0x1F, excluding standard whitespace) in sudo log files
- Log entries that appear to overwrite or corrupt previous entries when viewed
- Unusual terminal behavior when reviewing /var/log/auth.log or sudo-specific logs
- Log entries with unexpected formatting or missing portions that could indicate carriage return injection
Detection Strategies
- Implement log file integrity monitoring to detect unexpected modifications or anomalous entries in sudo logs
- Use log analysis tools that can identify non-printable control characters in log streams
- Monitor for sudo version strings in system inventory to identify unpatched instances running versions below 1.9.13
- Deploy file integrity monitoring (FIM) on critical log files to detect potential tampering
Monitoring Recommendations
- Configure centralized logging with a SIEM solution that normalizes and sanitizes log input before storage
- Enable verbose sudo logging with log_input and log_output options to capture full command context
- Implement alerting for any detected control character sequences in incoming sudo log data
- Regularly audit sudo configurations across the infrastructure to ensure consistent logging standards
How to Mitigate CVE-2023-28486
Immediate Actions Required
- Upgrade Sudo to version 1.9.13 or later on all affected systems immediately
- Review existing sudo logs for signs of exploitation or log injection attempts
- Implement network segmentation to limit exposure of systems that cannot be immediately patched
- Consider temporarily restricting sudo access to trusted users until patching is complete
Patch Information
The vulnerability has been addressed in Sudo version 1.9.13. The fix ensures that all control characters in log data are formatted in octal notation with a leading # character, preventing raw control sequences from being written to logs. The official patch is available through the GitHub commit 334daf92b31b79ce68ed75e2ee14fca265f029ca and the Sudo 1.9.13 release.
Distribution-specific patches are available:
Workarounds
- Route sudo logs through a log sanitization layer that strips or encodes control characters before storage
- Use centralized logging systems that automatically normalize and escape special characters
- Implement strict input validation on systems where sudo command arguments can be influenced by untrusted input
- Consider using sudoreplay with version 1.9.13+ to safely review historical session logs with proper escaping
# Check current sudo version
sudo --version | head -1
# Update sudo on Debian/Ubuntu systems
sudo apt update && sudo apt install sudo
# Update sudo on RHEL/CentOS systems
sudo yum update sudo
# Update sudo on Fedora systems
sudo dnf update sudo
# Verify updated version (should be 1.9.13 or later)
sudo --version | head -1
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

