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

Medium 5.3 Published Updated

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

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

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, CWE-428

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.

PackageAffectedFixed in
libpython BitnamiAll versions3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1
python BitnamiAll versions3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1
python-min BitnamiAll versions3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1
Linux distribution packages (37)
python3.11 AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-debug AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-devel AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-idle AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-libs AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-rpm-macros AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-test AlmaLinux:8All versions3.11.11-1.el8_10
python3.11-tkinter AlmaLinux:8All versions3.11.11-1.el8_10
python3.11 AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-debug AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-devel AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-idle AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-libs AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-test AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11-tkinter AlmaLinux:9All versions3.11.9-7.el9_5.2
python3.11 Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-debuginfo Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-debugsource Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-devel Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-libs Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-rpm-macros Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11-tkinter Red Hat:enterprise_linux:8::appstreamAll versions0:3.11.11-1.el8_10
python3.11 Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-debug Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-debuginfo Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-debugsource Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-idle Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-test Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11-tkinter Red Hat:enterprise_linux:8::crbAll versions0:3.11.11-1.el8_10
python3.11 Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11-debuginfo Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11-debugsource Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11-devel Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11-libs Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11-tkinter Red Hat:enterprise_linux:9::appstreamAll versions0:3.11.9-7.el9_5.2
python3.11 Red Hat:enterprise_linux:9::crbAll versions0:3.11.9-7.el9_5.2
python3.11-debug Red Hat:enterprise_linux:9::crbAll versions0:3.11.9-7.el9_5.2

Products include 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.

Upgrade, and pass arguments to programs as a list instead of through a shell. More about Command injection.

Is CVE-2024-9287 being exploited?

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

All Python Python vulnerabilities

Sources

Also known as ALPINE-CVE-2024-9287, ALSA-2024:10979, ALSA-2024:11111, AZL-109677, AZL-50757, AZL-50926 and 49 more.

Is CVE-2024-9287 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free