Skip to content

Commit

Permalink
Added patch from upstream project
Browse files Browse the repository at this point in the history
  • Loading branch information
pseiler committed Oct 12, 2023
1 parent 7de9951 commit 4cbbb06
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pysteamcmd/steamcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,26 @@ def _extract_steamcmd(self):

elif self.platform == 'Linux':
with tarfile.open(self.steamcmd_zip, 'r:gz') as f:
return f.extractall(self.install_path)
def is_within_directory(directory, target):

abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)

prefix = os.path.commonprefix([abs_directory, abs_target])

return prefix == abs_directory

def safe_extract(tar, path=".", members=None, *, numeric_owner=False):

for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")

tar.extractall(path, members, numeric_owner=numeric_owner)


safe_extract(f, self.install_path)

else:
# This should never happen, but let's just throw it just in case.
Expand Down

0 comments on commit 4cbbb06

Please sign in to comment.