Thanks to visit codestin.com
Credit goes to github.com

Skip to content

🐛 fix(seed): validate wheel zip entries before extraction#3118

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:security/zip-slip-guard
Apr 14, 2026
Merged

🐛 fix(seed): validate wheel zip entries before extraction#3118
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:security/zip-slip-guard

Conversation

@gaborbernat
Copy link
Copy Markdown
Contributor

@gaborbernat gaborbernat commented Apr 14, 2026

Security hardening. The app-data seeder extracts seed wheels with zipfile.ZipFile.extractall without validating entry names first. Wheels are not a strongly trusted input — they live on disk, they can be replaced by anyone with write access to the app-data cache, and in the --download path they come from pip's cache — so a tampered wheel with an entry named ../evil.py or an absolute path would land outside the image directory. 🔒

The fix wraps extraction in a helper that refuses any entry whose name is absolute or resolves outside the target image directory, then delegates to extractall for the happy path. Absolute-path checks cover both POSIX and Windows forms so the same guard is effective on any platform.

Nothing changes for well-formed wheels; only malformed archives are rejected, with a clear RuntimeError that names the offending entry.

@gaborbernat gaborbernat force-pushed the security/zip-slip-guard branch 4 times, most recently from 08857ad to 0adc9c6 Compare April 14, 2026 05:01
Guard the wheel extraction in the app-data seeder against zip slip.
The wheel is an untrusted zip archive as soon as anyone can tamper
with it on disk or along the download path, so refuse entries with
absolute names or ``..`` components before calling ``extractall``.
@gaborbernat gaborbernat force-pushed the security/zip-slip-guard branch from 0adc9c6 to 9b50cae Compare April 14, 2026 05:12
@gaborbernat gaborbernat marked this pull request as ready for review April 14, 2026 14:52
@gaborbernat gaborbernat enabled auto-merge (squash) April 14, 2026 15:03
@gaborbernat gaborbernat merged commit 754602d into pypa:main Apr 14, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants