SIGN IN SIGN UP

[3.13] gh-149486: tarfile.data_filter: validate written link target (GH-149487) (GH-149555)

* 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>
M
Miss Islington (bot) committed
0478bd83d82b255e0f29f613367a59d261e7eaa2
Parent: 6ab65b3
Committed by GitHub <noreply@github.com> on 5/11/2026, 9:58:26 AM