Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion agent/curator_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,19 @@ def rollback(backup_id: Optional[str] = None) -> Tuple[bool, str, Optional[Path]
try:
tf.extractall(str(skills), filter="data") # type: ignore[call-arg]
except TypeError:
# Python < 3.12 — no filter kwarg
# Python < 3.12 — no filter kwarg. Replicate the same
# protections manually: reject symlinks, hardlinks, and
# device/special files in addition to the path traversal
# check already done above.
for member in tf.getmembers():
if member.issym() or member.islnk():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter="data" does not reject every link: it permits symlink/hardlink members whose targets resolve inside the destination. This makes Python <3.12 stricter than Python 3.12+ and can reject a snapshot that the newer path restores; please either preserve equivalent target-aware behavior or explicitly establish and test all-link rejection as the supported contract.

raise tarfile.TarError(
f"refusing to extract symlink/hardlink: {member.name!r}"
)
if not member.isfile() and not member.isdir():
raise tarfile.TarError(
f"refusing to extract non-regular file: {member.name!r}"
)
tf.extractall(str(skills))
except (OSError, tarfile.TarError) as e:
# Best-effort recover: move staged contents back
Expand Down