# CVE-2024-53899: virtualenv allows command injection through activation scripts for a virtual environment

> Attackers can execute arbitrary commands via unquoted magic template strings in virtual environment activation scripts.

- **Severity:** High 8.4 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Nov 2024
- **Updated:** 24 Nov 2024
- **Also known as:** ALSA-2024:10953, AZL-53417, AZL-53645, BELL-CVE-2024-53899, BIT-virtualenv-2024-53899, CLSA-2026-1771855453, CLSA-2026-1771855894, CLSA-2026-1792510471, CLSA-2026-1792629041, CLSA-2026-1792629147, DEBIAN-CVE-2024-53899, ECHO-4ff8-0678-a958, GHSA-rqc4-2hc7-8c8v, OESA-2025-1241, PYSEC-2024-187, RHSA-2024:10953, RHSA-2024:11048, RHSA-2024:11091, RHSA-2024:11093, RHSA-2024:11094, RHSA-2025:0002, RLSA-2024:10953, ROOT-APP-PYPI-CVE-2024-53899, SUSE-SU-2024:4093-1, SUSE-SU-2024:4143-1, UBUNTU-CVE-2024-53899, USN-7271-1, USN-7271-2, openSUSE-SU-2025:15252-1

## What is CVE-2024-53899?

CVE-2024-53899 is a high-severity command injection vulnerability in n/a, published on 24 Nov 2024. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

virtualenv before 20.26.6 allows command injection through the activation scripts for a virtual environment. Magic template strings are not quoted correctly when replacing. NOTE: this is not the same as CVE-2024-9287.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-78 (Improper Neutralization of Special Elements used in an OS Command)

## Which versions are affected by CVE-2024-53899?

4 open source packages ship an affected version, including virtualenv. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `virtualenv` | Bitnami | All versions | 20.26.6 |
| `virtualenv` | PyPI | All versions | 20.26.6 |
| `virtualenv` | PyPI | All versions | 20.26.6 |
| `virtualenv` | PyPI | All versions | 20.26.6 |
| `python-nose-docs` | AlmaLinux:8 | All versions | 1.3.7-31.module_el8.9.0+3700+efebe9fd |
| `python-pymongo-doc` | AlmaLinux:8 | All versions | 3.7.0-1.module_el8.9.0+3700+efebe9fd |
| `python-sqlalchemy-doc` | AlmaLinux:8 | All versions | 1.3.2-3.module_el8.10.0+3769+3838165b |
| `python-virtualenv-doc` | AlmaLinux:8 | All versions | 15.1.0-23.module_el8.10.0+3937+b6a3652f |
| `python3-PyMySQL` | AlmaLinux:8 | All versions | 0.10.1-2.module_el8.9.0+3700+efebe9fd |
| `python3-bson` | AlmaLinux:8 | All versions | 3.7.0-1.module_el8.9.0+3700+efebe9fd |
| `python3-distro` | AlmaLinux:8 | All versions | 1.4.0-2.module_el8.9.0+3700+efebe9fd |
| `python3-docs` | AlmaLinux:8 | All versions | 3.6.7-2.module_el8.9.0+3700+efebe9fd |
| `python3-docutils` | AlmaLinux:8 | All versions | 0.14-12.module_el8.9.0+3700+efebe9fd |
| `python3-nose` | AlmaLinux:8 | All versions | 1.3.7-31.module_el8.9.0+3700+efebe9fd |
| `python3-pygments` | AlmaLinux:8 | All versions | 2.2.0-22.module_el8.9.0+3700+efebe9fd |
| `python3-pymongo` | AlmaLinux:8 | All versions | 3.7.0-1.module_el8.9.0+3700+efebe9fd |
| `python3-pymongo-gridfs` | AlmaLinux:8 | All versions | 3.7.0-1.module_el8.9.0+3700+efebe9fd |
| `python3-scipy` | AlmaLinux:8 | All versions | 1.0.0-21.module_el8.9.0+3700+efebe9fd |
| `python3-sqlalchemy` | AlmaLinux:8 | All versions | 1.3.2-3.module_el8.10.0+3769+3838165b |
| `python3-virtualenv` | AlmaLinux:8 | All versions | 15.1.0-23.module_el8.10.0+3937+b6a3652f |
| `python3-wheel` | AlmaLinux:8 | All versions | 1:0.31.1-3.module_el8.9.0+3700+efebe9fd |
| `python3-wheel-wheel` | AlmaLinux:8 | All versions | 1:0.31.1-3.module_el8.9.0+3700+efebe9fd |
| `python36` | AlmaLinux:8 | All versions | 3.6.8-39.module_el8.10.0+3769+3838165b |
| `python36-debug` | AlmaLinux:8 | All versions | 3.6.8-39.module_el8.10.0+3769+3838165b |
| `python36-devel` | AlmaLinux:8 | All versions | 3.6.8-39.module_el8.10.0+3769+3838165b |
| `python36-rpm-macros` | AlmaLinux:8 | All versions | 3.6.8-39.module_el8.10.0+3769+3838165b |
| `python-PyMySQL` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.10.1-2.module+el8.10.0+20784+edafcd43 |
| `python-distro` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.4.0-2.module+el8.10.0+20784+edafcd43 |
| `python-docs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.6.7-2.module+el8.10.0+20784+edafcd43 |
| `python-docutils` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.14-12.module+el8.10.0+20784+edafcd43 |
| `python-nose` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.3.7-31.module+el8.10.0+20784+edafcd43 |
| `python-nose-docs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.3.7-31.module+el8.10.0+20784+edafcd43 |
| `python-pygments` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.2.0-22.module+el8.10.0+20784+edafcd43 |
| `python-pymongo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.7.0-1.module+el8.10.0+20784+edafcd43 |
| `python-pymongo-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.7.0-1.module+el8.10.0+20784+edafcd43 |
| `python-pymongo-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.7.0-1.module+el8.10.0+20784+edafcd43 |
| `python-pymongo-doc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.7.0-1.module+el8.10.0+20784+edafcd43 |
| `python-sqlalchemy` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.3.2-3.module+el8.10.0+20981+3704b446 |
| `python-sqlalchemy-doc` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.3.2-3.module+el8.10.0+20981+3704b446 |
| `python-virtualenv` | Red Hat:enterprise_linux:8::appstream | All versions | 0:15.1.0-23.module+el8.10.0+22619+61b70790 |

Products: Virtualenv Virtualenv.

## How do I fix CVE-2024-53899?

Upgrade virtualenv to 20.26.6 or later.

## Is CVE-2024-53899 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-53899 exists.

## Other vulnerabilities in n/a

- [CVE-2026-22702](https://insights.sbomify.com/CVE-2026-22702/): virtualenv Has TOCTOU Vulnerabilities in Directory Creation (medium 4.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-53899 and fix it if it is affected.

What it is: CVE-2024-53899 is a high-severity command injection vulnerability in n/a, published on 24 Nov 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-53899 exists.

Affected packages and fixed versions:
- virtualenv (Bitnami): affected all versions; fixed in 20.26.6
- virtualenv (PyPI): affected all versions; fixed in 20.26.6
- virtualenv (PyPI): affected all versions; fixed in 20.26.6
- virtualenv (PyPI): affected all versions; fixed in 20.26.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-53899/ (Markdown: https://insights.sbomify.com/CVE-2024-53899/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-53899
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-53899
- OSV: https://osv.dev/vulnerability/CVE-2024-53899

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-53899/
Summaries are generated and may contain mistakes; the official description above is the record.
