Repository navigation
v1.94.5.0 fix(autoplan): keep secret files and keys out of the lean reviewer prompt (GST-1164, #3914) - #3921
Merged
Merged
Conversation
…eviewer's draft (GST-1164, #3914) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… draft, redact the rest (GST-1164, #3914) The lean reviewer's prompt goes to an outside model provider. captureDraft left out only some secret-named untracked files (.env and .env.*, not .envrc or .env-production), applied no name rule to tracked files and did no content check. Secret-named files are now never diffed, tracked or untracked, and every other patch goes through redactFindingSpans; a patch it cannot redact is left out with a note. Refs #3914 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…e stays out of the draft (GST-1164) 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>
…ret file renamed or copied on the branch (GST-1164) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… catches (GST-1164) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
5 tasks done
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
The four new leak tests fail on main (fake keys and secret files reach the lean reviewer draft) and pass on this branch.
Before/after as text: The four new leak tests fail on main (fake keys and secret files reach the lean reviewer draft) and pass on this branch
Why
The /ship review of #3901 filed a CRITICAL finding (#3914): "Untracked .envrc / .env-production files are not excluded (only .env and .env.*) and can be inlined into the lean reviewer prompt." That prompt goes to an outside model provider, so a direnv
.envrcor a key sitting in a source file could leave the machine. Now secret-named files never get read into the draft, and everything else goes through gstack's redact engine first.Blast radius
Only
captureDraftinlib/autoplan-lean.tschanges, and its one caller (lib/autoplan-run.ts:182, the lean /autoplan run) gets the same return shape. The draft can only lose content, as a left-out file or a<REDACTED-…>span. Its hash,DRAFT:receipt and inline cap work as before (script ran: all 34 tests intest/autoplan-lean.test.tspass, including the existing receipt, cap and capture-failure cases).Approvals
Source: gstack-approvals record for gsta258-s1-envrc-redact (display only; not an approval citation).
Summary
What could leak, and since when. Since v1.93.36.0 (#3897), the lean /autoplan run (
--kind feature, the default for an unattended Capy run) has put the branch's draft code into a prompt sent to an outside model provider. The issue said main excluded only.envand.env.*. That undersold the old rule, which also left out untracked*.pem,*.key,id_rsa,.netrc,.npmrc,credentials.*and*secret*. But it missed.envrc,.env-production,.env_local,credentials-prod.json,_netrc,.pgpass,.git-credentialsandid_ed25519_sk. It applied no name rule at all to tracked files, so a committed or edited.envrcwent out whole. And it never checked content, so an API key pasted into an ordinary source file went out as written.What blocks it now.
.env*family,*credentials*,_netrc/.netrc,.npmrc,.pypirc,.pgpass,*.pem/*.key/*.p12/*.pfx/*.keystore/*.jks, SSH private keys including_skkeys, and*secret*. It runs before any read, on untracked files and on tracked changes (excluded by:(exclude,literal)pathspec, so git never diffs them). It also catches both sides of a rename or copy that git detects (-M -C). The draft says which files it left out.redactFindingSpans(lib/redact-engine.ts), the same engine telemetry and the flaky-run records use. It also catches the values of credential-named environment variables. A patch it can't redact safely, including one over 1 MiB, is left out with a note.Security call-out (R45). This change reads no secrets or environment variables of its own, makes no network calls, and doesn't touch workflows, setup, install or upgrade scripts. The redact engine it now calls reads credential-named environment variables by value so it can redact them; that is the engine's existing behavior.
Test Coverage
All new code paths have test coverage. Four failing-first tests in
test/autoplan-lean.test.ts: untracked secret files (.envrc,.env-productionand six more) stay out; a committed and edited.envrcstays out of the tracked diff;.envrcrenamed to.envrc.localand.pgpassrenamed topg.txtstay out while an ordinary rename stays compact; a fake key in an untracked file and in a working-tree edit comes out redacted. All four fail on main at b42ad1e and pass here. The draft tests now ignore the developer's global and system git config.Regression proof: fails at main (b42ad1e) · passes after fix (f8571f3, and at 735ddb2 after merging main).
Tests ran: focused 34
Pre-Landing Review
REVIEW_LOOP: passes=2 blocking_found=4 deferred=0 noted=7 fixed=4 scope=frozen unrecorded=1 ledgers_read=3 fix_checks=1 dispatches=3
Review-loop exception: accepted by GStack Minder 2026-11-03 via GSTA-258: standing grant, GSTA-258 builds, 2026-11-03: anything still at the floor after the one fix-check ships as an open note (fix-check at f8571f3, 2 findings)
Gate edits: none detected (0 listed, 0 read; GATE_SCAN tagged=0 at f8571f3)
Review depth: the plan
gstack-review-planprinted (light: one batched specialist with the testing, security, state-machine and red-team checklists, plus the native adversarial reader). Pass 2 was scoped (red team and adversarial), and then the granted fix-check ran. Outside voice: skipped by the review plan (code class, no numeric claims).Fixed: a rename between secret names leaked the old file's lines (pass 1); the round-1
--no-renamesfix sent a secret renamed to an ordinary name in full (pass 2); and the draft tests read the developer's global git excludes.Review notes
Open notes. None of these fails a test, and none is a regression from main.
git add(mv .pgpass pg.txt) shows up as an untracked ordinary-named file, so its content goes out, guarded only by the redact engine (which doesn't recognize a.pgpassline). Main leaks the same file, and also its old lines. A secret copied unchanged and committed under an ordinary name, or renamed and edited past git's 50% rename threshold, behaves the same way. The docs and changelog now say so.http://127.0.0.1:8080, public IPs andTODO(name)markers also come out as<REDACTED-…>, sometimes swallowing a closing quote. That costs the reviewer some syntax fidelity, never data.secrets/prod.yaml,.aws/config,.ssh/config,*.tfstaterely on content redaction).*credentials*and*secret*also hide source files likelib/secret-scan.tsfrom the outside reviewer (with a note).DRAFT: none (draft capture failed…).diff --githeader instead of the path.Eval Results
No paid evals. The change alters the reviewer prompt's draft text only when it holds secret-named files or credential spans, and no eval fixture does.
bun run eval:selectselects 265 cases through the dependents oflib/autoplan-lean.ts, and those stay on the train's gate.Issues
Fixes #3914
Documentation
Status: current. No documentation edits were needed.
Scope: base b42ad1e to head e8aef87 on gsta258-s1-envrc-redact. The candidate has 4 committed files: the changelog fragment, docs/unattended.md, lib/autoplan-lean.ts and test/autoplan-lean.test.ts. Nothing was staged, unstaged or untracked. The 134-doc candidate inventory was checked for relevance, and the banned-terms check returned none.
Documentation health
Coverage debt: none critical. The reference coverage is in docs/unattended.md, and a how-to or tutorial is not needed for this fix. No architecture diagrams are affected, and no regeneration is required.
Test plan
bun test test/autoplan-lean.test.ts: 34 pass, 0 fail (also 34/34 with a global git excludesFile listing.envrc)bun run typecheck: clean;bun run typecheck:test: 814 known diagnostics, none newbun test test/module-size-ratchet.test.ts test/spawnsync-timeout-tripwire.test.ts: pass🤖 Generated with Claude Code