A-1533: harden cache target path validation and extraction - #4102
Draft
zhming0 wants to merge 1 commit into
Draft
Conversation
zhming0
force-pushed
the
a-1533-absolute-target-paths
branch
from
July 20, 2026 14:58
b1e18ce to
17239ce
Compare
Part of A-1533 (multi-PR change). Validate cache target paths up front and reject unsupported or unsafe forms with clear errors instead of failing late or behaving unsafely: - Reject absolute paths outside $HOME at mapping time (previously failed late in BuildArchive), ~/../ escapes, parent-relative paths escaping CWD, and Windows rooted/drive-relative paths - Fix home-prefix matching so a sibling like /home/user2 is not treated as under /home/user - Harden extraction: whole-component entry matching (entry cache2/x no longer matches target cache) and zip-slip containment checks for untrusted archive entries - Validate all target paths in Save and Restore before any download or destructive cleanup - Cleanup refuses filesystem roots, $HOME, top-level dirs, and CWD or its ancestors - Move path validation/cleanup into internal/cache/paths.go Support for absolute target_paths outside $HOME will land in a follow-up PR via an archive manifest format change.
zhming0
force-pushed
the
a-1533-absolute-target-paths
branch
from
July 21, 2026 05:21
17239ce to
cda6797
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of A-1533 (multi-PR change).
Safety hardening for cache save/restore path handling. No behavior change for supported paths (
~/..., absolute under$HOME, CWD-relative); unsupported or unsafe forms now fail early with clear errors instead of failing late or behaving unsafely.$HOMEat mapping time (previously failed late inBuildArchive),~/../escapes, parent-relative paths escaping CWD, and Windows rooted/drive-relative paths/home/user2is not treated as under/home/usercache2/xno longer matches targetcache) and zip-slip containment checks for untrusted archive entries$HOME, top-level dirs, and CWD or its ancestorsinternal/cache/paths.goSupport for absolute
target_pathsoutside$HOMEwill land in a follow-up PR, implemented via an archive manifest format change.