Repository navigation
Prevent path traversal (tar slip) in untar_dir/_unpack (CVE-2026-65320) - #973
Open
rahulreddykarne wants to merge 1 commit into
Open
rahulreddykarne wants to merge 1 commit into
rahulreddykarne wants to merge 1 commit into
Conversation
_unpack() delegated tar extraction to shutil.unpack_archive() with no extraction filter or member validation, so a crafted tar with '../' members could write files outside the intended destination directory (arbitrary file write). Route tar extraction through tarfile with filter='data' (Python 3.12+/3.11.4+), with a manual member-containment and symlink/hardlink check as a fallback for older 3.11.x. Zip and other formats continue via shutil (stdlib already sanitizes '..'). Adds a notebook regression test.
rahulreddykarne
force-pushed
the
fix-untar_dir-tarslip
branch
from
November 16, 2026 07:54
e09a268 to
e613150
Compare
This branch has not been deployed
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.
_unpack()extracts tar archives via shutil.unpack_archive() with no filteror member validation, so a crafted tar with
../members can write filesOUTSIDE the intended
dest(arbitrary file write → code execution if anextracted file is later imported/loaded).
Fix: route tar extraction through tarfile with filter='data' (Python 3.12+ /
3.11.4+), with a manual containment + symlink/hardlink check fallback for
older 3.11.x. Zip/other formats keep using shutil (stdlib already strips '..').
Adds a notebook regression test. Built with nbdev (edited nbs/03_xtras.ipynb,
regenerated fastcore/xtras.py).