Skip to content

Commit

Permalink
fix path traversal in PFS extractor script.
Browse files Browse the repository at this point in the history
os.path.join does not fully resolve a path so the condition that follows
will never be true. Fixed by resolving the path using os.path.abspath.
  • Loading branch information
qkaiser committed Oct 26, 2022
1 parent a555eb1 commit 696fe34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/binwalk/plugins/unpfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def extractor(self, fname):
data = binwalk.core.common.BlockFile(fname, 'rb')
data.seek(fs.get_end_of_meta_data())
for entry in fs.entries():
outfile_path = os.path.join(out_dir, entry.fname)
outfile_path = os.path.abspath(os.path.join(out_dir, entry.fname))
if not outfile_path.startswith(out_dir):
binwalk.core.common.warning("Unpfs extractor detected directory traversal attempt for file: '%s'. Refusing to extract." % outfile_path)
else:
Expand Down

0 comments on commit 696fe34

Please sign in to comment.