Harden updater tar extraction against path traversal #4

Open
opened 2025-12-15 00:36:21 +00:00 by 44r0n7 · 0 comments
Owner

Problem

  • The updater extracts bundle tar.gz with tarfile.extractall without validating member paths.
  • Malicious or corrupted archives could write outside /var/tmp/pikit-update or overwrite system files.

Proposal

  • Implement a safe_extract helper that rejects members whose names are absolute, contain .., or escape the intended target directory.
  • Use it in _install_manifest when unpacking bundle.tar.gz.
  • Add unit tests covering allowed/blocked entries.

Acceptance

  • Extracting a tar with ../ or absolute paths fails with a clear error and leaves state stable.
  • Normal bundles still install successfully.
  • Tests cover traversal cases.
Problem - The updater extracts bundle tar.gz with tarfile.extractall without validating member paths. - Malicious or corrupted archives could write outside /var/tmp/pikit-update or overwrite system files. Proposal - Implement a safe_extract helper that rejects members whose names are absolute, contain .., or escape the intended target directory. - Use it in _install_manifest when unpacking bundle.tar.gz. - Add unit tests covering allowed/blocked entries. Acceptance - Extracting a tar with ../ or absolute paths fails with a clear error and leaves state stable. - Normal bundles still install successfully. - Tests cover traversal cases.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: 44r0n7/pi-kit#4