Skip to content

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

Open
StanFromIreland wants to merge 1 commit into
python:3.10from
StanFromIreland:backport-5784119-3.10
Open

[3.10] gh-149486: tarfile.data_filter: validate written link target (GH-149487)#153180
StanFromIreland wants to merge 1 commit into
python:3.10from
StanFromIreland:backport-5784119-3.10

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Jul 6, 2026

Copy link
Copy Markdown
Member

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)

…rget (pythonGH-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>
@StanFromIreland

Copy link
Copy Markdown
Member Author

Based on #150904.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants