Skip to content

Commit

Permalink
Bugfix: Check symlink safety relative to link name in tarfile extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Fasano committed Feb 12, 2024
1 parent 2ce66d6 commit 76c29fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unblob/handlers/archive/_safe_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def extract(self, tarinfo: tarfile.TarInfo, extract_root: Path): # noqa: C901
"Converted to extraction relative path.",
)
tarinfo.linkname = f"./{tarinfo.linkname}"

if not is_safe_path(
basedir=extract_root,
path=extract_root / tarinfo.linkname,
path=extract_root / Path(tarinfo.name).parent / tarinfo.linkname,
):
self.record_problem(
tarinfo,
Expand Down

0 comments on commit 76c29fe

Please sign in to comment.