Skip to content

Commit

Permalink
Check for CVE-2007-4559
Browse files Browse the repository at this point in the history
In practice there is little benefit in crafting a TAR that maliciously
overwrites files right before reprounzip executes your code. You can
just be malicious there. Nevertheless, let's do the right thing.
  • Loading branch information
remram44 committed Oct 29, 2022
1 parent c5393db commit 81e3ea4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions reprounzip/reprounzip/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ def extract_data(self, root, members):
The members must come from get_data().
"""
# Check for CVE-2007-4559
abs_root = root.absolute()
for member in members:
member_path = (root / member.name).absolute()
if not member_path.lies_under(abs_root):
raise ValueError("Invalid path in data tar")

self.data.extractall(str(root), members)

def copy_data_tar(self, target):
Expand Down
7 changes: 7 additions & 0 deletions reprozip/reprozip/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ def extract_data(self, root, members):
The members must come from get_data().
"""
# Check for CVE-2007-4559
abs_root = root.absolute()
for member in members:
member_path = (root / member.name).absolute()
if not member_path.lies_under(abs_root):
raise ValueError("Invalid path in data tar")

self.data.extractall(str(root), members)

def copy_data_tar(self, target):
Expand Down

0 comments on commit 81e3ea4

Please sign in to comment.