Impact
A local account can prepare a symbolic or hard link in the destination directory before virtualenv creates the environment. The virtualenv routine _generate() removes an existing output file only when Path.exists() is true, and PyEnvCfg.write() opens pyvenv.cfg without replacing a pre‑existing link. Consequently, a dangling link is left and the generated activation files are written to the target path the link points to, outside the intended environment tree. This flaw allows an attacker to cause virtualenv to create or overwrite files wherever the link points, potentially modifying system files or dropping malicious code, effectively elevating the attacker’s privilege within the host system. The weakness is an improper path handling that can be classified as CWE‑59.
Affected Systems
All installations of the pypa virtualenv package older than version 21.14.9, regardless of operating system, are affected because the flaw resides in the core environment creation logic.
Risk and Exploitability
The CVSS score of 4.5 indicates a moderate severity. The exploit requires the attacker to be able to create or modify a symbolic or hard link in the destination directory, which is a local privilege scenario. EPSS information is not available, and the vulnerability is not listed in the CISA KEV catalog, suggesting current exploitation activity is limited. However, because the bug permits unauthorized file writes outside the expected environment tree, the potential damage—from tampering with environment configuration to inserting malicious code—can be significant if an attacker can access the directory used for environment creation. The vulnerability is fixed in virtualenv 21.14.9; therefore the risk diminishes once the package is updated.
OpenCVE Enrichment
Github GHSA