-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-123726: Document caveats of zipfile.Path around name sanitization #130537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ation Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution.
Thanks @AffanShaikhsurab for the PR, and @jaraco for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…ation (pythonGH-130537) Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution. (cherry picked from commit a3990df) Co-authored-by: Affan Shaikhsurab <[email protected]>
GH-130986 is a backport of this pull request to the 3.13 branch. |
…ation (pythonGH-130537) Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution. (cherry picked from commit a3990df) Co-authored-by: Affan Shaikhsurab <[email protected]>
GH-130987 is a backport of this pull request to the 3.12 branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this over a few times. I considered changing it to point out that it's mostly relevant when manifesting names in a file system, or making a reference to the open issues around providing a sanitizing extractor, but decided against that. This is a good, complete contribution. Thanks!
…zation (GH-130537) (#130986) gh-123726: Document caveats of zipfile.Path around name sanitization (GH-130537) Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution. (cherry picked from commit a3990df) Co-authored-by: Affan Shaikhsurab <[email protected]>
…zation (GH-130537) (#130987) gh-123726: Document caveats of zipfile.Path around name sanitization (GH-130537) Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution. (cherry picked from commit a3990df) Co-authored-by: Affan Shaikhsurab <[email protected]>
…ation (python#130537) Add a note to the `zipfile.Path` class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references the `extract` and `extractall` methods for comparison and suggests using `os.path.abspath` and `os.path.commonpath` for safe filename resolution.
Add a note to the
zipfile.Path
class documentation clarifying that it does not sanitize filenames. This emphasizes the caller's responsibility to validate or sanitize inputs, especially when handling untrusted ZIP archives, to prevent path traversal vulnerabilities. The note also references theextract
andextractall
methods for comparison and suggests usingos.path.abspath
andos.path.commonpath
for safe filename resolution.This Pr solves the issue #123726
zipfile.Path
around name sanitization #123726📚 Documentation preview 📚: https://cpython-previews--130537.org.readthedocs.build/