-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix arbitrary file write during tarfile extraction
Fixes #3302 Address arbitrary file write vulnerability during tarfile extraction in `luigi/contrib/lsf_runner.py`. * Add a function `_is_within_directory(directory, target)` to check if a target path is within a directory. * Add a function `_safe_extract(tar, path=".", members=None, *, numeric_owner=False)` to safely extract tar files. * Replace the existing tar extraction code with a call to `_safe_extract` in the `extract_packages_archive` function. * Add a test case `test_safe_extract` to verify the safe extraction of tar files in `test/contrib/lsf_test.py`. * Add a test case `test_safe_extract_with_traversal` to verify that directory traversal is prevented in `test/contrib/lsf_test.py`.
- Loading branch information
1 parent
74e6e63
commit 91ce61f
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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