Skip to content

/cso audits repositories that track symlinks, without following them (#4540) - #4567

Merged
capy-ai[bot] merged 6 commits into
mainfrom
cso-audits-repos-with-symlinks
Nov 20, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
cso-audits-repos-with-symlinks

Conversation

@garrytan

@garrytan garrytan commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

/cso no longer stops on a repository that tracks a symlink, such as gstack's own connect-chrome or CLAUDE.md -> AGENTS.md: each link is listed in the report by its target string, or as withheld when the target matches a secret pattern, and it is never followed.
Why: a security audit that refuses ordinary repositories audits nothing, and following a link would let it point the scanner at /etc/passwd or out through ...
Nothing to do. FIFOs, sockets and devices are still refused, and --paths now limits that check to the audited directories.

What changed

Running /cso on almost any real repository used to fail with UNSAFE_PATH the moment it met one symlink; 5 of 8 mid-size open-source repositories we measured stopped there. Now lib/cso/snapshot.ts reads each tracked or nonignored link with lstat and readlink only, binds it by device, inode, mode and target bytes, and records it as an exclusion that names its target and says, from the text alone, whether it is absolute, escapes the repository, or names a path inside it. Nothing stats, resolves or opens through a link, so a link to /etc/passwd, /dev/null, a .. escape, a loop or a dangling link is reported and never read, and links never enter the execution snapshot. A target that matches any secret pattern, whole or in any path segment, is withheld and no path derived from it is shown. A comparison base hashes a link as Git does (mode 120000, blob of the target), so --diff sees a retargeted link. A link changed during capture fails as SNAPSHOT_RACE. The special-file walk now descends only into the --paths scope. The troubleshooting page, the changelog entry and TODOS.md describe the new behavior; thanks to @nathanshox for the report and first fix (#4540).

Why record instead of resolving inside the root

The outside PR (#4540) resolved each link with realpath and stat and admitted it when the result stayed inside the repository. That is safe only if the resolution itself is: it follows every hop on the live filesystem, can touch an automounter or FUSE target while deciding, and leaves a window between the check and any later use. Recording the target string needs no resolution at all, so its safety does not depend on getting containment right, and it loses nothing an audit needs: Git stores a symlink as exactly that string, and a target inside the repository is audited under its own path anyway.

Tests
  • bun test --timeout=30000 test/cso-ordinary-repos.test.ts test/cso-snapshot-state.test.ts: 106 pass, 0 fail
  • Free Tests run 44785903660 at c0bd62d: green, 1718 files carried
  • typecheck, module-size and conflict-marker guards: pass
Security notes

No network, secrets, permissions, workflows, install scripts or dependencies change. The link target string is new text in report.json and the report: it passes through redact() and JSON.stringify, is bounded by the OS path limit, and sits in the same byte-bounded coverage lists as file paths, which can already hold arbitrary names.

Agent notes
Blast radius

The change stays inside /cso capture. It touches the new link branch in capture(), the text symlinkTransformation writes, and the scoped special-file walk. The manifest consumers in lib/cso/cli.ts match transformations by their excluded: prefix and recheck link entries by target bytes, so they need no change (read in review, and the 106 focused tests and CI's free suite at this head pass).

Pre-Landing Review

Four review rounds ran on this security-sensitive change (specialists, red team, an in-house adversarial reader and a second-model review on GPT-6.1 Sol). They found three secret-exposure problems in how link targets were printed, each fixed with a regression test: the in-repository path was printed unredacted, a key=value secret after a slash slipped past the redactor, and redacting per path segment hid URL passwords. The final check of the last fix found nothing. Eight lower-severity notes stay open below.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL sf-3df546269d55 security finding, details recorded privately
  • INFORMATIONAL sf-fd631400a8d9 security finding, details recorded privately
  • INFORMATIONAL security finding, details recorded privately (final review, red team, 2 items)
  • INFORMATIONAL security finding, details recorded privately (final review, adversarial reader, 4 items)
Exploratory QA

A fixture repository with links to /etc/passwd, README.md and a synthetic token was audited with gstack-cso start --offline at each fixed head. Before the first fix one run file held the raw token; at the final head the run exits 0, no run file holds the token, and none holds /etc/passwd content. A synthetic postgres URL with a password is withheld at the final head. Smoke only: races, FIFOs and sockets are covered by the tests, not by probes.

Eval Results

No prompt-related files changed, so no evals were selected (the selector deferred the three /cso evals to release coverage).

Issues

Refs #4540

TODOS
  • Marked the "Tracked symlinks refuse the whole /cso run" item as decided in this PR.
Documentation

Status: blocked, shipped under a maintainer exception (recorded in the agent notes). The final audit (scope: the diff from 92c6c8a in lib/cso/snapshot.ts, docs/troubleshooting.md, the changelog entry, TODOS.md and the tests) found three sentences that still said every link is listed by its target string. The auditor's own proposed clause was then applied to all three.

Agent notes

Agent notes

Rebuilt on current main from a text-only read of outside PR #4540 by @nathanshox (never checked out or run); the design differs (record, never resolve). Issue GST-3291.

Approvals

Approved: yes (record r-e93670f56da0). The full approval record stays private.
Plan: exempt: bug fix with a failing-first test (R65, --kind fix)
Plan check: exempt bug fix

Documentation exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-20 via Captain reply on GSTA-672: the docs were corrected by the lane to the auditor's own proposed wording after the final audit
REVIEW_LOOP: passes=3 blocking_found=2 deferred=0 noted=8 fixed=4 scope=frozen fix_checks=1 dispatches=12
Gate edits: none detected (6 listed, 4 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Review-loop exception (4b7d57c): Captain GStack Minder (GSTA-36): one exception at 4b7d57c for the pass-2 key=value redaction leak; read-only full review of the final head, no fix round
Review-loop exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-20 via approval a-df2338bea5e0: GStack Minder, 2026-11-20: grant one fix round for p3/outside-voice#1; fail closed, so a target that matches any secret pattern, whole or per segment, is withheld and its resolved path dropped. (fix-check at 5ef2341, 0 findings)
Second-model review: openai/gpt-6.1-sol via a Capy subagent, completed at cd18650 (one blocker, fixed by the granted fix round).

Open in Capy

{
  "schema_version": 1,
  "pr": 4567,
  "head": "c0bd62d50c90c5e1f5e30f448da2cc97a64ecdae",
  "version": "1.102.0.0",
  "base": "main",
  "gate": {
    "bun run test": {
      "pass": 1718,
      "fail": 0,
      "skip": 0
    },
    "cso-focused": {
      "pass": 106,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "bun_run_test",
      "run": 44785903660,
      "attempt": 1,
      "tree": "0781b1c8a295dcccf888094d3ae5242c7eb7cbd4"
    }
  ],
  "calls": 54,
  "session_kind": "unattended",
  "run": "ship-4567",
  "head_tree": "0781b1c8a295dcccf888094d3ae5242c7eb7cbd4",
  "product_patch_id": "da94fcee944b8a44b0170cc0c6ea638b55fed106",
  "gstack_version": "1.102.0.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 120,
    "rules": "3e7e9d5d0a0d8879",
    "base": "6287c75e2cd74392a5e601739f7d0d6e73f29df3",
    "registry": "6287c75e2cd74392a5e601739f7d0d6e73f29df3",
    "gate_scan": {
      "tagged": 0,
      "head": "c0bd62d50c90c5e1f5e30f448da2cc97a64ecdae"
    },
    "reasons": [
      "risk:security",
      "runtime=120"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @0781b1c8a295 (8 checks, current for c0bd62d50c90)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44785903660/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=0781b1c8a295 tests=38518 skipped=89 runs=44785903660/1 profiles=ci-reuse/free-tests heads=c0bd62d50c90 verified=2026-11-20T17:51:21.835Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      4540
    ],
    "flakes": []
  },
  "docs": {
    "status": "blocked",
    "scope": "re-audit of the diff from 92c6c8a5 (lib/cso/snapshot.ts, docs/troubleshooting.md, changelog.d/cso-audits-repos-with-symlinks.md, TODOS.md, tests) for the withheld secret-matching symlink targets",
    "exception": {
      "accepted_by": "Captain GStack Minder (GSTA-36)",
      "date": "2026-11-20",
      "via": "Captain reply on GSTA-672",
      "reason": "the docs were corrected by the lane to the auditor's own proposed wording after the final audit"
    }
  },
  "review_loop": {
    "passes": 3,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 8,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 4,
    "dispatches": {
      "specialist": 9,
      "red-team": 3
    }
  },
  "review_loop_exception": {
    "accepted_by": "Captain GStack Minder (GSTA-36)",
    "date": "2026-11-20",
    "via": "approval a-df2338bea5e0",
    "reason": "GStack Minder, 2026-11-20: grant one fix round for p3/outside-voice#1; fail closed, so a target that matches any secret pattern, whole or per segment, is withheld and its resolved path dropped.",
    "fix_check": {
      "head": "5ef2341b0b2bd88fd657e54def62ccccd4fb884c",
      "findings": 0
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "cd186503a30a2e148ecb55c59c22a90ae4d654ad",
      "pr": 4567,
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "fail closed on any secret-pattern match in a symlink target",
      "at": "2026-11-20T17:33:04.929Z",
      "approval": "a-df2338bea5e0",
      "stop_run": "ship-4567",
      "findings": [
        "p3/outside-voice#1"
      ]
    }
  ],
  "gate_dispositions": []
}
{"head":"cd186503a30a2e148ecb55c59c22a90ae4d654ad","run":"ship-4567","mark":"stop","tree":"5f85ad39a7c6bd113ab4d719c4db3fa1d9a85347"}
{"head":"cd186503a30a2e148ecb55c59c22a90ae4d654ad","run":"ship-4567","mark":"grant","grant":"a-df2338bea5e0"}

…4540)

Each tracked or nonignored symlink is recorded by its target string and
never followed; FIFOs, sockets and devices are still refused, and --paths
now limits the special-file walk to the audited directories.

Co-authored-by: nathanshox <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 5 commits November 20, 2026 16:28
…g it

The secrets check read the fixture key 'passwd' pointing at /etc/passwd as a
password assignment. The link is now named 'host-users'; the test is unchanged.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A tracked link whose target held a credential had the raw value copied into the
report next to its redaction marker. The path a link resolves to is now redacted
and quoted, so it can neither leak a secret nor read as extra report sentences.

Review-Finding: p1/specialist-batched#1 reader=security
Review-Finding: p1/red-team#3 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The redactor misses a key=value secret that follows a slash, so a link target
such as ../password=<value> still reached the report. Each segment is now
redacted on its own and the in-repository path is built from that redacted
target. TODOS.md records the symlink design as decided.

Review-Finding: p2/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Redacting each path segment on its own hid the URL context the credential
detectors need, so a target like postgres://user:<password>@host/db, or a
secret containing a slash, could still reach the report. A target that matches
any secret pattern, whole or per segment, is now withheld and no path derived
from it is shown.

Review-Finding: p3/outside-voice#1 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The troubleshooting page, the changelog entry and TODOS.md said every link is
listed with its target string; a target that matches a secret pattern is
withheld instead.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit a529769 into main Nov 20, 2026
94 checks passed
@garrytan garrytan mentioned this pull request Nov 20, 2026
capy-ai Bot added a commit that referenced this pull request Nov 20, 2026
- Two /ship approval records stop needing workarounds. (#4549)
- For contributors: the paid auto-decide check counts a start step that ran while the skill loaded. (#4543)
- The destructive-command check closes three ways past its disk-wipe and force-push blocks. (#4534)
- A green CI run still counts when the repository's artifact storage is full. (#4536)
- `/cso` now audits repositories that track symlinks. (#4567)
- A doc-sync eval stops failing when the audit child drops one field from its result line. (#4555)
- The browse daemon no longer picks port 10080, which Chromium refuses to open. (#4554)
- Opted-in telemetry now says why a skill run ended, which coding agent and model family ran it, and whether an upgrade worked. (#4542)
- A preregistration with only its write-up and plain data now gets the write-up review: one reviewer, one round. (#4544)
- When owner rulings don't clear a stopped review, `gstack-review-read` now says which findings are left. (#4553)
- The prompt-routing hook now names your installed bug-fix skill on bug reports, alone, and never puts /verify ahead of it. (#4539)
- Owner rulings now close a stopped review whose findings were logged in a findings file. (#4568)
- /ship can finish after the owner accepts a stopped review's findings as open notes. (#4552)
- /ship no longer starts the full test suite on your machine when CI's earlier run can't be reused (GST-3277). (#4565)
- The prompt-routing hook no longer acts on words inside backticks. (#4566)
- In Claude Code, a gstack skill's start step now runs when the skill loads, so the model can't skip it. (#4509)
- gstack's telemetry backend only accepts writes through its own validated endpoint, and the community dashboard now counts real use. (#4537)
- gstack now says what it's adding before it adds a background job or a browser extension. (#4538)
- For contributors: every flaky pass in Free Tests is now recorded. (#4572)
- For contributors: Free Tests on pull requests starts its test shards one round of small jobs sooner. (#4570)
- Secret values written as `name=value` at the end of a path are now hidden. (#4571)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Follow-up landed in #4592: /cso now checks every folder above a source path, from the repository root down, before it looks at the path itself. A tracked file under a folder that was swapped for a symlink now fails closed with UNSAFE_PATH before anything is stat-ed through the link, and the size count in the source-cap message skips such paths the same way.

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.

1 participant