Skip to content

Commit a6b4aa6

Browse files
encukouethanfurman
andauthored
gh-156026: Add warning about link targets to tarfile.tar_filter (GH-159019)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
1 parent b70a512 commit a6b4aa6

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

‎Doc/library/tarfile.rst‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,17 +1137,13 @@ reused in custom filters:
11371137
Return the modified ``TarInfo`` member.
11381138

11391139
.. 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-
1150-
.. versionchanged:: 3.16
1140+
1141+
This filter does not check link targets (:attr:`TarInfo.linkname`).
1142+
It allows benign cases (like links to ``/dev/null``), but it also allows
1143+
links (symbolic and hard) to arbitrary files on the filesystem,
1144+
potentially granting unintended access to these files.
1145+
1146+
.. versionchanged:: next
11511147

11521148
Filenames containing ``..`` components are now normalized.
11531149

0 commit comments

Comments
 (0)