Skip to content

gh-160297: Fix tarfile setting attributes through a hard link fallback - #160298

Open
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:scanfix-tarfile-y0h1y0er
Open

gpshead wants to merge 1 commit into
python:mainfrom
gpshead:scanfix-tarfile-y0h1y0er

Conversation

@gpshead

@gpshead gpshead commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

When a hard link member's target is missing, makelink_with_filter() extracts a copy of the referenced member instead. If that member is a symlink, _extract_member() went on to apply the hard link's owner, mode and mtime with calls that follow the symlink, so they could land on a file outside the destination with the 'tar' and 'fully_trusted' filters. Attribute setting is now skipped when a hard link member ended up as a symlink; the nested extraction has already applied the symlink member's own attributes without following it. A hard link extracted as a copy of a regular file still gets the hard link's attributes, as before.

Fixes #160297

ANT-2026-Y0H1Y0ER

…allback

When a hard link member is extracted as a copy of a symlink member, do
not apply the hard link's owner, mode and mtime to the symlink's target.

ANT-2026-Y0H1Y0ER
@gpshead gpshead added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 22, 2026
@gpshead gpshead self-assigned this Oct 22, 2026
@gpshead
gpshead requested a review from JelleZijlstra October 22, 2026 18:34
@gpshead
gpshead marked this pull request as ready for review October 22, 2026 18:35
@gpshead
gpshead requested a review from ethanfurman as a code owner October 22, 2026 18:35

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add the CVE.

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

Labels

awaiting core review needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes sprint

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

tarfile applies a hard link member's attributes through a symlink extracted in its place

2 participants