Repository navigation
Conversation
feiiiiii5
requested review from
gaborbernat,
henryiii and
layday
as code owners
November 20, 2026 04:22
Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
feiiiiii5
force-pushed
the
fix/sdist-symlink-extraction
branch
from
November 20, 2026 04:25
7ef8472 to
1399610
Compare
Contributor
|
Duplicate of #1274. Please check duplicates including closed ones. |
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.
Why I decided to contribute
buildis the standard build frontend for Python projects across the packaging ecosystem, and ensuring archives unpack securely without symlink traversal vulnerabilities is vital for safe builds in automated and sandbox environments.Description
Fixes #1265.
In
_prepare_sdist_archive, archive members were filtered withtarfile.data_filter(m, extract_dir)up-front, and thenextractallwas called withfilter='fully_trusted'. Because extraction filters must inspect the filesystem dynamically as members are extracted, an up-front check cannot detect symlinks that resolve through earlier extracted symlinks in a chain (such asdemo-1.0/self -> .followed by nested symlinks escaping the extraction root).Passing
filter='data'toarchive.extractallensures each member is dynamically verified against the current filesystem state during extraction, correctly rejecting symlink traversal chains withtarfile.LinkOutsideDestinationErrorbefore any files outside the destination directory can be created or modified.Added a regression test
test_extract_sdist_rejects_symlink_chain_traversalintests/test_main.py.Changelog
docs/changelog/1265.bugfix.rstChecklist
docs/development/contributing.rst)tox,tox -e fix,tox -e type,tox -e docs, depending on the change)<details>tags if you really need more)