Skip to content

Commit 8bfc405

Browse files
authored
gh-156026: Document that the 'tar' filter does not bound link targets
1 parent 6893326 commit 8bfc405

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎Doc/library/tarfile.rst‎

Lines changed: 15 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. This does not include limiting 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,19 @@ reused in custom filters:
11241125

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

1128+
.. warning::
1129+
1130+
This filter does not limit where a link member *points*.
1131+
:attr:`TarInfo.linkname` is not checked, so a symbolic link whose target
1132+
is an absolute path, or a relative path that climbs outside the
1133+
destination, is extracted as given.
1134+
The rule above constrains where each member is *written*; it does not
1135+
constrain where a link resolves to.
1136+
1137+
Only :func:`data_filter` refuses such members, raising
1138+
:class:`~tarfile.AbsoluteLinkError` or
1139+
:class:`~tarfile.LinkOutsideDestinationError`.
1140+
11271141
.. versionchanged:: next
11281142

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

0 commit comments

Comments
 (0)