]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-149486: tarfile.data_filter: validate written link target (GH-149487) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 18 May 2026 17:58:27 +0000 (19:58 +0200)
committerGitHub <noreply@github.com>
Mon, 18 May 2026 17:58:27 +0000 (19:58 +0200)
commit0d28f5e46e151718972dfabd91205444d0037b6d
tree219d23db1db1375c82f47427c923e5783d7af411
parent6cad0283a9deac0e947eec4a56ef3700a0bc0998
[3.12] gh-149486: tarfile.data_filter: validate written link target (GH-149487) (#149556)

* 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.)
(cherry picked from commit 578411982c16f753f4893532510099ef665117da)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Move dotdot_resolves_early setting to setUpClass

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
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]