# CVE-2024-9287: Virtual environment (venv) activation scripts don't quote paths

> Attackers can inject commands into virtual environment activation scripts, leading to code execution when the environment is activated.

- **Severity:** Medium 5.3 (`CVSS:4.0/AV:L/AC:L/AT:P/PR:H/UI:A/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/U:Green`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 22 Oct 2024
- **Updated:** 3 Nov 2025
- **Also known as:** ALPINE-CVE-2024-9287, ALSA-2024:10979, ALSA-2024:11111, AZL-109677, AZL-50757, AZL-50926, BELL-CVE-2024-9287, BIT-libpython-2024-9287, BIT-python-2024-9287, BIT-python-min-2024-9287, CLEANSTART-2026-HT85293, CLSA-2024-1734543773, CLSA-2024-1734543883, CLSA-2025-1736503464, CLSA-2025-1736856534, CLSA-2025-1740132042, CLSA-2025-1740133056, CLSA-2025-1742466441, CLSA-2025-1747854434, CLSA-2025-1748638245, DEBIAN-CVE-2024-9287, GHSA-grqq-hcc7-crmr, MINI-58p4-mr75-8www, MINI-5wc3-m369-6w42, MINI-8xh2-w695-gm5x, MINI-pxj3-wgr4-3ff7, OESA-2024-2481, OESA-2024-2482, OESA-2024-2483, OESA-2024-2484, PSF-2024-12, RHSA-2024:10979, RHSA-2024:11024, RHSA-2024:11111, RHSA-2025:0280, RLSA-2024:10979, RLSA-2024:11111, SUSE-SU-2024:3760-1, SUSE-SU-2024:3879-1, SUSE-SU-2024:3924-1, SUSE-SU-2024:3929-1, SUSE-SU-2024:3944-1, SUSE-SU-2024:3945-1, SUSE-SU-2024:3957-1, SUSE-SU-2024:3958-1, SUSE-SU-2024:3959-1, SUSE-SU-2025:0048-1, UBUNTU-CVE-2024-9287, USN-7116-1, openSUSE-SU-2024:14426-1, openSUSE-SU-2024:14427-1, openSUSE-SU-2024:14428-1, openSUSE-SU-2024:14430-1, openSUSE-SU-2024:14455-1, openSUSE-SU-2024:14456-1

## What is CVE-2024-9287?

CVE-2024-9287 is a medium-severity command injection vulnerability in Python Python, published on 22 Oct 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

A vulnerability has been found in the CPython `venv` module and CLI where path names provided when creating a virtual environment were not quoted properly, allowing the creator to inject commands into virtual environment "activation" scripts (ie "source venv/bin/activate"). This means that attacker-controlled virtual environments are able to run commands when the virtual environment is activated. Virtual environments which are not created by an attacker or which aren't activated before being used (ie "./venv/bin/python") are not affected.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-428 (Unquoted Search Path or Element)

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

3 open source packages ship an affected version, including libpython, python and python-min. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libpython` | Bitnami | All versions | 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1 |
| `python` | Bitnami | All versions | 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1 |
| `python-min` | Bitnami | All versions | 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1 |
| `python3.11` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-debug` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-devel` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-idle` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-libs` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-rpm-macros` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-test` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11-tkinter` | AlmaLinux:8 | All versions | 3.11.11-1.el8_10 |
| `python3.11` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-debug` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-devel` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-idle` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-libs` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-test` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11-tkinter` | AlmaLinux:9 | All versions | 3.11.9-7.el9_5.2 |
| `python3.11` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-libs` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-rpm-macros` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-tkinter` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11.11-1.el8_10 |
| `python3.11` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-debug` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-debuginfo` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-debugsource` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-idle` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-test` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11-tkinter` | Red Hat:enterprise_linux:8::crb | All versions | 0:3.11.11-1.el8_10 |
| `python3.11` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-devel` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-libs` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-tkinter` | Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11` | Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.9-7.el9_5.2 |
| `python3.11-debug` | Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.9-7.el9_5.2 |

Products: Python Python.

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

Upgrade libpython to a fixed version for your release line: 3.9.21, 3.10.16, 3.11.11 or 3.12.8.

## Is CVE-2024-9287 being exploited?

There is no known exploitation of CVE-2024-9287 in the wild and no public exploit code.

## Other vulnerabilities in Python Python

- [CVE-2008-5031](https://insights.sbomify.com/CVE-2008-5031/): Integer overflow in n/a (critical 10.0)
- [CVE-2014-4650](https://insights.sbomify.com/CVE-2014-4650/): Path traversal in n/a (critical 9.8)
- [CVE-2016-5636](https://insights.sbomify.com/CVE-2016-5636/): Integer overflow in n/a (critical 9.8)
- [CVE-2007-4559](https://insights.sbomify.com/CVE-2007-4559/): Path traversal in n/a (critical 9.8)
- [CVE-2017-17522](https://insights.sbomify.com/CVE-2017-17522/): Command injection in n/a (high 8.8)

## Fix prompt for AI coding agents

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

What it is: CVE-2024-9287 is a medium-severity command injection vulnerability in Python Python, published on 22 Oct 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-9287 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected all versions; fixed in 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1
- python (Bitnami): affected all versions; fixed in 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1
- python-min (Bitnami): affected all versions; fixed in 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1

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-9287/ (Markdown: https://insights.sbomify.com/CVE-2024-9287/index.md)
```

## Sources

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

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