Skip to content

v1.92.9.0 fix: /freeze checks where an edit really lands, so new-folder paths can't escape it (#3623) - #3758

Merged
capy-ai[bot] merged 11 commits into
mainfrom
gsta206-freeze-escape
Nov 1, 2026
Merged

capy-ai[bot] merged 11 commits into
mainfrom
gsta206-freeze-escape

Conversation

@garrytan

@garrytan garrytan commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3758,
  "head": "b7b84683258137c272f8b2401e2db7e0c7d526d2",
  "version": "1.91.376.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 410,
      "fail": 0,
      "skip": 2
    }
  },
  "session_kind": "unattended",
  "head_tree": "37e49beb17abc20a2e12c5dc81073a9bc3975e64",
  "product_patch_id": "62702a7e87d382f9635df9b91ec4e5b7a1bd1259",
  "gstack_version": "1.91.376.0",
  "review_depth": {
    "depth": "standard",
    "class": "code",
    "runtime_lines": 291,
    "rules": "150435b0a543019a",
    "base": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "registry": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "gate_scan": {
      "tagged": 0,
      "head": "b7b84683258137c272f8b2401e2db7e0c7d526d2"
    },
    "reasons": [
      "runtime=291>50"
    ]
  },
  "pregate": "requires-remote cleared @37e49beb17ab (1 checks, current for b7b846832581)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41247567180",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/41247567165",
    "pregate.json/remote_gate: remote-gate tree=37e49beb17ab tests=18012"
  ],
  "issues": {
    "fixes": [
      3623
    ],
    "refs": [],
    "flakes": [],
    "related": [
      {
        "pr": 3624,
        "author": "Quinnod345",
        "closes": [
          3623
        ],
        "supersedes": true,
        "credit": true
      }
    ]
  },
  "docs": {
    "status": "blocked",
    "scope": "README.md, docs/, freeze/SKILL.md(.tmpl), guard/SKILL.md.tmpl, changelog.d/ (audit gsta206-docs-2 at a5ad761, stale by hash after code-only commits 5a6547c 2034fbb)",
    "exception": {
      "accepted_by": "GStack Minder (Captain)",
      "date": "2026-10-31",
      "via": "Captain reply in GSTA-206: \"Decision: do it. Accept the docs risk\"",
      "reason": "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"
    }
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 8,
    "deferred": 2,
    "noted": 3,
    "fixed": 8,
    "scope": "frozen",
    "fix_checks": 4,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  }
}

What changed

repro.sh, main 5ba425a vs this branch: 11 of 14 escapes allowed and 2 of 6 legit edits denied before; all 20 right after

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
--- Before · before.txt · captured output
+++ After · after.txt · captured output
 == expect deny
+deny   /home/proj/src/../../../outside/new-dir/x.ts (cwd )
+deny   /home/proj/src/out-link/new-dir/x.ts (cwd )
+deny   /home/proj/src/up-link/new-dir/x.ts (cwd )
+deny   /home/proj/src/.. (cwd )
+deny   /home/proj/src/dangle/x.ts (cwd )
+deny   /home/proj/src/c45/x.ts (cwd )
+deny   /home/proj/src/c45/new/x.ts (cwd )
+deny   /home/proj/src/loopa/x.ts (cwd )
+deny   ~/.zshrc (cwd /home/proj/src)
-allow  /home/proj/src/../../../outside/new-dir/x.ts (cwd )
-allow  /home/proj/src/out-link/new-dir/x.ts (cwd )
-allow  /home/proj/src/up-link/new-dir/x.ts (cwd )
-allow  /home/proj/src/.. (cwd )
-allow  /home/proj/src/dangle/x.ts (cwd )
-allow  /home/proj/src/c45/x.ts (cwd )
-allow  /home/proj/src/c45/new/x.ts (cwd )
-allow  /home/proj/src/loopa/x.ts (cwd )
-allow  ~/.zshrc (cwd /home/proj/src)
 deny   ../../x.ts (cwd /home/proj/src)
+deny   ../../new/x.ts (cwd /home/proj/src)
-allow  ../../new/x.ts (cwd /home/proj/src)
 deny   /outside/..\home\proj\src\x.ts (cwd )
 deny   /HOME/proj/src/x.ts (cwd )
+deny   C:\dev\proj\src\..\..\other\new\x.ts (cwd )
-allow  C:\dev\proj\src\..\..\other\new\x.ts (cwd )
 == expect allow
 allow  /home/proj/src/new-dir/x.ts (cwd )
 allow  /home/proj/src/a/../b/x.ts (cwd )
+allow  ~/proj/src/x.ts (cwd )
+allow  /alias/bnd/new/x.ts (cwd )
-deny   ~/proj/src/x.ts (cwd )
-deny   /alias/bnd/new/x.ts (cwd )
 allow  /real/bnd/new/x.ts (cwd )
 allow  C:\dev\proj\src\new\x.ts (cwd )
 

On Windows bash with cygpath on PATH, the physical reading of a path goes through cygpath -m, so ~/proj/src/x.ts and 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 only command values, 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

Date Asked Exact words Outcome Covers Still pending
2026-10-31 Approve the plan "Plan v2: close the /freeze boundary escapes (#3623), rewritten from outside PR #3624" (autoplan run autoplan-20261031175102, 3 decisions) “Approved: do it (A1 B1 C1). S1 security fix, so no further plan round.” (GStack Minder, relayed by agent:jam_01M69H5SSB0JHT0B13HRK779G0) approved the reviewed plan (sha256 528726ad38e6), every recommendation taken none

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's check-freeze.sh was 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.

  • One resolver for the whole path. _resolve_path walks 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 plus readlink.
  • Two readings of ... An edit counts as inside only when both the OS reading (<link>/.. is the target's parent) and a path normalizer's reading (Node's path.resolve) land inside.
  • Fail closed with a reason. When the hook can't tell where a path lands, it blocks the edit. That covers symlink loops, chains over 40 links, unreadable links, line breaks, paths over 4096 characters, a path plus link targets over 8192 characters, Windows drive-relative and root-relative paths and link targets, names Windows trims, and odd UNC roots.
  • ~ and relative paths. ~ expands first, and relative paths resolve against the physical working folder.
  • The shared extractor. In 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:

  • a newline that split .. off a name, and a dropped trailing newline
  • .. popping past C:\ or \\server\share
  • triple slashes, \\.\ and \\?\ device paths, bare C:, ///
  • POSIX link targets shaped like C:\..
  • a \\/ prefix read as UNC on POSIX
  • a logical $PWD through a symlink
  • a lone-surrogate name mismatch
  • a long path or long link targets outliving the hook timeout
  • Windows link targets relative to a drive or its root
  • a leading // on Linux and macOS read as a UNC prefix

Security 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 in test/hook-scripts.test.ts covers 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 through OSTYPE=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).

  • Pass 1 Red Team: a quadratic walk let a hook timeout fail open (fixed in 3ad63ec).
  • Pass 2 Red Team: link hops re-expanded that walk (fixed in 1d90c1b).
  • Outside voice: two link-target escapes (fixed in 5a6547c and 2034fbb).
  • Fix-checks 3–6: NO FINDINGS, including the Windows CI repairs in 4a28416 (cygpath -m for the physical reading) and b7b8468 (the deny names the raw file_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.sh and test/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 fail
  • Remote pregate (gstack-pregate --stage tests --remote) at tree 37e49be (head b7b8468): 18012 tests, 0 failed
  • repro.sh under docker bash:3.2: 20 of 20

Co-authored-by: Quinn O'Donnell [email protected]

🤖 Generated with Claude Code

Open in Capy

garrytan and others added 8 commits October 31, 2026 19:36
…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>
)

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>
@trunk-io

trunk-io Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits October 31, 2026 21:54
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>
#3623)

cygpath's drive spelling made a Windows deny print /c/Program Files/Git/etc/hosts
for /etc/hosts (windows-free-shard 2 on #3758, 'Edit denials name the tool and
file_path too').

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title fix: /freeze checks where an edit really lands, so new-folder paths can't escape it (#3623) v1.92.9.0 fix: /freeze checks where an edit really lands, so new-folder paths can't escape it (#3623) Nov 1, 2026
@capy-ai
capy-ai Bot merged commit 510dd07 into main Nov 1, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(freeze): check-freeze.sh allows boundary escape when target parent directory does not exist and mis-resolves tilde paths

1 participant