René's URL Explorer Experiment


Title: shutil.unpack_archive() on Windows writes outside extract_dir for ZIP entries with drive-prefixed names · Issue #146581 · python/cpython · GitHub

Open Graph Title: shutil.unpack_archive() on Windows writes outside extract_dir for ZIP entries with drive-prefixed names · Issue #146581 · python/cpython

X Title: shutil.unpack_archive() on Windows writes outside extract_dir for ZIP entries with drive-prefixed names · Issue #146581 · python/cpython

Description: Bug report Bug description: Summary I found a Windows-specific issue in shutil.unpack_archive() when extracting ZIP files. In Lib/shutil.py, the private helper _unpack_zipfile() skips names that start with / or contain .., but it does no...

Open Graph Description: Bug report Bug description: Summary I found a Windows-specific issue in shutil.unpack_archive() when extracting ZIP files. In Lib/shutil.py, the private helper _unpack_zipfile() skips names that st...

X Description: Bug report Bug description: Summary I found a Windows-specific issue in shutil.unpack_archive() when extracting ZIP files. In Lib/shutil.py, the private helper _unpack_zipfile() skips names that st...

Opengraph URL: https://github.com/python/cpython/issues/146581

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"shutil.unpack_archive() on Windows writes outside extract_dir for ZIP entries with drive-prefixed names","articleBody":"# Bug report\n\n### Bug description:\n\n### Summary\n\nI found a Windows-specific issue in `shutil.unpack_archive()` when extracting ZIP files.\n\nIn `Lib/shutil.py`, the private helper `_unpack_zipfile()` skips names that start with `/` or contain `..`, but it does not reject or sanitize Windows drive-prefixed names such as `D:/path/file`.\n\nOn Windows, such names are joined into a drive-qualified path and can escape the intended extraction directory. As a result, a crafted ZIP archive can cause files to be written outside `extract_dir`.\n\n### Affected component\n\n- `Lib/shutil.py`\n- `_unpack_zipfile()`\n\n### Impact\n\nA crafted ZIP archive can cause an arbitrary file write outside `extract_dir` on Windows.\n\n### Trigger condition\n\n- Platform: Windows\n- Archive format: ZIP\n- A ZIP entry name contains a drive prefix such as `D:/...`\n- `extract_dir` is on a different drive\n\n### Tested environment\n\nI reproduced this on Windows with Python 3.12.8.\n\n### Minimal reproduction\n\nI attached a minimal repro script:\n\n- `repro_shutil_unpack_zip_windows_drive_path_min.py`\n\nThe repro creates a ZIP archive containing an entry like:\n\nD:/shutil_outside_min.txt\n\nand then calls:\n\nshutil.unpack_archive(str(zip_path), str(extract_dir))\nWith extract_dir on another drive, the file is written outside the intended extraction directory.\n\nRoot cause\nThe validation in _unpack_zipfile() appears incomplete for Windows path semantics. Checking only for leading / and .. is not sufficient, because drive-prefixed paths such as D:/... are still treated as rooted or drive-qualified paths by Windows path handling.\n\nFor comparison, zipfile's own extraction logic strips drive information before extraction, but shutil._unpack_zipfile() does not.\n\nExpected behavior\nZIP entries that are absolute, drive-prefixed, or otherwise resolve outside extract_dir on Windows should be rejected or normalized so that extraction always remains within extract_dir.\n\nActual behavior\nA crafted ZIP entry with a drive prefix can escape extract_dir and be written to another location.\n\nAdditional context\nI previously reported this privately to the Python Security Response Team on March 28, 2026, but I have not received a response yet, so I am opening this issue for tracking and triage.\n\nI also attached a short write-up:\n\nvuln_shutil_unpack_archive_zip_windows_drive_path.md\n\n[shutil_unpack_archive_zip_windows_drive_path_min.zip](https://github.com/user-attachments/files/26325208/shutil_unpack_archive_zip_windows_drive_path_min.zip)\n\n### CPython versions tested on:\n\nCPython main branch, 3.14\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146588\n* gh-146591\n* gh-149064\n* gh-149065\n* gh-149066\n* gh-149071\n* gh-149994\n* gh-150064\n* gh-150065\n* gh-150066\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/PuH4ck3rX","@type":"Person","name":"PuH4ck3rX"},"datePublished":"2026-03-28T17:55:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/146581/cpython/issues/146581"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cd1a79c1-7321-94d9-6394-8b7bf188ede5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE3DE:3FE40B:CA1572:1139F50:6A55B3A8
html-safe-nonce1a37fcb4d94b242251c79a16487be545b66334aa2b0373b07aa861c0f0623036
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0RFOjNGRTQwQjpDQTE1NzI6MTEzOUY1MDo2QTU1QjNBOCIsInZpc2l0b3JfaWQiOiI3OTc2NDI2ODc5NTE0NDI0MjMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac64843583d06b64baef153d93c78e3ba05920287f82c2070f63a6526240798dab
hovercard-subject-tagissue:4161096240
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/146581/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a326f3ddca96f1503e75688d65a695435c41e52443d85979ab7f166967de037d/python/cpython/issues/146581
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a326f3ddca96f1503e75688d65a695435c41e52443d85979ab7f166967de037d/python/cpython/issues/146581
og:image:altBug report Bug description: Summary I found a Windows-specific issue in shutil.unpack_archive() when extracting ZIP files. In Lib/shutil.py, the private helper _unpack_zipfile() skips names that st...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamePuH4ck3rX
hostnamegithub.com
expected-hostnamegithub.com
Noneb5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release653fccf1e27344851c0d3de3fa6faa526197f072
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/146581#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F146581
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F146581
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/146581
Reloadhttps://github.com/python/cpython/issues/146581
Reloadhttps://github.com/python/cpython/issues/146581
Please reload this pagehttps://github.com/python/cpython/issues/146581
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/146581
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
shutil.unpack_archive() on Windows writes outside extract_dir for ZIP entries with drive-prefixed nameshttps://github.com/python/cpython/issues/146581#top
https://github.com/serhiy-storchaka
3.10only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15pre-release feature fixes, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-securityA security issuehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-security%22
https://github.com/PuH4ck3rX
PuH4ck3rXhttps://github.com/PuH4ck3rX
on Mar 28, 2026https://github.com/python/cpython/issues/146581#issue-4161096240
shutil_unpack_archive_zip_windows_drive_path_min.ziphttps://github.com/user-attachments/files/26325208/shutil_unpack_archive_zip_windows_drive_path_min.zip
gh-146581: Use ZipFile.extractall() in shutil for secure ZIP extraction #146588https://github.com/python/cpython/pull/146588
gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows #146591https://github.com/python/cpython/pull/146591
[3.14] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) #149064https://github.com/python/cpython/pull/149064
[3.13] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) #149065https://github.com/python/cpython/pull/149065
[3.12] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) #149066https://github.com/python/cpython/pull/149066
[3.11] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) #149071https://github.com/python/cpython/pull/149071
gh-146581: Update docs for dangerous filenames in ZIP files #149994https://github.com/python/cpython/pull/149994
[3.15] gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994) #150064https://github.com/python/cpython/pull/150064
[3.14] gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994) #150065https://github.com/python/cpython/pull/150065
[3.13] gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994) #150066https://github.com/python/cpython/pull/150066
serhiy-storchakahttps://github.com/serhiy-storchaka
3.10only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15pre-release feature fixes, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-securityA security issuehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-security%22
Zipfile issues 📦https://github.com/orgs/python/projects/7
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.