CVE-2026-102938: Virtualenv Virtualenv Writes Prompt Values Into Vulnerability

MODERATE
Advisory Identifier: GHSA-9h9j-4vrj-gf7g
CWE-93
Published
Advisory Summary

CVE-2026-102938 is a MODERATE virtualenv writes prompt values into vulnerability (CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')) affecting Virtualenv libraries in the PyPI ecosystem. The issue involves virtualenv writes prompt values into pyvenv.cfg without sanitizing line boundaries, allowing configuration injection. Remediation is available by upgrading affected packages to version 21.7.11.

CVE-2026-102938 at a Glance

CVE Identifier CVE-2026-102938
GHSA Identifier GHSA-9h9j-4vrj-gf7g
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')
Affected Product Virtualenv
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-102938

To remediate this vulnerability, upgrade all affected Virtualenv dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

virtualenv fixed: 21.7.11
pip install virtualenv>=21.7.11
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show virtualenv

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-102938, inspect your installed packages using pip:

pip show virtualenv

Analyze the terminal output to locate any version of Virtualenv in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 21.7.11), your application is affected.

Note: The pip show virtualenv command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection'), where the product uses crlf (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes crlf sequences from inputs. In Virtualenv, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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`: ```console $ 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`.

CVE-2026-102938 Affected Virtualenv Versions

1 component(s)
Fixed Versions:
21.7.11
Product / Package Ecosystem Affected Versions Fixed Version
virtualenv
PyPI
< 21.7.11
21.7.11

References

Frequently Asked Questions

What is CVE-2026-102938?
CVE-2026-102938 is a security vulnerability in Virtualenv involving virtualenv writes prompt values into pyvenv.cfg without sanitizing line boundaries, allowing configuration injection under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection').
Which Virtualenv versions are affected?
Affected versions include releases prior to 21.7.11 across affected packages: virtualenv.
What version fixes CVE-2026-102938?
Upgrading to 21.7.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is virtualenv affected?
Yes, virtualenv is affected in releases prior to 21.7.11. Upgrade your dependency to 21.7.11 or later.
What CWE is associated with CVE-2026-102938?
CVE-2026-102938 is classified under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') (The product uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.).
How can I check PyPI dependencies for CVE-2026-102938?
Run the dependency tree command: 'pip show virtualenv'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9h9j-4vrj-gf7g",
  "modified" : "2026-09-30T23:53:58Z",
  "published" : "2026-09-30T23:53:58Z",
  "aliases" : [ "CVE-2026-102938" ],
  "summary" : "virtualenv writes prompt values into pyvenv.cfg without sanitizing line boundaries, allowing configuration injection",
  "details" : "### Summary\n\n`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.\n\n### Impact\n\nThe `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`:\n\n```console\n$ virtualenv --prompt $'x\"\\nhome = /attacker/path\\nprompt = \"z' venv\n$ grep '^home' venv/pyvenv.cfg\nhome = /attacker/path\n```\n\n`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.\n\nThis 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.\n\n### Details\n\nThe 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.\n\n### Patches\n\n`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`.\n\n### Workarounds\n\nDo not pass externally influenced data as the virtualenv prompt. Strip line boundaries from any value before using it as `--prompt` or `VIRTUALENV_PROMPT`.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:L/VI:H/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "virtualenv"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "21.7.11"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 21.7.10"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pypa/virtualenv/security/advisories/GHSA-9h9j-4vrj-gf7g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-102938"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/virtualenv/pull/3247"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/virtualenv/commit/a30f995461043acb6cacbf3a890951563ccf7140"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/virtualenv/PYSEC-2026-4012.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pypa/virtualenv"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/virtualenv/releases/tag/21.7.11"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/virtualenv"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-93" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-30T23:53:58Z",
    "nvd_published_at" : "2026-09-29T21:17:19Z"
  }
}