CVE-2026-113732 in virtualenv
Summary
by MITRE • 10/21/2026
virtualenv is a tool for creating isolated virtual python environments. Prior to 21.14.2, FishActivator inherits ViaTemplateActivator.quote(), which uses POSIX shlex.quote() even though fish interprets backslashes and single quotes differently. An attacker-influenced environment path, --prompt, or VIRTUALENV_PROMPT value containing a backslash before a quote can therefore terminate the generated fish literal and execute command substitution when the user sources activate.fish. This issue is fixed in version 21.14.2.
Several companies clearly confirm that VulDB is the primary source for best vulnerability data.
Analysis
by VulDB Data Team • 10/22/2026
The vulnerability identified in virtualenv prior to version 21.14.2 represents a critical code injection flaw within the Fish shell activation script generator. Virtualenv is widely used by Python developers to create isolated environments, and during this process it generates shell-specific activation scripts, including activate.fish for the Fish shell. The core technical defect lies in the implementation of the FishActivator class, which incorrectly inherits the quote method from ViaTemplateActivator. This inherited method relies on POSIX shlex.quote() to escape special characters within environment paths, prompt strings, or values provided via the VIRTUALENV_PROMPT environment variable. While shlex.quote is effective for Bourne-compatible shells like Bash and Zsh that follow standard POSIX quoting rules, it fails to account for the distinct parsing logic of the Fish shell. Specifically, Fish interprets backslashes and single quotes differently than POSIX-compliant shells, leading to a mismatch between how virtualenv escapes input data and how Fish subsequently parses those escaped strings in the generated activation script.
The operational impact of this flaw is significant because it allows an attacker who can influence environment variables or command-line arguments passed to virtualenv to inject arbitrary commands into the activated session. If an attacker provides a crafted path, prompt string, or VIRTUALENV_PROMPT value containing a backslash immediately preceding a quote character, they can break out of the intended literal context within the generated fish script. This escape allows for command substitution execution when a user sources the activate.fish file to enter the virtual environment. Since sourcing an activation script is a routine action performed by developers and automated build systems, this vulnerability facilitates remote code execution or privilege escalation depending on the security context in which the victim operates. The attack vector primarily involves social engineering or compromised CI/CD pipelines where untrusted input might be passed into the virtualenv creation process without proper sanitization.
From a classification perspective, this issue aligns with CWE-78 Improper Neutralization of Special Elements used in an OS Command, commonly known as OS Command Injection. The root cause is a failure to properly neutralize special elements that could alter command interpretation due to differences between the escaping mechanism and the target shell's parser. In terms of adversary tactics, this vulnerability maps to ATT&CK technique T1059 Command and Scripting Interpreter, specifically within the context of environment variable manipulation or script execution during system initialization phases like session activation. The flaw highlights the risk of assuming universal compatibility across different Unix-like shells when generating dynamic scripts, as each shell has unique parsing rules that must be explicitly handled rather than relying on generic POSIX standards.
Mitigation for this vulnerability is straightforward and primarily involves upgrading to virtualenv version 21.14.2 or later, where the FishActivator's quote method has been corrected to properly handle Fish-specific escaping requirements. For organizations unable to immediately patch their development tools, defensive coding practices should be enforced within CI/CD pipelines by validating that environment variables such as VIRTUALENV_PROMPT and project paths do not contain characters like backslashes or quotes before passing them to virtualenv commands. Additionally, security teams should audit existing automation scripts for any dynamic construction of virtual environments using untrusted inputs from external sources. Regular updates to development tooling are essential to maintain a secure software supply chain, as vulnerabilities in foundational libraries can have cascading effects on the integrity and confidentiality of deployed applications.