Repository navigation
Closed
Labels
S1Severity 1: broken install/upgrade, data loss, wrong security result, or main CI red
Description
Summary
freeze/bin/check-freeze.sh has two boundary-check issues:
1. _resolve_path falls back to the uncanonicalized string when a parent directory does not exist (freeze/bin/check-freeze.sh:169-188)
_resolve_path only follows symlinks on the final path component (while [ -L "$_p" ]) and runs cd "$_dir" 2>/dev/null && pwd -P || printf '%s' "$_dir" on the immediate parent directory.
Whenever a parent directory does not exist yet (for example, Write or NotebookEdit creating a file in a new subdirectory), cd "$_dir" fails and falls back to the raw uncanonicalized _dir string:
- Boundary escape via
..through a non-existent directory:
Passingfile_path: "<boundary>/../outside/new-dir/secret.ts"failscdonoutside/new-dir, keeps the literal<boundary>/prefix, matches"${FREEZE_DIR%/}/"*at line 194, and returns{}(allow). - Boundary escape via an in-boundary directory symlink + non-existent subdirectory:
If<boundary>/out-linkis a symlink pointing outside<boundary>, passingfile_path: "<boundary>/out-link/new-dir/secret.ts"fails both[ -L "$_p" ](final component does not exist) andcd(new-dirdoes not exist), keeps<boundary>/out-link/..., and returns{}(allow). - Boundary escape via trailing
..:
Passingfile_path: "<boundary>/.."resolvesdirnameto<boundary>andbasenameto.., reconstructing<boundary>/..and matching"${FREEZE_DIR%/}/"*(allow). - False denial on macOS for new subdirectories inside a frozen directory:
When a frozen directory sits under a symlinked parent (/tmp->/private/tmpor/var/folders->/private/var/folderson macOS),FREEZE_DIRresolves viapwd -Pto/private/var/folders/.../boundary, while creating<boundary>/new-subdir/Component.tsxfailscdonnew-subdirand stays/var/folders/.../boundary/new-subdir/Component.tsx, falsely denying an in-boundary write.
2. Missing tilde (~/) expansion on FILE_PATH and GNU BRE \+ in sed (freeze/bin/check-freeze.sh:85-88, 143-159)
FREEZE_DIRexpands a leading~/or~to$HOMEat lines 85-88, butFILE_PATHomits tilde expansion at lines 143-149 and instead prepends$(pwd)/. Whenpwdis insideFREEZE_DIR, an out-of-boundary tilde path like~/.zshrcbecomes$(pwd)/~/.zshrcand is allowed; whenpwdis outsideFREEZE_DIR, an in-boundary tilde path like~/project/src/index.tsis denied.- Line 157 uses
sed 's|/\+|/|g;s|/$||', where\+is a GNU BRE extension that macOS BSDsedreads as a literal+rather than one-or-more slashes (//*in POSIX BRE).
Reproduction
# 1. Create a freeze boundary and a state file (use pwd -P so macOS /tmp -> /private/tmp does not mask it)
mkdir -p /tmp/freeze-repro/boundary /tmp/freeze-repro/outside
T="$(cd /tmp/freeze-repro && pwd -P)"
printf '%s/boundary\n' "$T" > "$T/freeze-dir.txt"
# 2. Pass a path that traverses out of the boundary into a non-existent directory
printf '{"tool_input":{"file_path":"%s/boundary/../outside/new-dir/secret.ts"}}' "$T" \
| GSTACK_STATE_DIR="$T" bash freeze/bin/check-freeze.sh
# Actual output on main: {} (allowed)
# Expected output: {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny",...}}Companion PR: #3624 (test/hook-scripts.test.ts, 315 pass, 0 fail).
Metadata
Metadata
Assignees
Labels
S1Severity 1: broken install/upgrade, data loss, wrong security result, or main CI red
Activity
freeze: compare Git Bash paths by cygpath's drive spelling (#3623)
freeze: name the edited path as given in the deny, with where it lands (
v1.92.9.0 fix: /freeze checks where an edit really lands, so new-fold…
capy-ai commentedon Nov 1, 2026
Fixed in #3758, merged as 510dd07 and released in v1.92.9.0. /freeze now resolves the whole path, including
.., symlinks inside folders that don't exist yet, and~. It blocks any edit whose path it can't resolve. Thanks @Quinnod345 for the clear report and repro.