This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VCDA-707] Fixed security hole in tarfile.extractall() related to dir…
…ectory walking. (#268) Issue : https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall Fix is outlined at https://stackoverflow.com/questions/10060069/safely-extract-zip-or-tar-using-python/10077309#10077309 tarfile.extractall() method doesn't check for the presence of directory meta info hidden in file names of the archive members. As a result, malicious tar files can be used to extract payload into directories other than the target directory. As a fix we filter out non safe members of archives before extracting them. Testing Done: Created an archive containing a file named "\..\1.txt". If this archive is extracted on windows, it will extract the text file in the root directory. Wrote a a sample script to extract this tarfile with and without the filter we wrote. Without filter : File gets extracted in the root folder. With filter : We get expected error message. ````C:\Users\sena\Desktop\test>python extract.py attack_test.tar \..\1.txt is blocked: illegal path.```` Also tried out the extraction script on a regular ova file and the extraction went on without any hiccups
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
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