Skip to content

Commit 4b297a9

Browse files
authored
gh-91783: Document security considerations for shutil.unpack_archive (#91844)
1 parent feb45d0 commit 4b297a9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Doc/library/shutil.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
636636

637637
.. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive
638638

639+
.. warning::
640+
641+
Never extract archives from untrusted sources without prior inspection.
642+
It is possible that files are created outside of the path specified in
643+
the *extract_dir* argument, e.g. members that have absolute filenames
644+
starting with "/" or filenames with two dots "..".
645+
639646
.. versionchanged:: 3.7
640647
Accepts a :term:`path-like object` for *filename* and *extract_dir*.
641648

642-
643649
.. function:: register_unpack_format(name, extensions, function[, extra_args[, description]])
644650

645651
Registers an unpack format. *name* is the name of the format and
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document security issues concerning the use of the function
2+
:meth:`shutil.unpack_archive`

0 commit comments

Comments
 (0)