fix(security): prevent Zip Slip path traversal vulnerability in input…#116
Open
zhenliemao wants to merge 1 commit into
Open
fix(security): prevent Zip Slip path traversal vulnerability in input…#116zhenliemao wants to merge 1 commit into
zhenliemao wants to merge 1 commit into
Conversation
…_handler
This change fixes CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability by using Python 3.12+'s built-in parameter in extractall(), which automatically rejects:
- Path traversal sequences (../)
- Symbolic links
- Device files and other special files
Fixes NVIDIA#109
Signed-off-by: GitHub User <494822673@qq.com>
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.
Summary
This PR fixes CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability also known as Zip Slip.
Problem
The
_extract_zipmethod ininput_handler.pywas usingZipFile.extractall()without any path validation, which allowed malicious zip files containing path traversal sequences (../) to write files outside the intended extraction directory.Solution
Use Python 3.12+'s built-in
filter="data"parameter forextractall(), which automatically rejects dangerous entries:../or Windows equivalent\..)This is the official recommended secure extraction method from Python's standard library documentation.
Testing
skillspector scan malicious.zip
Impact
Fixes #109
Checklist