Skip to content

[3.12] gh-149486: tarfile.data_filter: validate written link target (GH-149487)#149556

Merged
Yhg1s merged 2 commits into
python:3.12from
miss-islington:backport-5784119-3.12
May 18, 2026
Merged

[3.12] gh-149486: tarfile.data_filter: validate written link target (GH-149487)#149556
Yhg1s merged 2 commits into
python:3.12from
miss-islington:backport-5784119-3.12

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented May 8, 2026

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 5784119)

Co-authored-by: Petr Viktorin encukou@gmail.com
Co-authored-by: Gregory P. Smith greg@krypto.org

…ythonGH-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 5784119)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 8, 2026

@Yhg1s Yhg1s merged commit 0d28f5e into python:3.12 May 18, 2026
31 checks passed
@miss-islington miss-islington deleted the backport-5784119-3.12 branch May 18, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

4 participants