Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion setup_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def download_library(command):
content = BytesIO(r.read())
content.seek(0)
with tarfile.open(fileobj=content) as tf:
# Prevent Tar Slip (Path Traversal)
base_path = os.path.realpath(os.getcwd())
for member in tf.getmembers():
member_path = os.path.realpath(os.path.join(base_path, member.name))
if not member_path.startswith(base_path + os.sep) and member_path != base_path:
raise Exception('Attempted Path Traversal in Tar File')
dirname = tf.getnames()[0].partition('/')[0]
tf.extractall()
shutil.move(dirname, libdir)
Expand Down Expand Up @@ -149,4 +155,4 @@ def detect_dll():
for fn in os.listdir(os.path.join(here, 'libsecp256k1')):
if fn.endswith('.dll'):
return True
return False
return False