Skip to content

Commit e29cce5

Browse files
authored
gh-156026: document tar filter link targets (GH-156056)
1 parent fd67161 commit e29cce5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎Doc/library/tarfile.rst‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,8 @@ can be:
10671067

10681068
* the string ``'tar'``: Honor most *tar*-specific features (i.e. features of
10691069
UNIX-like filesystems), but block features that are very likely to be
1070-
surprising or malicious. See :func:`tar_filter` for details.
1070+
surprising or malicious. Note that this filter does not limit the targets of
1071+
symbolic links. See :func:`tar_filter` for details.
10711072

10721073
* the string ``'data'``: Ignore or block most features specific to UNIX-like
10731074
filesystems. Intended for extracting cross-platform data archives.
@@ -1135,6 +1136,17 @@ reused in custom filters:
11351136

11361137
Return the modified ``TarInfo`` member.
11371138

1139+
.. warning::
1140+
This filter does not check :attr:`TarInfo.linkname`. This means it does
1141+
not limit where a symbolic link member points. An absolute symbolic-link
1142+
target will remain absolute, and a relative target may resolve outside the
1143+
extraction destination. The destination path protection described above
1144+
concerns only where the archive member itself is written, not where a
1145+
symbolic link resolves. The stricter :func:`data_filter` rejects these
1146+
unsafe link targets, raising :class:`~tarfile.AbsoluteLinkError` for
1147+
absolute link targets or :class:`~tarfile.LinkOutsideDestinationError`
1148+
for link targets outside the destination.
1149+
11381150
.. versionchanged:: next
11391151

11401152
Filenames containing ``..`` components are now normalized.

0 commit comments

Comments
 (0)