Skip to content

Commit bdb2a0e

Browse files
committed
gh-156026: document tar filter link targets
1 parent 20e6c2f commit bdb2a0e

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
@@ -1056,7 +1056,8 @@ can be:
10561056

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

10611062
* the string ``'data'``: Ignore or block most features specific to UNIX-like
10621063
filesystems. Intended for extracting cross-platform data archives.
@@ -1124,6 +1125,17 @@ reused in custom filters:
11241125

11251126
Return the modified ``TarInfo`` member.
11261127

1128+
.. warning::
1129+
This filter does not check :attr:`TarInfo.linkname`. This means it does
1130+
not limit where a symbolic link member points. An absolute symbolic-link
1131+
target will remain absolute, and a relative target may resolve outside the
1132+
extraction destination. The destination path protection described above
1133+
concerns only where the archive member itself is written, not where a
1134+
symbolic link resolves. The stricter :func:`data_filter` rejects these
1135+
unsafe link targets, raising :class:`~tarfile.AbsoluteLinkError` for
1136+
absolute link targets or :class:`~tarfile.LinkOutsideDestinationError`
1137+
for link targets outside the destination.
1138+
11271139
.. versionchanged:: next
11281140

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

0 commit comments

Comments
 (0)