All vulnerabilities
CVE-2026-102938BIT-virtualenv-2026-102938GHSA-9h9j-4vrj-gf7gPYSEC-2026-4012

virtualenv writes prompt values into pyvenv.cfg without sanitizing line boundaries, allowing configuration injection

pypa virtualenvpipLibraries & packages
CVSS
5.8Medium
ExploitationNo known exploitationNot in CISA KEV, which does not prove it is unexploitedCISA KEV
Exploit odds (EPSS)0.14%Chance of exploitation activity in the next 30 days, higher than 3% of CVEs. Scored 23 Oct 2026FIRST EPSS
Fixed in21.7.11Fixed versionGitHub
Published29 Sep 2026Updated 6 Oct 2026CVE List

What fixes it

  • 21.7.11virtualenv, pipGitHub
  • 21.7.11virtualenv, PyPIOSVpip install "virtualenv>=21.7.11"

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

Description

Summary

pyvenv.cfg is a line-based format with no escape syntax. PyEnvCfg.write() wrote values verbatim, while PyEnvCfg._read_values() parses the file with str.splitlines(). A value containing a line boundary therefore became additional configuration lines, and because reading is last-wins, the injected keys replaced any key written earlier in the file.

Impact

The prompt value is the reachable input: it is set by --prompt, by the VIRTUALENV_PROMPT environment variable, or from the config file, and write() emits prompt before home. A crafted prompt can therefore set home in the generated pyvenv.cfg:

$ virtualenv --prompt $'x"\nhome = /attacker/path\nprompt = "z' venv
$ grep '^home' venv/pyvenv.cfg
home = /attacker/path

home is what tooling reads to locate the base interpreter, so a consumer that trusts it can be pointed elsewhere. implementation, version_info, version, executable, command and virtualenv are also written before prompt and can be replaced the same way.

This requires the prompt to come from somewhere other than the person running the command, for example a CI job templating a branch name into it, tooling deriving an environment name from user-supplied data, or an inherited VIRTUALENV_PROMPT. Where the operator supplies the prompt directly they already control the command line, and the effect is corruption rather than privilege gain: the value is truncated at the boundary and read back with a dangling quote.

Details

The boundary set is the one str.splitlines() recognizes, which is wider than \n: \r, \v, \f, the file, group and record separators, U+0085, U+2028 and U+2029 were all written through unchanged and all split the line when read back.

Patches

PyEnvCfg.write() now collapses those boundaries to spaces as it serializes each line, so it cannot emit a structurally invalid file regardless of what a caller places in content.

Workarounds

Do not pass externally influenced data as the virtualenv prompt. Strip line boundaries from any value before using it as --prompt or VIRTUALENV_PROMPT.

Text from GitHub Advisory Database

Affected versions 53

  • virtualenv, pip<= 21.7.10GitHub
  • virtualenvaffected: < 21.7.11CVE List
  • virtualenv, PyPIfrom first release, fixed in 21.7.11OSV
  • virtualenv, PyPI0.8OSV
  • virtualenv, PyPI0.8.1OSV
  • virtualenv, PyPI0.8.2OSV
  • virtualenv, PyPI0.8.3OSV
  • virtualenv, PyPI0.8.4OSV
  • virtualenv, PyPI0.9OSV
  • virtualenv, PyPI0.9.1OSV
  • virtualenv, PyPI0.9.2OSV
  • virtualenv, PyPI1.0OSV
  • virtualenv, PyPI1.1OSV
  • virtualenv, PyPI1.10OSV
  • virtualenv, PyPI1.10.1OSV
  • virtualenv, PyPI1.11OSV
  • virtualenv, PyPI1.11.1OSV
  • virtualenv, PyPI1.11.2OSV
  • virtualenv, PyPI1.11.3OSV
  • virtualenv, PyPI1.11.4OSV
  • virtualenv, PyPI1.11.5OSV
  • virtualenv, PyPI1.11.6OSV
  • virtualenv, PyPI1.2OSV
  • virtualenv, PyPI1.3OSV
  • virtualenv, PyPI1.3.1OSV
  • virtualenv, PyPI1.3.2OSV
  • virtualenv, PyPI1.3.3OSV
  • virtualenv, PyPI1.3.4OSV
  • virtualenv, PyPI1.4OSV
  • virtualenv, PyPI1.4.1OSV
  • virtualenv, PyPI1.4.2OSV
  • virtualenv, PyPI1.4.3OSV
  • virtualenv, PyPI1.4.4OSV
  • virtualenv, PyPI1.4.5OSV
  • virtualenv, PyPI1.4.6OSV
  • virtualenv, PyPI1.4.7OSV
  • virtualenv, PyPI1.4.8OSV
  • virtualenv, PyPI1.4.9OSV
  • virtualenv, PyPI1.4rc1OSV
  • virtualenv, PyPI1.5OSV
  • virtualenv, PyPI1.5.1OSV
  • virtualenv, PyPI1.5.2OSV
  • virtualenv, PyPI1.6OSV
  • virtualenv, PyPI1.6.1OSV
  • virtualenv, PyPI1.6.2OSV
  • virtualenv, PyPI1.6.3OSV
  • virtualenv, PyPI1.6.4OSV
  • virtualenv, PyPI1.7OSV
  • virtualenv, PyPI1.7.1OSV
  • virtualenv, PyPI1.7.1.1OSV
  • virtualenv, PyPI1.7.1.2OSV
  • virtualenv, PyPI1.7.2OSV
  • virtualenv, PyPI1.8OSV

References 8