Cloudanix VulnDB

CVE-2024-9287

None

CVSS

—

EPSS

0.6%

Published

Oct 22, 2024

CISA due date

—

Cloudanix analysis

Schedule a fix SSVC: Track

A flaw in Python's virtual-environment tool can let a specially named folder run extra commands whenever someone activates that environment, which could give an attacker control of the computer.

Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Low
Impact
Remote Code Execution
Component
Library
Class
Command Injection
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

Improper quoting of user-supplied path names during virtual environment creation allows arbitrary command injection into generated activation scripts such as venv/bin/activate.

Why it matters to the business

Developers or automated pipelines that source activation scripts from attacker-supplied virtual environments can execute unintended commands, potentially leading to workstation or build-system compromise.

How an attack unfolds

An attacker supplies a path containing shell metacharacters when invoking python -m venv; the resulting activate script embeds the unquoted path, so any subsequent source venv/bin/activate executes the attacker's commands.

How to fix it

Upgrade CPython to a build containing commit 633555735a023d3e4d92ba31da35b1205f9ecbd7 or later; avoid sourcing activation scripts from untrusted virtual environments and prefer direct invocation of the venv interpreter.

How to confirm the fix worked

Confirm the installed CPython version includes commit 633555735a023d3e4d92ba31da35b1205f9ecbd7; test venv creation with a path containing spaces and single quotes and verify the activate script properly quotes the VIRTUAL_ENV variable.

Typical attack path

  1. Attacker crafts a directory path containing shell metacharacters
  2. Victim or CI job runs python -m venv with the malicious path
  3. Generated activation script is written with the unquoted path
  4. Victim or automation sources the activation script
  5. Embedded commands execute in the victim's shell context

How to detect it

Search shell history, CI logs, and filesystem for venv creation commands containing unusual characters; inspect generated activate scripts for unquoted $VIRTUAL_ENV or PATH assignments that include suspicious strings.

  • venv creation command containing single quotes, backticks, or dollar signs in the target path
  • activate script lines containing unquoted $VIRTUAL_ENV or PATH assignments with embedded shell syntax

What your security team should do

  • Prioritize patching CPython in all developer and CI images to the fixed commit
  • Audit scripts and documentation that instruct users to source venv activation files
  • Add static analysis or pre-commit hooks to detect unquoted VIRTUAL_ENV references

The record

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.

Affected packages

Ecosystem Package Introduced Fixed
AlmaLinux:8 platform-python 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 platform-python-debug 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 platform-python-devel 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 python3-idle 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 python3-libs 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 python3-test 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 python3-tkinter 0 3.6.8-69.el8_10.alma.1
AlmaLinux:8 python3.11 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-debug 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-devel 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-idle 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-libs 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-rpm-macros 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-test 0 3.11.11-1.el8_10
AlmaLinux:8 python3.11-tkinter 0 3.11.11-1.el8_10
AlmaLinux:8 python3.12 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-debug 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-devel 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-idle 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-libs 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-rpm-macros 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-test 0 3.12.8-1.el8_10
AlmaLinux:8 python3.12-tkinter 0 3.12.8-1.el8_10
AlmaLinux:8 python39 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-Cython 0 0.29.21-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-Cython 0 0.29.21-5.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-PyMySQL 0 0.10.1-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-attrs 0 20.3.0-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cffi 0 1.14.3-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cffi 0 1.14.3-2.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-chardet 0 3.0.4-19.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cryptography 0 3.3.1-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-debug 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-devel 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-idle 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-idna 0 2.10-4.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-iniconfig 0 1.1.1-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-libs 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-lxml 0 4.6.5-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-lxml 0 4.6.5-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-mod_wsgi 0 4.7.1-7.module_el8.10.0+3989+a618fe15.1
AlmaLinux:8 python39-more-itertools 0 8.5.0-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy 0 1.19.4-3.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-numpy-doc 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy-f2py 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy-f2py 0 1.19.4-3.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-packaging 0 20.4-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pip 0 20.2.4-9.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-pip-wheel 0 20.2.4-9.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-pluggy 0 0.13.1-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-ply 0 3.11-10.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-psutil 0 5.8.0-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-psutil 0 5.8.0-4.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-psycopg2 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-psycopg2-doc 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-psycopg2-tests 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-py 0 1.10.0-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11 0 2.7.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11 0 2.7.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-pybind11-devel 0 2.7.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11-devel 0 2.7.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-pycparser 0 2.20-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyparsing 0 2.4.7-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pysocks 0 1.7.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pytest 0 6.0.2-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyyaml 0 5.4.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyyaml 0 5.4.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-requests 0 2.25.0-3.module_el8.9.0+3634+fb2a896c
AlmaLinux:8 python39-rpm-macros 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-scipy 0 1.5.4-5.module_el8.9.0+3634+fb2a896c
AlmaLinux:8 python39-setuptools 0 50.3.2-7.module_el8.10.0+4040+9207bbc0
AlmaLinux:8 python39-setuptools-wheel 0 50.3.2-7.module_el8.10.0+4040+9207bbc0
AlmaLinux:8 python39-six 0 1.15.0-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-test 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-tkinter 0 3.9.25-2.module_el8.10.0+4083+53cad1fb
AlmaLinux:8 python39-toml 0 0.10.1-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-urllib3 0 1.25.10-5.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-wcwidth 0 0.2.5-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-wheel 0 1:0.35.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-wheel-wheel 0 1:0.35.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:9 python-unversioned-command 0 3.9.21-1.el9_5
AlmaLinux:9 python3 0 3.9.21-1.el9_5
AlmaLinux:9 python3-debug 0 3.9.21-1.el9_5
AlmaLinux:9 python3-devel 0 3.9.21-1.el9_5
AlmaLinux:9 python3-idle 0 3.9.21-1.el9_5
AlmaLinux:9 python3-libs 0 3.9.21-1.el9_5
AlmaLinux:9 python3-test 0 3.9.21-1.el9_5
AlmaLinux:9 python3-tkinter 0 3.9.21-1.el9_5
AlmaLinux:9 python3.11 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-debug 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-devel 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-idle 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-libs 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-test 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.11-tkinter 0 3.11.9-7.el9_5.2
AlmaLinux:9 python3.12 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-debug 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-devel 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-idle 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-libs 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-test 0 3.12.5-2.el9_5.2
AlmaLinux:9 python3.12-tkinter 0 3.12.5-2.el9_5.2
Alpine:v3.18 python3 0 3.11.11-r0
Alpine:v3.19 python3 0 3.11.11-r0
Alpine:v3.20 python3 0 3.12.8-r0
Alpine:v3.21 python3 0 3.12.8-r0
Alpine:v3.22 python3 0 3.12.8-r0
Bitnami libpython 0 3.9.21
Bitnami python 0 3.13.0
Bitnami python 0 3.9.21
Bitnami python-min 0 3.9.21
Chainguard python-3.10 0 3.10.15-r3
Chainguard python-3.10-base 0 3.10.15-r3
Chainguard python-3.10-base-dev 0 3.10.15-r3
Chainguard python-3.10-dev 0 3.10.15-r3
Chainguard python-3.10-doc 0 3.10.15-r3
Chainguard python-3.11 0 3.11.10-r4
Chainguard python-3.11-base 0 3.11.10-r4
Chainguard python-3.11-base-dev 0 3.11.10-r4
Chainguard python-3.11-dev 0 3.11.10-r4
Chainguard python-3.11-doc 0 3.11.10-r4
Chainguard python-3.12 0 3.12.7-r1
Chainguard python-3.12-base 0 3.12.7-r1
Chainguard python-3.12-base-dev 0 3.12.7-r1
Chainguard python-3.12-dev 0 3.12.7-r1
Chainguard python-3.12-doc 0 3.12.7-r1
Chainguard python-3.12-privileged-netbindservice 0 3.12.7-r1
Chainguard python-3.12-tk 0 3.12.7-r1
Chainguard python-3.13 0 3.13.0-r1
Chainguard python-3.13-base 0 3.13.0-r1
Chainguard python-3.13-base-dev 0 3.13.0-r1
Chainguard python-3.13-dev 0 3.13.0-r1
Chainguard python-3.13-doc 0 3.13.0-r1
Chainguard python-3.13-privileged-netbindservice 0 3.13.0-r1
Chainguard python-3.13-tk 0 3.13.0-r1
Chainguard python-3.9 0 3.9.20-r3
Chainguard python-3.9-base 0 3.9.20-r3
Chainguard python-3.9-base-dev 0 3.9.20-r3
Chainguard python-3.9-default 0 3.9.20-r3
Chainguard python-3.9-dev 0 3.9.20-r3
Chainguard python-3.9-doc 0 3.9.20-r3
Debian:11 pypy3 0 7.3.5+dfsg-2+deb11u4
Debian:11 python2.7 0 No fix
Debian:11 python3.9 0 No fix
Debian:11 python3.9 0 3.9.2-1+deb11u2
Debian:12 pypy3 0 No fix
Debian:12 python3.11 0 No fix
Debian:13 pypy3 0 7.3.17+dfsg-3
Debian:13 python3.12 0 No fix
Debian:13 python3.13 0 No fix
Mageia:9 python3 0 3.10.18-1.4.mga9
Red Hat:enterprise_linux:8::appstream platform-python 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream platform-python-debug 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream platform-python-devel 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-debuginfo 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-debugsource 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-idle 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-libs 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-test 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3-tkinter 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::appstream python3.11 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debug 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debuginfo 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debugsource 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-devel 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-idle 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-libs 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-rpm-macros 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-test 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-tkinter 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-debug 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-debuginfo 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-debugsource 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-devel 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-idle 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-libs 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-rpm-macros 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-test 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.12-tkinter 0 0:3.12.8-1.el8_10
Red Hat:enterprise_linux:8::baseos platform-python 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos platform-python-debug 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos platform-python-devel 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-debuginfo 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-debugsource 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-idle 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-libs 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-test 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::baseos python3-tkinter 0 0:3.6.8-69.el8_10
Red Hat:enterprise_linux:8::crb python3.11 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-debug 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-debuginfo 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-debugsource 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-devel 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-idle 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-libs 0 0:3.11.11-1.el8_10
Red Hat:enterprise_linux:8::crb python3.11-rpm-macros 0 0:3.11.11-1.el8_10

Related vulnerabilities