GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-123726: Document caveats of zipfile.Path around name sanitization by AffanShaikhsurab · Pull Request #130537 · python/cpython

Conversation

@AffanShaikhsurab

@AffanShaikhsurab AffanShaikhsurab commented Feb 25, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • Issue: Document caveats of zipfile.Path around name sanitization #123726

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AffanShaikhsurab added 2 commits February 25, 2025 16:18
@AffanShaikhsurab
pythongh-123726: Document caveats of zipfile.Path around name sanitiz…
67a0709
…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
Merge branch 'python:main' into main
cfa4461
@ghost

ghost commented Feb 25, 2025 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news awaiting review labels Feb 25, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 25, 2025
Document caveats of zipfile.Path around name sanitization #123726
Closed
AffanShaikhsurab added 2 commits March 2, 2025 14:09
@AffanShaikhsurab
Merge branch 'main' into main
8455041
@AffanShaikhsurab
Merge branch 'main' into main
ecbba03
@jaraco jaraco self-assigned this Mar 8, 2025
@jaraco jaraco added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Mar 8, 2025
@jaraco
jaraco merged commit a3990df into python:main Mar 8, 2025
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Mar 8, 2025
@miss-islington-app

miss-islington-app Bot commented Mar 8, 2025

Copy link
Copy Markdown

Thanks @AffanShaikhsurab for the PR, and @jaraco for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Mar 8, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2025
@AffanShaikhsurab @miss-islington
pythongh-123726: Document caveats of zipfile.Path around name sanitiz…
8cd150a
…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 commented Mar 8, 2025

Copy link
Copy Markdown

GH-130986 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Mar 8, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2025
@AffanShaikhsurab @miss-islington
pythongh-123726: Document caveats of zipfile.Path around name sanitiz…
4a277ab
…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 commented Mar 8, 2025

Copy link
Copy Markdown

GH-130987 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 8, 2025
jaraco
jaraco reviewed Mar 8, 2025
View reviewed changes

@jaraco jaraco left a comment

Copy link
Copy Markdown
Member

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jaraco jaraco mentioned this pull request Mar 8, 2025
Feature: provide (safe) traversal/extraction facilities for zipfile.Path #123727
Open
jaraco pushed a commit that referenced this pull request Mar 8, 2025
@miss-islington @AffanShaikhsurab
[3.13] gh-123726: Document caveats of zipfile.Path around name saniti…
aef7eda
…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 pull request Mar 8, 2025
@miss-islington @AffanShaikhsurab
[3.12] gh-123726: Document caveats of zipfile.Path around name saniti…
552dad1
…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]>
@dmitrin9 dmitrin9 mentioned this pull request Mar 8, 2025
gh-123726: Document caveats of zipfile.Path around name sanitization … dmitrin9/cpython#1
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jaraco jaraco jaraco left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jaraco jaraco

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@AffanShaikhsurab @jaraco
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.