Reject path-traversal archive entries and make the install swap cross-filesystem safe #2

Merged
benvin merged 2 commits from benvin/extract-and-swap-fixes into main 2026-09-06 10:46:35 +10:00
Member

M.extract shelled to tar/unzip without inspecting the archive, so a hostile plugin could write outside the destination. Staging also lived on a different filesystem to the install target, so the final rename returned EXDEV and every install failed.

  • Reject archive members that are absolute, escape via .., are device/fifo/socket, or link outside the destination.
  • Stage under <pack root>/.vimpack-stage/ so the swap is a same-filesystem rename; fall back to copy+rename on EXDEV.
  • Propagate build_headers errors from registry.resolve instead of fetching unauthenticated.
  • Reject a dir_name that is not a single path component.
  • Point pipelines at the vimpack-ci service account and install zip.
`M.extract` shelled to `tar`/`unzip` without inspecting the archive, so a hostile plugin could write outside the destination. Staging also lived on a different filesystem to the install target, so the final rename returned EXDEV and every install failed. - Reject archive members that are absolute, escape via `..`, are device/fifo/socket, or link outside the destination. - Stage under `<pack root>/.vimpack-stage/` so the swap is a same-filesystem rename; fall back to copy+rename on EXDEV. - Propagate `build_headers` errors from `registry.resolve` instead of fetching unauthenticated. - Reject a `dir_name` that is not a single path component. - Point pipelines at the `vimpack-ci` service account and install `zip`.
unkin-agent added 1 commit 2026-09-05 16:33:07 +10:00
Validate archive entries and stage inside the pack root
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ca55c9dd9f
- Reject archive members that are absolute, escape via .., are special files, or link outside the destination, before anything is written

- Stage under the pack root so the swap is a same-filesystem rename, with an EXDEV copy fallback; propagate registry auth errors and validate dir_name
unkin-agent added 1 commit 2026-09-05 16:59:27 +10:00
Validate zip symlinks and backslash paths before extraction
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
6e1b018adb
- treat `\` as a separator in safe_relative so `\abs` and `..\..\x` are refused
- read zip symlink targets with `unzip -p` off the `unzip -Z -l` listing and reject escapes before unpacking
benvin merged commit 06781ef4e3 into main 2026-09-06 10:46:35 +10:00
benvin deleted branch benvin/extract-and-swap-fixes 2026-09-06 10:46:36 +10:00
Sign in to join this conversation.