---
id: CVE-2026-113776
aliases:
  - GHSA-8rjx-v5ww-45pp
  - BIT-virtualenv-2026-113776
title: >-
  virtualenv activation scripts run code from a path that contains a placeholder
  name
summary: >-
  virtualenv activation scripts run code from a path that contains a placeholder
  name
severity: high
cvss: 7.8
cvssVector: 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'
vendor: virtualenv
product: virtualenv
ecosystem: pip
affected:
  - 'virtualenv >= 20.26.6, < 21.14.2'
patched:
  - virtualenv 21.14.2
published: '2026-10-21'
updated: '2026-10-29'
sourceUpdated: '2026-10-29T10:55:59.336337258Z'
source: OSV
sourceUrl: 'https://osv.dev/vulnerability/GHSA-8rjx-v5ww-45pp'
references:
  - url: 'https://github.com/pypa/virtualenv/security/advisories/GHSA-8rjx-v5ww-45pp'
  - url: 'https://nvd.nist.gov/vuln/detail/CVE-2026-113776'
  - url: >-
      https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74
  - url: 'https://github.com/pypa/virtualenv'
  - url: 'https://github.com/pypa/virtualenv/releases/tag/21.14.2'
  - url: 'https://github.com/advisories/GHSA-8rjx-v5ww-45pp'
  - url: >-
      https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-113776.json
  - url: 'https://access.redhat.com/security/cve/CVE-2026-113776'
  - url: 'https://bugzilla.redhat.com/show_bug.cgi?id=2557581'
  - url: 'https://www.cve.org/CVERecord?id=CVE-2026-113776'
tags:
  - osv
  - pip
  - cve.org
  - ghsa
  - csaf
  - vex
  - red-hat
epss: 0.00269
epssPercentile: 0.19065
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: total
  timestamp: '2026-10-28T14:53:53.156314Z'
cwe:
  - CWE-78
  - CWE-94
ingestedAt: '2026-10-20T22:23:33.690Z'
---

## Overview

### Impact

`ViaTemplateActivator.instantiate_template` replaces the placeholders in an activation template one key at a time, each across the whole text. When a value that it already substituted and quoted contains the name of a later placeholder, the later pass rewrites that name inside the quoted literal. The inserted value brings its own quotes, which close the outer literal, and the rest of the path runs as code when a user activates the environment.

`__VIRTUAL_NAME__` holds the environment's directory name, so a destination such as `A__VIRTUAL_NAME__B/x'$(touch PWNED)'y` is enough. In the default `activate` for bash, the `VIRTUAL_ENV` line renders as:

```sh
VIRTUAL_ENV='/tmp/t/A'x'"'"'$(touch PWNED)'"'"'y'B/x'"'"'$(touch PWNED)'"'"'y'
```

Sourcing that script runs `touch PWNED`. The same payload in a path without the placeholder name runs nothing. `activate.fish` runs the command the same way, and the reporter also showed Python code execution through `activate.xsh` and `bin/activate_this.py`. In `activate.csh`, a directory named after a prompt display placeholder, such as `__VIRTUAL_PROMPT_DISPLAY_TCSH__`, breaks the script with `Unmatched '''`.

No change to `quote()` can stop this, because the rewrite happens after `quote()` ran; it defeats `shlex.quote` and `repr()` alike.

An attacker needs to influence the destination path or `--prompt`: a CI job or wrapper tool that builds the path from a branch or project name, or a directory in a cloned repository or unpacked archive.

The bug affects versions 20.26.6 through 21.14.1. Version 20.26.6 first quoted template values (#2768) and introduced the per-key loop.

### Patches

Fixed in 21.14.2. Activation scripts now keep a placeholder name in the environment's path or prompt as plain text, and activating the example above runs nothing. Fix: https://github.com/pypa/virtualenv/commit/602b26623a724827ff171bf11fef4ad186d01f74

### Workarounds

Do not create an environment whose path or `--prompt` contains a placeholder name such as `__VIRTUAL_NAME__`, `__VIRTUAL_ENV__` or `__VIRTUAL_PROMPT__`, and inspect the generated activation script before you source one you did not create.

### Credits

Kevin Stubbings (@Kwstubbs) of GitHub Security Lab reported this issue.

## Affected packages

- `virtualenv >= 20.26.6, < 21.14.2`

## Remediation

Upgrade to a patched release:

- `virtualenv 21.14.2`

## Vendor advisories

- **Red Hat VEX** · Important · affected: OpenShift Lightspeed, Red Hat Ansible Automation Platform 2, Red Hat OpenShift AI (RHOAI), Red Hat OpenShift Container Platform 4, Red Hat OpenShift Dev Spaces, Red Hat Satellite 6 · no fix planned: OpenShift Lightspeed, Red Hat Ansible Automation Platform 2, Red Hat OpenShift AI (RHOAI), Red Hat OpenShift Container Platform 4, … · updated 2026-10-21 · [vex](https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-113776.json)
