Skip to content

[3.13] gh-157190: Fix tarfile data/tar filter bypass via hard link to a symlink - #157192

Open
StanFromIreland wants to merge 3 commits into
python:3.13from
StanFromIreland:backport-480ea4a-3.13
Open

[3.13] gh-157190: Fix tarfile data/tar filter bypass via hard link to a symlink#157192
StanFromIreland wants to merge 3 commits into
python:3.13from
StanFromIreland:backport-480ea4a-3.13

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Sep 8, 2026

Copy link
Copy Markdown
Member

Comment thread Lib/tarfile.py
os.link(tarinfo._link_target, targetpath)
# Resolve the target so the hard link points to the file
# itself. Otherwise os.link() may duplicate a symlink to a
# shallower location, where it's relative target escapes the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# shallower location, where it's relative target escapes the
# shallower location, where its relative target escapes the

Comment thread Lib/test/test_tarfile.py

@symlink_test
@os_helper.skip_unless_hardlink
def test_sneaky_hardlink_relocation(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a test if the symlink points to a directory?

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.

2 participants