# Patch Analysis and Bypass Research - GHSA-5rjg-fvgr-3xxf / CVE-2025-47273

Test Matrix
- Vulnerable tested: setuptools 78.1.0 (confirmed vulnerable)
- Patched baseline attempted: 78.1.1, then upgraded to latest release at test time
- Result on latest: setuptools.package_index is not importable; vulnerable API path removed/blocked

Verification on Vulnerable Version
- API: setuptools.package_index.PackageIndex._download_url(url, tmpdir)
- PoC URL: http://127.0.0.1:<port>/%2Ftmp%2Fsetuptools_pwned.txt
- Expected behavior (vulnerable): os.path.join(tmpdir, name) uses absolute name and discards tmpdir
- Observed: File created at /tmp/setuptools_pwned.txt with controlled content
- Evidence: logs/poc_vulnerable.jsonl
  - downloaded_to: /tmp/setuptools_pwned.txt
  - abs_file_exists: true
  - abs_file_content_matches: true

Patched Version Behavior
- After upgrading to 78.1.1 and then latest, importing setuptools.package_index fails, indicating the deprecated module path is gone; exploitation via this vector is blocked.
- Evidence: logs/poc_patched.jsonl contains entries with error: import_failed: No module named 'setuptools.package_index'

Bypass Attempts (10 tested on patched/latest)
All crafted last path segment payloads sent as URL last segment; none produced file writes because API was not reachable:
1) %2Ftmp%2Fsetuptools_pwned_p1.txt
2) //tmp/setuptools_pwned_p3.txt
3) /tmp//setuptools_pwned_p4.txt
4) /tmp/./setuptools_pwned_p7.txt
5) %2Fvar%2Ftmp%2Fsetuptools_pwned_p5.txt
6) %2Ftmp%2F..%2Fetc%2Fsetuptools_pwned_p6.txt
7) %2Ftmp%2Fsetuptools_pwned_p2.txt
8) %2Ftmp%2Fspace%20in%20name_p11.txt
9) %255Ctmp%255Cwinsep_p12.txt
10) C:%5Ctmp%5Cwin_drive_p13.txt

Threat Model Assessment per bypass
- Required access: Control of URLs processed by PackageIndex._download_url
- Expected gain (if reachable): Arbitrary file write
- Actual on latest: API not available => no attack path => blocked

Gap Analysis: Patch vs Root Cause
- Root cause: Failure to validate/sanitize absolute paths in name derived from URL before joining with tmpdir
- 78.1.1 reportedly adds sanitization; latest release line removes/deprecates the module, fully preventing use of this API
- No reachable variant identified via this API on latest

Artifacts
- logs/poc_vulnerable.jsonl: vulnerable run evidence
- logs/poc_patched.jsonl: import_failed entries on latest
- logs/result.json: summarized outcome including reproduced=true and patched_all_blocked=true

Conclusion
- Vulnerability reproducible on 78.1.0
- Latest setuptools blocks this vector; 10 bypass styles tested, none succeeded
