Skip to content

Commit d113674

Browse files
gh-91783: Document security considerations for shutil.unpack_archive (GH-91844)
(cherry picked from commit 4b297a9) Co-authored-by: Sam Ezeh <[email protected]>
1 parent 1a7867f commit d113674

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Doc/library/shutil.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,16 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
630630

631631
.. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive
632632

633+
.. warning::
634+
635+
Never extract archives from untrusted sources without prior inspection.
636+
It is possible that files are created outside of the path specified in
637+
the *extract_dir* argument, e.g. members that have absolute filenames
638+
starting with "/" or filenames with two dots "..".
639+
633640
.. versionchanged:: 3.7
634641
Accepts a :term:`path-like object` for *filename* and *extract_dir*.
635642

636-
637643
.. function:: register_unpack_format(name, extensions, function[, extra_args[, description]])
638644

639645
Registers an unpack format. *name* is the name of the format and
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)