Skip to content

Commit 8e13025

Browse files
miss-islingtonserhiy-storchakaSebastian Gassner
authored
[3.14] gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994) (GH-150065)
(cherry picked from commit ba0aca3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Sebastian Gassner <sebastian.gassner@gmail.com>
1 parent 1cc98b7 commit 8e13025

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/library/shutil.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
745745

746746
Never extract archives from untrusted sources without prior inspection.
747747
It is possible that files are created outside of the path specified in
748-
the *extract_dir* argument, e.g. members that have absolute filenames
749-
starting with "/" or filenames with two dots "..".
748+
the *extract_dir* argument, for example, members that have absolute filenames
749+
or filenames with ".." components.
750750

751751
Since Python 3.14, the defaults for both built-in formats (zip and tar
752752
files) will prevent the most dangerous of such security issues,

Doc/library/zipfile.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ ZipFile objects
414414
.. warning::
415415

416416
Never extract archives from untrusted sources without prior inspection.
417-
It is possible that files are created outside of *path*, e.g. members
418-
that have absolute filenames starting with ``"/"`` or filenames with two
419-
dots ``".."``. This module attempts to prevent that.
417+
It is possible that files are created outside of *path*, for example, members
418+
that have absolute filenames or filenames with ".." components.
419+
This module attempts to prevent that.
420420
See :meth:`extract` note.
421421

422422
.. versionchanged:: 3.6
@@ -593,7 +593,7 @@ Path objects
593593
The :class:`Path` class does not sanitize filenames within the ZIP archive. Unlike
594594
the :meth:`ZipFile.extract` and :meth:`ZipFile.extractall` methods, it is the
595595
caller's responsibility to validate or sanitize filenames to prevent path traversal
596-
vulnerabilities (e.g., filenames containing ".." or absolute paths). When handling
596+
vulnerabilities (for example, absolute paths or paths with ".." components). When handling
597597
untrusted archives, consider resolving filenames using :func:`os.path.abspath`
598598
and checking against the target directory with :func:`os.path.commonpath`.
599599

0 commit comments

Comments
 (0)