Skip to content

Fix for CVE-2024-55587: Prevent Directory Traversal in ZIP Extraction #43

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ezhiltech
Copy link

PR Description:

Issue Addressed
This PR mitigates the security vulnerability CVE-2024-55587, which allows directory traversal attacks when extracting ZIP files using python-libarchive.

Fix Implemented:
Sanitized Filenames:

Introduced sanitize_filename() in zip.py to remove malicious path components like ../ and absolute paths.
Ensures extracted files remain within the intended directory.
Updated extract() and extractall():

Applied sanitize_filename() to prevent unsafe file extractions.
Raised ValueError if an unsafe path is detected.
Added Test Cases:

Unit tests in test_zip.py to validate:

Prevents directory traversal attacks, mitigating the security risk.
Ensures backward compatibility with existing safe extractions.
Improves overall security of ZipFile extraction methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant