]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91783: Document security considerations for shutil.unpack_archive (#91844)
authorSam Ezeh <sam.z.ezeh@gmail.com>
Mon, 2 May 2022 17:15:04 +0000 (18:15 +0100)
committerGitHub <noreply@github.com>
Mon, 2 May 2022 17:15:04 +0000 (11:15 -0600)
Doc/library/shutil.rst
Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst [new file with mode: 0644]

index cb72ff6f3914bb81488537f182a2e87dc862d1a0..9a25b0d008bf5fbb5ee72e8111b329960ce7a27d 100644 (file)
@@ -636,10 +636,16 @@ provided.  They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
 
    .. audit-event:: shutil.unpack_archive filename,extract_dir,format shutil.unpack_archive
 
+   .. warning::
+
+      Never extract archives from untrusted sources without prior inspection.
+      It is possible that files are created outside of the path specified in
+      the *extract_dir* argument, e.g. members that have absolute filenames
+      starting with "/" or filenames with two dots "..".
+
    .. versionchanged:: 3.7
       Accepts a :term:`path-like object` for *filename* and *extract_dir*.
 
-
 .. function:: register_unpack_format(name, extensions, function[, extra_args[, description]])
 
    Registers an unpack format. *name* is the name of the format and
diff --git a/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst
new file mode 100644 (file)
index 0000000..4d6be37
--- /dev/null
@@ -0,0 +1,2 @@
+Document security issues concerning the use of the function
+:meth:`shutil.unpack_archive`