Skip to content

[3.12] gh-123726: Document caveats of zipfile.Path around name sanitization (GH-130537) #130987

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

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 8, 2025

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]


📚 Documentation preview 📚: https://cpython-previews--130987.org.readthedocs.build/

…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]>
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir awaiting review labels Mar 8, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Mar 8, 2025
@jaraco jaraco enabled auto-merge (squash) March 8, 2025 21:39
@jaraco jaraco merged commit 552dad1 into python:3.12 Mar 8, 2025
25 of 26 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants