Skip to content

Commit ba0aca3

Browse files
serhiy-storchakaSebastian Gassner
andauthored
gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994)
Co-authored-by: Sebastian Gassner <sebastian.gassner@gmail.com>
1 parent 517d3d2 commit ba0aca3

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
@@ -749,8 +749,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
749749

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

755755
Since Python 3.14, the defaults for both built-in formats (zip and tar
756756
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
@@ -411,9 +411,9 @@ ZipFile objects
411411
.. warning::
412412

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

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

0 commit comments

Comments
 (0)