CVE-2024-9287: Virtual environment (venv) activation scripts don't quote paths
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.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Virtual environment (venv) activation scripts don't quote paths
— Microsoft
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
azurelinux/python3to a version that resolves this vulnerability.Fixed in 3.9.19-11 - Upgrade
Upgrade
azurelinux/python3to a version that resolves this vulnerability.Fixed in 3.12.9-1 - Upgrade
Upgrade
alpine/python3to a version that resolves this vulnerability.Fixed in 3.11.11-r0 - Upgrade
Upgrade
alpine/python3to a version that resolves this vulnerability.Fixed in 3.12.8-r0 - Upgrade
Upgrade
debian/pypy3to a version that resolves this vulnerability.Fixed in 7.3.11+dfsg-2+deb12u3 - Upgrade
Upgrade
debian/pypy3to a version that resolves this vulnerability.Fixed in 7.3.17+dfsg-3 - Upgrade
Upgrade
debian/python3.11to a version that resolves this vulnerability.Fixed in 3.11.2-6+deb12u5 - Upgrade
Upgrade
debian/python3.13to a version that resolves this vulnerability.Fixed in 3.13.1-1 - Upgrade
Upgrade
debian/pypy3to a version that resolves this vulnerability.Fixed in 7.3.11+dfsg-2+deb12u3Fixed in 7.3.19+dfsg-2Fixed in 8.0.1+dfsg-1 - Upgrade
Upgrade
debian/python3.11to a version that resolves this vulnerability.Fixed in 3.11.2-6+deb12u8Fixed in 3.11.2-6+deb12u9 - Upgrade
Upgrade
debian/python3.13to a version that resolves this vulnerability.Fixed in 3.13.5-2+deb13u5Fixed in 3.13.18-1 - Compensating control
Do not activate virtual environments created by attackers or untrusted sources; invoke the virtual environment interpreter directly instead, such as "./venv/bin/python".
Event History
Frequently Asked Questions
What is the severity of CVE-2024-9287?
CVE-2024-9287 has been classified as a high-severity vulnerability due to the potential for command injection.
How do I fix CVE-2024-9287?
To remediate CVE-2024-9287, update to the latest version of Python that addresses this vulnerability.
Which versions of Python are affected by CVE-2024-9287?
CVE-2024-9287 affects multiple versions of Python including versions prior to 3.10.17, 3.11.11, 3.12.8, and 3.13.1.
What type of vulnerability is CVE-2024-9287?
CVE-2024-9287 is a command injection vulnerability due to improper quoting of path names in the CPython venv module.
How can I verify if my system is vulnerable to CVE-2024-9287?
You can verify your vulnerability by checking the version of Python installed on your system and comparing it to the affected versions of CVE-2024-9287.