CVE-2026-113732
Fish shell activation allows command injection via crafted path or prompt containing backslash‑quote.
- CVSS 7.8
- CWE-78
- Input Validation and Sanitization
- Local
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.
- CWE
- CWE-78
- CVSS base score
- 7.8
- Published
- 2026-10-20
- OWASP
- A03 Injection
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade virtualenv to version 21.14.2 or later.
Vulnerable code sample
import shlex
import os
class ViaTemplateActivator:
def quote(self, s: str) -> str:
# VULNERABLE: uses POSIX quoting for fish, allowing injection via backslash
return shlex.quote(s)
class FishActivator(ViaTemplateActivator):
def generate_activate_script(self, env_path: str, prompt: str = None) -> str:
parts = ["set -gx VIRTUAL_ENV", self.quote(env_path)]
if prompt:
parts.append("set -gx VIRTUAL_ENV_PROMPT")
parts.append(self.quote(prompt))
return " ".join(parts)
def create_activation(env_path: str, prompt: str = None):
activator = FishActivator()
script = activator.generate_activate_script(env_path, prompt)
return scriptPatched code sample
import os
class ViaTemplateActivator:
def quote(self, s: str) -> str:
# fallback POSIX quoting (not used by FishActivator)
import shlex
return shlex.quote(s)
class FishActivator(ViaTemplateActivator):
# FIX: use fish‑compatible quoting to neutralize backslashes and single quotes
def quote(self, s: str) -> str:
# fish quoting: wrap in single quotes and escape internal single quotes
escaped = s.replace("'", "'\\''")
return f"'{escaped}'"
def generate_activate_script(self, env_path: str, prompt: str = None) -> str:
parts = ["set -gx VIRTUAL_ENV", self.quote(env_path)]
if prompt:
parts.append("set -gx VIRTUAL_ENV_PROMPT")
parts.append(self.quote(prompt))
return " ".join(parts)
def create_activation(env_path: str, prompt: str = None):
activator = FishActivator()
script = activator.generate_activate_script(env_path, prompt)
return scriptPublished fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Merge commit from fork (pypa/virtualenv)
src/virtualenv/activation/fish/__init__.py
Cite this entry
@misc{vaitp:cve2026113732,
title = {{Fish shell activation allows command injection via crafted path or prompt containing backslash‑quote.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113732},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113732/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
