Repository navigation
v1.92.9.0 fix: /freeze checks where an edit really lands, so new-folder paths can't escape it (#3623) - #3758
Merged
Merged
Conversation
…osed when it can't (#3623) check-freeze.sh canonicalized only an existing parent directory and compared the raw string otherwise, so any path through a directory that did not exist yet kept its literal in-boundary prefix: '<b>/../outside/new/x', '<b>/link-out/new/x', '<b>/..', '~/.zshrc' with cwd inside, and 'C:\proj\src\..\..\other\new\x' were all allowed. _resolve_path now walks the path one component at a time, follows symlinks at any depth, and requires both the OS reading and a lexical normalizer's reading of '..' to land inside. Paths it cannot place deny with a reason: symlink loops and chains over 40 links, line breaks, Windows drive- and root-relative paths, names Windows trims, odd UNC roots. Windows rules keep '..' at the drive or share root. The shared extractor keeps trailing newlines and maps lone surrogates on path fields only; /careful's command values are unchanged. Co-authored-by: Quinn O'Donnell <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A PreToolUse hook that outlives the host's timeout does not block the edit, and the component walk is quadratic in path length. Deny a file_path over 4096 characters, and links that grow the walk past 8192, before walking. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The PATH_MAX cap bounded only the file_path text; each link hop could add up to 8192 characters again, and a padded 40-link chain kept the quadratic walk busy for 104s. Count every target against one 8192-character budget. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…et reason (#3623) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…3623) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Git Bash mounts %TEMP% at /tmp and converts HOME through its mounts, so '~/x' and 'D:\...\x' named one file in two spellings and the hook denied a legit edit (windows-free-shard 2 on #3758). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
3 tasks done
This was referenced Nov 3, 2026
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.
What changed
repro.sh on main 5ba425a vs this branch: 11 of 14 escape shapes were allowed and 2 of 6 legit edits were denied before; all 20 are right after.
Before/after as text: repro.sh, main 5ba425a vs this branch: 11 of 14 escapes allowed and 2 of 6 legit edits denied before; all 20 right after
On Windows bash with
cygpathon PATH, the physical reading of a path goes throughcygpath -m, so~/proj/src/x.tsand MSYS-style paths compare against the boundary in the same form. A deny names the path the tool was given, plus(lands at <resolved>)when the resolved target differs, so the message still matches what the agent asked to edit.Why
"/freeze can be escaped with paths through folders that don't exist yet" (#3623, Quinn O'Donnell). /freeze and /guard are the fence people turn on when the agent must not touch anything else, and a fence a new-folder path walks through is a security bug. Now the hook works out where every edit really lands, and when it can't tell, it blocks the edit and says why.
Blast radius
The change touches the /freeze hook (
freeze/bin/check-freeze.sh) and the path fields of the shared payload extractor that /careful also uses (careful/bin/hook-extract.sh). /careful reads onlycommandvalues, and those stay byte-for-byte the same: a regression test pins it, and the full freeze, careful and lifecycle suites pass (410 pass, 0 fail).Approvals
Source: gstack-approvals record for gsta206-freeze-escape (display only; not an approval citation).
Summary
The /freeze hook checked an edit's path by resolving only an existing parent folder. When that parent didn't exist yet, it compared the raw text, so
..and symlinks inside a new-folder path were never applied. It also never expanded~in the file path. This PR rewrites outside PR #3624's idea, a walk over every path component, on current main. That branch was never checked out, built or merged, and this PR's code was written on main. One disclosure: before the crew's untrusted-code rule arrived on 2026-10-31, the branch'scheck-freeze.shwas copied out of git and run locally to measure its behavior. Read as text, it makes no network calls and touches no environment variables, secrets, permissions or workflows. Nothing from it ran after the rule arrived._resolve_pathwalks components left to right:.and empty components drop,..pops, and a symlink at any depth is replaced by its target even when the rest of the path does not exist. It uses bash 3.2 builtins plusreadlink.... An edit counts as inside only when both the OS reading (<link>/..is the target's parent) and a path normalizer's reading (Node'spath.resolve) land inside.~and relative paths.~expands first, and relative paths resolve against the physical working folder.careful/bin/hook-extract.sh, path fields keep trailing newlines, and lone surrogates become U+FFFD the way Node writes the name. Command values are unchanged.Escapes found in review beyond #3623, each fixed with a test:
..off a name, and a dropped trailing newline..popping pastC:\or\\server\share\\.\and\\?\device paths, bareC:,///C:\..\\/prefix read as UNC on POSIX$PWDthrough a symlink//on Linux and macOS read as a UNC prefixSecurity read of #3624. I read the diff as text. It makes no network calls, reads no environment variables or secrets, changes no permissions, edits no workflow, setup or install script, and adds no dependency. This PR is the same. It changes two shell scripts, one test file, docs and a changelog fragment.
Dropped as inconsequential: an empty or relative
$HOME. That is the user's own environment, not something a tool payload controls.Not covered: Bash-tool writes (freeze guards Edit, Write and NotebookEdit only), hard links, bind mounts, and a symlink swapped between check and write.
Test Coverage
The
boundary escape shapes (#3623)block intest/hook-scripts.test.tscovers every shape above. The tests were written first and fail on main 5ba425a. Each Step 11 fix also failed first: the Windows link-target test at a5ad761 and the double-slash test at 5a6547c. Windows-bash rules run on any runner throughOSTYPE=msys. The repro also runs under bash 3.2 (docker run bash:3.2, 20 of 20).Tests ran: tests 410
Pre-Landing Review
The review had two full passes and four fix-checks, plus the adversarial pass (native, and an outside voice on google/gemini-4-argon).
cygpath -mfor the physical reading) and b7b8468 (the deny names the rawfile_path).REVIEW_LOOP: passes=2 blocking_found=8 deferred=2 noted=3 fixed=8 scope=frozen fix_checks=4 dispatches=4
Gate edits: none detected (no gate-class paths in the diff)
Outside review: completed (google/gemini-4-argon via OpenRouter), 4 findings: 2 fixed, 2 deferred as pre-existing.
Exploratory QA
Probes ran through the real hook with temporary state roots, covering Linux bash 5, bash 3.2, and Windows-bash rules through
OSTYPE=msys. Every shape above denies, and the positive controls allow. macOS native and real Windows were not run here; the windows-free-tests CI covers Windows.Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
Plan Completion
The plan was approved (autoplan-20261031175102). Every plan item was done: the resolver, the fail-closed denies,
~expansion, the extractor change with its /careful regression, the tests, docs and the changelog fragment. Escapes found later in review were added above.Issues
Fixes #3623
Supersedes #3624
Contributed by @Quinnod345
TODOS
No TODO items completed in this PR.
Documentation
Status: blocked under the owner's named risk. Scope: README.md, docs/, freeze/SKILL.md(.tmpl), guard/SKILL.md.tmpl, changelog.d/. Audit gsta206-docs-2 found everything current at a5ad761; it is stale by hash only after the code-only commits 5a6547c and 2034fbb. The two later commits, 4a28416 and b7b8468, also touch only
freeze/bin/check-freeze.shandtest/hook-scripts.test.ts.Documentation exception: accepted by GStack Minder (Captain) 2026-10-31 via Captain reply in GSTA-206: "Decision: do it. Accept the docs risk": the two commits after the audit (5a6547c, 2034fbb) touch only freeze/bin/check-freeze.sh and its test, no doc changed, and the changelog fragment already covers the new denies
Test plan
bun test test/hook-scripts.test.ts test/investigate-freeze-path.test.ts test/freeze-owned-lifecycle.test.ts test/workflow-boundaries-fixture.test.ts test/setup-hook-syntax-gate.test.ts: 410 pass, 2 skip, 0 failgstack-pregate --stage tests --remote) at tree 37e49be (head b7b8468): 18012 tests, 0 failedrepro.shunder docker bash:3.2: 20 of 20Co-authored-by: Quinn O'Donnell [email protected]
🤖 Generated with Claude Code