Repository navigation
Don't apply archive permissions to the wheel unpack directory - #701
Merged
Merged
Conversation
agronholm
requested changes
Oct 1, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #701 +/- ##
==========================================
+ Coverage 63.45% 63.54% +0.08%
==========================================
Files 15 15
Lines 1267 1270 +3
==========================================
+ Hits 804 807 +3
Misses 463 463 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Drops the os.path.normpath() call in favour of Path.resolve(), and shortens the comment. resolve() is called on both sides: ZipFile.extract() returns normpath(join(dest, arcname)), so with a relative --dest (the default is ".") an already-resolved root never compares equal and the chmod would go ahead. strict=True can't be used, as the unpack directory is created by extract() and does not exist yet at that point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wheel unpack restores each member's mode from external_attr, applying it to the path that ZipFile.extract hands back. That path is not always a member of the archive: extract drops empty, "." and ".." components from the member name, so a member called ../ or / collapses to an empty name and the call returns the destination directory itself. The mode of the unpack directory then comes straight from the archive, so a wheel carrying one such member leaves the unpacked tree at whatever mode it asks for, world-writable included, which on a shared machine or CI runner lets another user rewrite the files before they are inspected, repacked or installed. I came across it reading the fix for CVE-2026-24049, which moved the chmod onto extract's return value but did not cover the case where that value is the destination itself. Skipping the chmod when extract returns the unpack root keeps the behaviour for real members unchanged and leaves the directory wheel unpack created at the mode the umask gave it. The regression test alongside fails on main with mode 0o777 and passes with this change.