CVE-2026-81695 in openssl_encrypt
Summary
by MITRE • 08/27/2026
openssl_encrypt versions before 1.4.9 fail to escape attacker-controlled key_id values printed to stderr during decrypt auto-detection. Attackers can craft encrypted files with malicious key_id containing escape sequences to repaint terminal output and forge authenticity verification blocks.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 08/27/2026
The vulnerability in openssl_encrypt prior to version 1.4.9 represents a significant security flaw rooted in improper input validation and output handling during the decryption process. Specifically, when the library performs auto-detection of encryption parameters, it extracts a key identifier from the encrypted payload and prints this value directly to the standard error stream without applying necessary escaping mechanisms. This oversight allows an attacker who controls the content of the encrypted file to inject arbitrary terminal escape sequences into the output generated by the application using openssl_encrypt. The core technical flaw lies in the failure to sanitize or encode special characters that have meaning within a terminal emulator environment, treating user-controlled data as safe literal text rather than potentially executable control codes.
From an operational perspective, this vulnerability enables a class of attacks known as Terminal Injection or ANSI Escape Code injection. By crafting malicious encrypted files containing specific byte sequences corresponding to ANSI escape codes, an attacker can manipulate the visual presentation of the terminal output. This capability goes beyond simple cosmetic changes; it allows for sophisticated social engineering and security bypass techniques. For instance, attackers can repaint parts of the screen to display forged authenticity verification blocks or misleading status messages that appear legitimate but are actually fabricated by the injected code. This deception can trick system administrators or automated monitoring systems into believing that a decryption operation was successful when it may have failed, or conversely, masking errors that should be visible for debugging purposes.
The impact of this vulnerability is particularly severe in environments where openssl_encrypt output is piped to logs, displayed on consoles, or processed by scripts that rely on the visual integrity of terminal output. In automated pipelines, if a script parses stderr to determine success or failure based on specific text patterns, an attacker could inject sequences that alter these patterns, leading to incorrect decision-making within the automation workflow. Furthermore, in interactive sessions, this vulnerability can be used for phishing-like attacks where the user is presented with fake prompts or warnings designed to extract credentials or induce them into executing malicious commands under false pretenses. The ability to repaint terminal output effectively breaks the trust model of the command-line interface, as users can no longer rely on what they see being an accurate reflection of system state.
This vulnerability aligns closely with CWE-134: Use of Externally-Controlled Format String and CWE-798: Use of Hard-coded Credentials if the key_id is used for authentication logic, but more accurately maps to CWE-20: Improper Input Validation regarding the lack of sanitization before output. In terms of offensive security frameworks, this behavior facilitates techniques described in MITRE ATT&CK under T1608: Link Exploitation or potentially T1537: Transfer Data to Cloud Account if used for exfiltration disguises, though its primary classification is within the realm of client-side code injection via terminal manipulation. The attack vector requires the victim to decrypt a file controlled by an adversary, which may be delivered through email attachments, compromised repositories, or malicious updates depending on the application context.
Mitigation strategies must focus primarily on upgrading to openssl_encrypt version 1.4.9 or later where this issue has been addressed with proper escaping of key identifiers before printing. For systems that cannot immediately upgrade, developers should implement a workaround by manually sanitizing any output derived from decryption processes. This involves filtering out non-printable characters and specifically targeting ANSI escape sequences such as those starting with the ESC character (ASCII 27) followed by bracket or parenthesis commands. Additionally, applications should avoid printing sensitive internal states like key identifiers to stderr in production environments unless absolutely necessary for debugging, and if they must do so, these outputs should be logged securely rather than displayed directly on user-facing terminals where visual manipulation is possible. Regular security audits of code paths that handle external data before outputting it to interactive displays are essential to prevent similar injection vulnerabilities across the software stack.