virtualenv@21.14.8

Virtual Python Environment builder

  • latest version

    21.14.13

  • latest non vulnerable version

  • first published

    19 years ago

  • latest version published

    3 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the virtualenv package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • L
    Improper Validation of Integrity Check Value

    Affected versions of this package are vulnerable to Improper Validation of Integrity Check Value via the seed wheel acquisition logic in src/virtualenv/seed/wheels/acquire.py and pip_invoke.py, where wheels are cached and then passed to pip for installation without verifying their integrity before use. When the --find-links directories used by pip contain multiple wheel files matching a distribution, pip selects among them by filename, allowing a wheel that was placed in the cache directory prior to digest verification to be installed instead of the expected, verified wheel. An attacker who can write to the shared wheel cache directory can substitute a malicious wheel that pip then installs into the new virtual environment.

    How to fix Improper Validation of Integrity Check Value?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • M
    Insecure Temporary File

    Affected versions of this package are vulnerable to Insecure Temporary File via the FromAppData seeder in src/virtualenv/seed/embed/via_app_data/via_app_data.py when --symlink-app-data is used with a transient (temporary) app-data directory. Because the app-data directory is removed after virtualenv creation, symlinks placed into the new environment point to a now-deleted location, allowing a local attacker who can recreate that path to substitute malicious content and achieve arbitrary file writes into the virtual environment's site-packages.

    How to fix Insecure Temporary File?

    Upgrade virtualenv to version 21.14.10 or higher.

    [21.14.8,21.14.10)
    • M
    Incorrect Permission Assignment for Critical Resource

    Affected versions of this package are vulnerable to Incorrect Permission Assignment for Critical Resource in the copy and copytree functions within src/virtualenv/util/path/_sync.py, files copied into a new virtual environment are created via shutil.copy, which does not use exclusive creation flags and does not enforce safe permissions at creation time. A local attacker who can race the file-creation window can replace a copied file - such as a Python interpreter or activation script - with a malicious payload, leading to privilege escalation or arbitrary code execution in the context of the user activating or using the virtual environment. The fix introduces _copy_file, which opens the destination with O_CREAT | O_EXCL and applies a mode derived from the source file's execute bits, eliminating the race window.

    How to fix Incorrect Permission Assignment for Critical Resource?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via the onerror handler in src/virtualenv/util/path/_sync.py during directory tree removal on Windows. When a read-only file or directory cannot be deleted, the handler widens the entry's permissions using os.chmod before retrying the deletion, creating a race window in which another local user can access the target path with the temporarily elevated mode. An attacker who can traverse the parent directories of the target can exploit this window to read or modify files they would otherwise be denied access to.

    Note: This is only exploitable if another account can traverse the target's parent directories, and the widened mode is applied only transiently during the deletion retry on Windows.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Arbitrary Code Injection

    Affected versions of this package are vulnerable to Arbitrary Code Injection via the quote method in src/virtualenv/activation/xonsh/__init__.py, which uses repr() to encode string literals written into the xonsh activation script. Because repr() does not guarantee ASCII-safe output, non-ASCII characters in paths (such as a virtualenv directory containing Unicode characters) can be written into the activation script in a form that xonsh, depending on its source encoding, may misparse, allowing an attacker who controls the virtualenv path to inject and execute arbitrary code when a user activates the environment.

    How to fix Arbitrary Code Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    CRLF Injection

    Affected versions of this package are vulnerable to CRLF Injection via the validate_dest path in src/virtualenv/create/via_global_ref/venv.py when using the --creator venv backend, where a virtual environment destination path containing line boundary characters is written unescaped into pyvenv.cfg. An attacker who can influence the destination path can inject arbitrary lines into pyvenv.cfg, potentially corrupting the configuration or causing tools that parse it to read attacker-controlled key-value pairs.

    Note: This is only exploitable when the --creator venv option is explicitly used, as it is not the default creator backend.

    How to fix CRLF Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Command Injection

    Affected versions of this package are vulnerable to Command Injection via insufficient escaping of the VIRTUAL_ENV_PROMPT variable in src/virtualenv/activation/bash/activate.sh. When a virtual environment is activated in bash or zsh, the prompt string is interpolated into PS1 without fully neutralising backslashes, dollar signs, and backticks, allowing an attacker who controls the virtual environment's prompt value to inject arbitrary shell commands that execute in the context of the activating user's shell session.

    How to fix Command Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Directory Traversal

    Affected versions of this package are vulnerable to Directory Traversal via the _uninstall_dist method in src/virtualenv/seed/embed/via_app_data/pip_install/base.py, which fails to validate that paths listed in a distribution's RECORD or top_level.txt metadata files are contained within the virtual environment directory before deleting them. An attacker who can control the contents of a seed package's dist-info metadata can cause virtualenv to delete arbitrary files outside the environment boundary during an uninstall-previous-version operation.

    How to fix Directory Traversal?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via ViaTemplateActivator._generate() and PyEnvCfg.write(), which write generated activation scripts and pyvenv.cfg without first atomically replacing any existing symbolic or hard link at the destination path. ViaTemplateActivator._generate() only removes an existing output file when Path.exists() returns true, meaning a dangling symlink survives the check and redirects the generated activation content to an attacker-controlled location. Similarly, PyEnvCfg.write() opens pyvenv.cfg for writing without first unlinking an existing symbolic or hard link, allowing an attacker who can plant a symlink in the virtualenv output directory to redirect writes and corrupt or overwrite arbitrary files reachable by the creating user.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Command Injection

    Affected versions of this package are vulnerable to Command Injection via the seed mechanism's console script launcher rewriting logic in pip_invoke.py on POSIX systems. When a virtual environment is created and pip installs packages with console scripts, the interpreter path embedded in script shebangs may contain spaces, causing pip to generate a /bin/sh-based wrapper shebang. The _rewrite_launchers method rewrites these scripts to use the correct interpreter path but does so by unlinking and recreating the file, which can allow a local attacker with write access to the script directory to replace the file between the unlink and open calls, potentially gaining elevated execution privileges through the recreated script.

    How to fix Command Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Arbitrary Code Injection

    Affected versions of this package are vulnerable to Arbitrary Code Injection via the quote method in src/virtualenv/activation/xonsh/__init__.py, which uses repr() to encode string literals written into the xonsh activation script. Because repr() does not guarantee ASCII-safe output, non-ASCII characters in paths (such as a virtualenv directory containing Unicode characters) can be written into the activation script in a form that xonsh, depending on its source encoding, may misparse, allowing an attacker who controls the virtualenv path to inject and execute arbitrary code when a user activates the environment.

    How to fix Arbitrary Code Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Command Injection

    Affected versions of this package are vulnerable to Command Injection via the seed mechanism's console script launcher rewriting logic in pip_invoke.py when a virtual environment is created on POSIX systems with an interpreter path containing spaces. The _rewrite_launchers method rewrites pip-installed console script shebangs but fails to preserve the correct interpreter path, producing launchers that reference an incorrect or truncated executable. An attacker who can influence the virtual environment creation process or the scripts executed from it can leverage the malformed launchers to achieve arbitrary code execution with the privileges of the user invoking the script.

    How to fix Command Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • H
    Arbitrary Code Injection

    Affected versions of this package are vulnerable to Arbitrary Code Injection via insufficient escaping of the VIRTUAL_ENV_PROMPT variable in activate.sh, which allows an attacker who controls the virtual environment prompt string to inject arbitrary shell code. When the activation script constructs PS1 by interpolating VIRTUAL_ENV_PROMPT without fully neutralising backslashes, dollar signs, and backticks, a malicious prompt value causes arbitrary command execution in the activating shell session.

    How to fix Arbitrary Code Injection?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via the onerror handler in src/virtualenv/util/path/_sync.py, which previously called os.chmod on a path without first checking whether it is a symbolic link. On Windows, when a read-only file cannot be deleted during a tree removal, the handler widened the file's permissions using os.chmod before retrying the deletion. Because no link check was performed, an attacker who can place a symlink at the target path can cause the handler to widen the permissions of the symlink's target, leading to unauthorized modification of file attributes and potential information disclosure or integrity impact.

    Note: This is only exploitable if the attacker can traverse the target's parent directories to place a symlink at the affected path.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via ViaTemplateActivator._generate() in src/virtualenv/activation/via_template.py, which checks whether a destination file exists with Path.exists() before unlinking it and writing new content. A local attacker who can race the check-then-unlink-then-write sequence can substitute a symlink or file between the unlink and the subsequent write, causing virtualenv to write attacker-influenced content to an arbitrary path with the privileges of the virtualenv-creating process. The same pattern is present in several other file-writing paths (creator.py, pyenv_cfg.py, and related modules) that were consolidated into a new atomic write_file helper by the fix.

    Note: This is only exploitable when an existing output file is present at the destination path, triggering the Path.exists() / unlink() branch in ViaTemplateActivator._generate().

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Resources Downloaded over Insecure Protocol

    Affected versions of this package are vulnerable to Resources Downloaded over Insecure Protocol via the seed wheel acquisition logic in src/virtualenv/seed/wheels/acquire.py and pip_invoke.py, where wheels are cached and later reused without verifying their integrity before being passed to pip for installation. An attacker who can place a malicious wheel file in a shared or writable search directory can cause that unverified wheel to be installed into a newly created virtual environment, achieving supply-chain compromise of the seeded packages.

    Note: This is only exploitable when an attacker can write a wheel of the same name into a directory that virtualenv uses as a search or download path, and pip replaces a cached file only when the link's digest differs.

    How to fix Resources Downloaded over Insecure Protocol?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • M
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via the FromAppData seed mechanism in src/virtualenv/seed/embed/via_app_data/via_app_data.py, when symlink_app_data is enabled against a transient (temporary) app-data store. In this configuration, virtualenv creates symlinks from the newly created virtual environment's seed packages to temporary files that are deleted after setup completes, leaving the environment with dangling symlinks. An attacker who can write to the temporary directory before or after deletion can substitute malicious package files that the virtual environment then resolves through those symlinks, leading to arbitrary code execution within the environment.

    Note: This is only exploitable when symlink_app_data is enabled and virtualenv is configured to use a transient app-data store, either via environment variables or configuration files.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.10 or higher.

    [21.14.8,21.14.10)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via the create method in venv.py and via_global_self_do.py, where output directories are created without first verifying they reside within the intended virtual environment destination. An attacker who can plant a symlink or hard link at an expected output path (such as bin_dir, purelib, or platlib) can cause virtualenv to write files outside the virtual environment boundary, leading to arbitrary file writes in attacker-controlled locations.

    Note: This is only exploitable when an attacker can pre-position a symlink or hard link at an expected output directory path before virtualenv creates the environment, and does not require write access to the target itself.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Resources Downloaded over Insecure Protocol

    Affected versions of this package are vulnerable to Resources Downloaded over Insecure Protocol in the seed wheel acquisition logic (src/virtualenv/seed/wheels/acquire.py and src/virtualenv/seed/embed/pip_invoke.py) when resolving and caching seed wheels (pip, setuptools, wheel) for new virtual environments. The fix reveals that wheels were not verified before being placed into the cache and subsequently passed to pip for installation, allowing a MitM attacker or a compromised local cache to substitute a malicious wheel that pip would install without integrity checks. The patch introduces digest verification via verify_wheel_digest before caching, and copies only the selected, verified archives into an isolated temporary directory passed to pip via --find-links, preventing unverified wheels from participating in pip's filename-based selection.

    How to fix Resources Downloaded over Insecure Protocol?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)
    • L
    Symlink Attack

    Affected versions of this package are vulnerable to Symlink Attack via the create method in venv.py and via_global_self_do.py, where output directories are created without first verifying they reside within the intended virtual environment destination. An attacker who can plant a symlink or hard link at an expected output path (such as bin_dir, purelib, or platlib) can cause virtualenv to write files outside the virtual environment boundary, leading to arbitrary file writes in attacker-controlled locations.

    Note: This is only exploitable when an attacker can pre-position a symlink or hard link at an expected output directory path before virtualenv creates the environment, and does not require write access to the target itself.

    How to fix Symlink Attack?

    Upgrade virtualenv to version 21.14.9 or higher.

    [21.14.8,21.14.9)