fix(security): prevent Zip Slip directory traversal in skills hub downloads - #4996
Closed
Xowiek wants to merge 1 commit into
Closed
fix(security): prevent Zip Slip directory traversal in skills hub downloads#4996Xowiek wants to merge 1 commit into
Xowiek wants to merge 1 commit into
Conversation
Contributor
|
Thanks for the security-minded contribution, @Xowiek! This is an automated hermes-sweeper review. This fix was already shipped to
No additional changes are needed. Closing as already implemented. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
🐛 The Bug
A critical Zip Slip (Directory Traversal) security vulnerability was identified in the
tools/skills_hub.pymodule, specifically within theClawHubSource._download_zipmethod.The previous logic allowed a maliciously crafted ZIP archive to perform directory traversal using paths like
../../evil.txtor absolute paths like/tmp/evil.txt. This could potentially allow an attacker to write or overwrite arbitrary files outside the intended skill extraction directory during the download process.🛠️ The Fix
Implemented a robust, platform-independent boundary check using
pathlibto enforce strict extraction constraints:pathlib.Path.resolve()and utilizes.relative_to(target_dir)to definitively catch and block any traversal escapes.ValueErrorand safely skips any unsafe archive members without crashing the download loop.✅ Validation
Successfully verified the fix using a targeted regression script simulating malicious ZIP payloads:
subdir/nested.md) are extracted correctly.../../evil.txt) and absolute paths (/tmp/evil.txt) are strictly blocked.tests/tools/test_zip_slip.pyto ensure this vulnerability does not return.📋 Checklist