Skip to content
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

gh-123726: Document caveats of zipfile.Path around name sanitization #130537

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AffanShaikhsurab
Copy link

@AffanShaikhsurab AffanShaikhsurab commented Feb 25, 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.

This Pr solves the issue #123726


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

…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.
Copy link

cpython-cla-bot bot commented Feb 25, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant