Skip to content

Commit e734195

Browse files
Andrew Fasanoqkaiser
Andrew Fasano
authored andcommitted
Bugfix: Check symlink safety relative to link name in tarfile extraction
1 parent 400df8c commit e734195

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

unblob/handlers/archive/_safe_tarfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ def extract(self, tarinfo: tarfile.TarInfo, extract_root: Path): # noqa: C901
8383
"Converted to extraction relative path.",
8484
)
8585
tarinfo.linkname = f"./{tarinfo.linkname}"
86+
8687
if not is_safe_path(
8788
basedir=extract_root,
88-
path=extract_root / tarinfo.linkname,
89+
path=extract_root / Path(tarinfo.name).parent / tarinfo.linkname,
8990
):
9091
self.record_problem(
9192
tarinfo,

0 commit comments

Comments
 (0)