GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows by serhiy-storchaka · Pull Request #146591 · python/cpython Conversation
|
|
Wasn't |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Also, the new |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Backports will be fixed to use equivalent code.
Backslash is not a separator on Posix. It is a legal character which has no special meaning. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I believe it’s actually a regression. Currently, In this PR it switches to a component based check, which removes that existing protection. So I believe this actually reduces the existing security strictness for non windows users |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There is no backslash traversal on Linux. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| fp = None # Set here since __del__ checks it | ||
| _windows_illegal_name_trans_table = None | ||
| _ignore_invalid_names = False |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to be set by users needing back-compat as well? Should we document it (carefully)?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is intended for internal use in shutil.unpack_archive() only.
We could add it as optional parameter, but this does not look like a good long term solution. Even if we make the parameter name underscored, it will be visible in the help, and will confuse users. Users will start to use it, so it will be difficult to get rid of it.
I think that in future versions we can add a hook which would be called for all entry names. It would allow to translate them to valid paths, allow to skip them (with possible logging) or raise an exception. But this is a new feature, it cannot be backported. And it needs a separate discussion.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11, 3.12, 3.13, 3.14. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-149064 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-149065 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-149066 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-149071 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…P files on Windows (GH-146591) (GH-149065) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit fc829e8) Co-authored-by: Serhiy Storchaka <[email protected]>
…P files on Windows (GH-146591) (GH-149064) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit fc829e8) Co-authored-by: Serhiy Storchaka <[email protected]>
Introduced in python#8295 alongside shutil.unpack_archive() as a helper that created the parent directory of each extracted member. Orphaned by pythongh-146581 (pythonGH-146591), the ZIP path-traversal fix, which reworked _unpack_zipfile() to create directories inline and deleted the last _ensure_directory(targetpath) call site in the same change. Since then the private helper has had no caller: a word-boundary search across Lib, Modules, Python, Objects and Include finds zero references outside its own definition, and a GitHub code search finds no downstream importers.
Introduced in python#8295 alongside shutil.unpack_archive() as a helper that created the parent directory of each extracted member. Orphaned by pythongh-146581 (pythonGH-146591), the ZIP path-traversal fix, which reworked _unpack_zipfile() to create directories inline and deleted the last _ensure_directory(targetpath) call site in the same change. Since then the private helper has had no caller: a word-boundary search across Lib, Modules, Python, Objects and Include finds zero references outside its own definition, and a GitHub code search finds no downstream importers.
) No longer used after pythongh-146581 (pythonGH-146591).
…P files on Windows (GH-146591) (#149066) gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit fc829e8) Co-authored-by: Serhiy Storchaka <[email protected]>
…P files on Windows (GH-146591) (#149071) gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit fc829e8)
…P files on Windows (GH-146591) (GH-149071) (#155440) [3.11] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) (GH-149071) gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit 7ef7dd0) (cherry picked from commit fc829e8) Co-authored-by: Serhiy Storchaka <[email protected]>
…for ZIP files on Windows (pythonGH-146591) (pythonGH-149071) (python#155440) [3.11] pythongh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (pythonGH-146591) (pythonGH-149071) pythongh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (pythonGH-146591) Use ZipFile.extractall() to sanitize file names and extract files. Files with invalid names (e.g. absolute paths) are now skipped. Files containing ".." in the name are no longer skipped. (cherry picked from commit 7ef7dd0) (cherry picked from commit fc829e8) Co-authored-by: Serhiy Storchaka <[email protected]> (cherry picked from commit 1071290)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.