Skip to content

Document caveats of zipfile.Path around name sanitization #123726

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

Closed
jaraco opened this issue Sep 5, 2024 · 5 comments
Closed

Document caveats of zipfile.Path around name sanitization #123726

jaraco opened this issue Sep 5, 2024 · 5 comments
Assignees
Labels
docs Documentation in the Doc dir easy

Comments

@jaraco
Copy link
Member

jaraco commented Sep 5, 2024

Advertise that zipfile.Path does not do any name sanitization and it's the responsibility of the caller to check the inputs, etc.

I think documenting the caveats would be good.

Originally posted by @obfusk in #123270 (comment)

Linked PRs

@jaraco jaraco added docs Documentation in the Doc dir easy labels Sep 5, 2024
@picnixz picnixz moved this to Todo in Zipfile issues Sep 5, 2024
@jaraco
Copy link
Member Author

jaraco commented Sep 9, 2024

@abj101 expressed interest in working on a documentation issue relating to #123270. Please take some time to understand the concern and consider how you might want to approach communicating the concern to the reader. Feel free to ask questions or describe a draft change in this issue, or create a PR. See the documentation section of the devguide for advice on how to contribute documentation changes. Thanks for offering to help.

@AffanShaikhsurab
Copy link
Contributor

Hi, I would love to contribute and be a part of this! Could someone please assign this to me?

@swastim01
Copy link

Hi if this issue is unassigned, I'd like to take it up.

@jaraco
Copy link
Member Author

jaraco commented Feb 17, 2025

Since Affan offered first, let's let them take the first stab at it. Swasti - perhaps you could review the proposal. If there's no proposal by March 15, feel free to take it on. Affan, please keep us apprised and let us know if you've stopped working on it or have questions.

AffanShaikhsurab added a commit to AffanShaikhsurab/cpython that referenced this issue Feb 25, 2025
…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.
@AffanShaikhsurab
Copy link
Contributor

Hi @jaraco ,

I’ve created a pull request to address this issue by adding a note to the zipfile.Path documentation clarifying that it doesn’t sanitize filenames. This is my first contribution to CPython, so I’d really appreciate it if you could review the PR and let me know if I’ve missed anything or if there’s anything I need to improve.

Thank you for your guidance!

jaraco pushed a commit that referenced this issue Mar 8, 2025
…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.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 8, 2025
…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]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 8, 2025
…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]>
@jaraco jaraco closed this as completed Mar 8, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Zipfile issues Mar 8, 2025
jaraco pushed a commit that referenced this issue Mar 8, 2025
…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]>
jaraco pushed a commit that referenced this issue Mar 8, 2025
…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]>
dmitya26 added a commit to dmitya26/cpython that referenced this issue Mar 8, 2025
pythongh-123726: Document caveats of zipfile.Path around name sanitization …
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…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.
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 easy
Projects
Status: Done
Development

No branches or pull requests

3 participants