[Python-checkins] gh-91783: Document security considerations for shutil.unpack_archive (#91844)
JelleZijlstra
webhook-mailer at python.org
Mon May 2 13:15:13 EDT 2022
https://github.com/python/cpython/commit/4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469
commit: 4b297a9ffd4a1d420c1a8016f4ed2c7f1d298469
branch: main
author: Sam Ezeh <sam.z.ezeh at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-05-02T11:15:04-06:00
summary:
gh-91783: Document security considerations for shutil.unpack_archive (#91844)
files:
A Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst
M Doc/library/shutil.rst
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index cb72ff6f3914b..9a25b0d008bf5 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -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
index 0000000000000..4d6be37402079
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2022-04-23-00-22-54.gh-issue-91783.N09dRR.rst
@@ -0,0 +1,2 @@
+Document security issues concerning the use of the function
+:meth:`shutil.unpack_archive`
More information about the Python-checkins
mailing list