fix(host-kit): keep extracted directories owner-accessible
Summary
An archive could declare a directory without owner read access (for example 0o300). The extractor applied that mode with recursive mkdir, so implied parents got it too, and cleanup's recursive rm then failed with EACCES:
- a failed extraction reported the cleanup error instead of its own, and leaked the temp tree;
- a successful one leaked the extracted tree after install.
Any caller who can get an archive extracted (uploads, path sources, allowlisted URLs) could repeat this, up to the 4 GiB expansion budget each time.
Zip and tar now share one entry-mode rule in archive-safety.ts: declared permission bits only (set-id and sticky stripped, as before), at least owner rwx for directories and rw for files. Implied parents are created with the default mode; directories get their declared mode under the process umask whether declared before or after their children, so entry order does not change permissions. An explicit mode of zero is honored as owner access only; only an absent mode (including zip entries without Unix attributes) falls back to the default.
This also adds adversarial extraction tests for guarantees that had no coverage: zip/tar symlinks and hard links, device and FIFO entries, ../absolute paths, PAX path/linkpath overrides, duplicate, case-colliding, and file/directory-colliding entries, set-id stripping, and zero modes. It's groundwork for allowing archive URLs from any public host, which follows in #3110.
6 files, all in packages/host-kit/src/internal.
Validation
- Tested commit:
5d9f400aa - The unreadable-directory tests fail on
origin/main(4 of 20; the unfixed bug also left the run's TMPDIR undeletable) and pass after the fix. The entry-order and zero-mode tests fail against0f45e3band pass after4b1b594. pnpm check:affected --runon5d9f400aa: all runnable checks passed (434 files, 2,917 tests, typecheck, lint, layering, fallow, build). Replay and smoke lanes are GitHub-authoritative.- Host-side extraction only, so no device run applies.