]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-149486: tarfile.data_filter: validate written link target (GH-149487)
authorPetr Viktorin <encukou@gmail.com>
Fri, 8 May 2026 12:16:06 +0000 (14:16 +0200)
committerGitHub <noreply@github.com>
Fri, 8 May 2026 12:16:06 +0000 (14:16 +0200)
commit578411982c16f753f4893532510099ef665117da
tree6f31b5f0e818cd353c4f35bc4238d42009290a9f
parent2f6b3800e6004b97e04082c9fa06192ae37aea52
gh-149486: tarfile.data_filter: validate written link target (GH-149487)

The data filter rewrote linknames with normpath() but ran the
containment check against the un-normalised value, and computed a
symlink's directory before stripping trailing slashes.  Both let a
crafted archive create links pointing outside the destination.  Also
reject link members that resolve to the destination directory itself,
which could otherwise replace it with a symlink and redirect all
subsequent members.

(Patch by Greg; Petr's just reviewing & merging.)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Lib/tarfile.py
Lib/test/test_tarfile.py
Misc/NEWS.d/next/Security/2026-05-03-21-00-00.gh-issue-149486.tarflt.rst [new file with mode: 0644]