Skip to content

Secrets check stops flagging three code shapes and catches concatenated and commented secrets (GST-3004) - #4457

Merged
capy-ai[bot] merged 6 commits into
mainfrom
secrets-check-code-shapes
Nov 17, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
secrets-check-code-shapes

Conversation

@garrytan

@garrytan garrytan commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

The secrets check no longer stops a push on three kinds of ordinary code that only look like secrets: TypeScript types with spaced generic arguments, Python arguments that read a settings constant, and camelCase dotted field paths.
It also catches two kinds of real secrets it used to miss, one built with + from short pieces and one written in a comment, so pushes are both quieter and safer.
Nothing to do; a secret in any of the loosened positions still fails the check.

What changed

People hit the secrets check on code that holds no secret: session: Awaited<ReturnType<typeof launch>>;, aws_secret_access_key=settings.S3_SECRET_KEY, and KEY = "form.section.fieldName" each stopped a push. Those three shapes now pass. Each exemption reads the value's shape, never the key's name, and each has tests that put a real-looking secret in the same position and expect it to report.

Two misses are closed too. KEY = "form.x" + "<secret>" is reported because the string pieces of a + chain are joined and checked, and x = 1 # API_KEY = "<secret>" is reported after #, //, /* or an HTML comment opener, while prose in comments is not.

The dotted field path exemption applies only in source files, and only when the rest of the line holds no secret literal. So password = "form.section.fieldName" or "<secret>" and the same path in a .env or YAML file still report.

Known limits, still reported and documented in docs/pregate.md (allowlist them by value): JS/TS template keys, arrays of names, and generic types with string-literal arguments.

How it was checked
  • New tests: test/redact-env-kv-code-shapes.test.ts (the three loosenings, each paired with holds, plus the known limits and every audit bypass line, which must report) and test/redact-env-kv-misses.test.ts (the two misses and a linear-time check on 40 KB lines). At main 0ee5914 every pass and miss test fails and every hold, known-limit and benign test passes. One pregate end-to-end case in test/pregate-secrets-source-context.test.ts.
  • Every tracked text file in gstack (5,080) and gbrain (15,363) was scanned with main's scanner and with this branch's: no finding is added in gstack and one in gbrain (a commented-out template line in a test file); 1 and 3 false positives go away. Scan time is within 5%.
  • Focused suites before the narrowing: 24 redact and pregate secrets test files, 781 pass; one existing pregate case (GST-2047) timed out at its 5 s limit under load and passes alone in 3.6 s.
Agent notes

Second-model audit (GPT-6.1 Sol), two rounds. Round 1 at 1d93c56, 3,621 probes: HOLD, four bypasses (a spaced password with symbols in a template, array element or literal type; a regex literal in a template slot) and a quadratic slowdown on long space runs from the comment lookbehind; fixed once in 6a464d6 and fbb4156. Round 2 at fbb4156, 6,639 probes: HOLD, random 20-character hex under 3.0 bits/char passing the template-key and name-array exemptions (19 of 1,500 samples) and a String.fromCharCode slot. Per the Captain's ruling the PR was narrowed in f84cfad, not fixed again: the template-key, name-array and literal-type exemptions are removed and their false positives documented as known limits. Long-line timing after the fix: main 5.8 ms, branch 6.0 ms worst case.
Outside PR #4309 (@atharva081106) was read as text only; its template exemption is not carried. Thanks to @atharva081106 and to @LimpingWolf for #4289's regression table.

Why

The secrets check runs before every push, so a false alarm on ordinary code blocks real work and teaches people to allowlist by reflex. Fewer false alarms and two closed misses make the check something people can trust.

Blast radius

Only the env.kv rule in lib/redact-patterns.ts changed, and every redaction caller (pregate, gstack-post, the pre-push hook) reads it through scan(). A side-by-side scan of every tracked file found no new env.kv finding in gstack and one in gbrain, while one false positive in gstack goes away (script ran on 5,088 files).

Test Coverage

Coverage: 80% of the changed paths (12 of 15), from an audit-only pass that wrote no tests. Tests: 1801 → 1801 files; the fix commit adds one test case with six hold rows. Proposed follow-up rows for the three gaps: generic-type text inside a string literal, a spaced password split across + pieces, and a comment secret on a raw diff-prefixed line.
Tests ran: test 1683 (files, carried from CI run 44149072762)

Pre-Landing Review

The full review found one real problem, and it is fixed in this PR. The new dotted field path exemption hid a secret written later on the same line (password = "form.section.fieldName" or "<secret>"), and it hid the same text in config files. The main scanner reported both. The fix limits the exemption to source files and requires the rest of the line to hold no secret literal. The adversarial reader and the second-model review each found this on their own. The repeat pass on the fix found nothing blocking.

Second-model review (GPT-6.1 Sol): completed, two findings, both fixed.

Review notes

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

  • INFORMATIONAL lib/redact-engine.ts:418 The engine's placeholder and allowlist shortcut runs on the first piece before validate, so a chain whose first piece looks like a placeholder ("your_key" + secret) gives no finding, against the docs' 'joined and checked' wording. Not a regression.
  • INFORMATIONAL lib/redact-patterns.ts:1692 A + chain finding covers only the short first piece, so span redaction leaves the joined secret in place. Not a regression: main did not match these lines at all.
  • INFORMATIONAL lib/redact-patterns.ts:1692 A whole-line comment on a raw diff line (+# TOKEN=…) is still missed. Not a regression.
  • INFORMATIONAL lib/redact-patterns.ts A comment or heading whose value has a digit (## Session: 2026-Q3-planning-notes) now reports; none occur in the repository.
  • INFORMATIONAL lib/redact-patterns.ts A single long line with many comment markers scans in 783 ms against 82 ms on main at 544 KB; seconds, not a hang, under the 1 MiB cap.
  • INFORMATIONAL lib/redact-patterns.ts:1229 Plain .js, .mjs and .cjs files don't get the dotted field path exemption, so such a path there still reports. This adds false positives only.
Exploratory QA

Functional, the gstack-redact CLI on synthetic files at bb221cc: pass, 3 probes. A spaced generic TypeScript type gives no finding; API_KEY = "ab" + "<synthetic>" reports; password = "form.section.fieldName" or "<synthetic>" reports. Smoke only: comment and keyword-argument shapes are left to the unit tests.

Design Review

No frontend files changed, so design review was skipped.

Eval Results

No prompt-related files changed, so evals were skipped.

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

TODOS

No TODO items completed in this PR.

Documentation

Status: current — documentation already matches the change; no edits.

Scope: base 0ee5914..bb221cc on secrets-check-code-shapes, 6 committed files (lib/redact-patterns.ts, docs/pregate.md, changelog.d fragment, 3 tests); no staged, unstaged or new files.

Documentation health:

Coverage debt: the new env.kv exemptions have reference coverage only (docs/pregate.md); no how-to for allowlisting the known-limit shapes beyond the general allowlist section (common gap). Diagram drift: none.

Issues

Refs #4289 (the regression table), #4287 (template keys, still a known limit).

Tests
  • CI free tests (run 44149072762 at bb221cc): 1683 files, green
  • bun test on the six redact env.kv, engine, context and diff-prefix files: 421 pass, 0 fail
  • bun test test/pregate-secrets-source-context.test.ts: 33 pass, 0 fail
  • bun run typecheck and test/module-size-ratchet.test.ts: pass
Agent notes

Refs GST-3004

Approvals

No approvals recorded for branch secrets-check-code-shapes.
Plan: exempt: bug fix (R65; GST-3004 false positives and #4289 misses, failing tests written first)

REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=2 fixed=3 scope=frozen ledgers_read=2 dispatches=4
Gate edits: none detected (3 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Review panel at f84cfad (pass 1): batched specialist (testing, security, state-machines) no findings; red team two informational notes; adversarial reader one blocker plus six notes; GPT-6.1 Sol two blockers. Fix bb221cc carries Review-Finding trailers p1/adversarial-native#1, p1/outside-voice#1, p1/outside-voice#2. Pass 2 on f84cfad..bb221cc: specialist no findings, red team one note. The red-team note on chain-span redaction was skipped as below the blocking floor (not a regression).

Earlier second-model security audit (GPT-6.1 Sol), two rounds before this /ship. Round 1 at 1d93c56, 3,621 probes: four bypasses and a quadratic slowdown, fixed in 6a464d6 and fbb4156. Round 2 at fbb4156, 6,639 probes: random hex passing the template-key and name-array exemptions; per the Captain's ruling the PR was narrowed in f84cfad and those exemptions plus the literal-type one were removed and documented as known limits. Outside PR #4309 (@atharva081106) was read as text only; its template exemption is not carried. Thanks to @atharva081106 and to @LimpingWolf for #4289's regression table.

Fetch-rule note: Playwright's browser cache was downloaded twice during review stage one and two by stray local free-suite workers from this run's own stopped test lane (not by a reader). The lane Captain approved deleting ~/.cache/ms-playwright; both stages reran clean.

{
  "schema_version": 1,
  "pr": 4457,
  "head": "bb221ccc0b6165691327174f13bacf99f56a96de",
  "version": "1.100.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1683,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44149072762,
      "attempt": 1,
      "tree": "462d97a8e50b53337e06e3c9acf1cf93f8cdb525"
    }
  ],
  "calls": 36,
  "session_kind": "unattended",
  "run": "ship-4457",
  "head_tree": "462d97a8e50b53337e06e3c9acf1cf93f8cdb525",
  "product_patch_id": "10906fc0d459fa17fd1a335d6039584bb3dc5557",
  "gstack_version": "1.100.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 189,
    "rules": "66e5174161eecc2c",
    "base": "88da124dbc68ad886f4aef467d4b09375041ad86",
    "registry": "88da124dbc68ad886f4aef467d4b09375041ad86",
    "gate_scan": {
      "tagged": 0,
      "head": "bb221ccc0b6165691327174f13bacf99f56a96de"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=189"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @462d97a8e50b (8 checks, current for bb221ccc0b61)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44149072762/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44149072762/attempts/1",
    "free-tests.yml/cso-windows-launcher: https://github.com/garrytan/gstack/actions/runs/44149072762/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44147521172/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=462d97a8e50b tests=37525 skipped=91 runs=44149072762/1 profiles=ci-reuse/free-tests heads=bb221ccc0b61 verified=2026-11-17T18:40:34.526Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md (147 docs files); branch docs change is docs/pregate.md plus the changelog.d fragment"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 2,
    "fixed": 3,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 3,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "gate_dispositions": []
}

garrytan and others added 2 commits November 17, 2026 17:18
…atenated and commented secrets (GST-3004)

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

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

trunk-io Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 17, 2026 17:29
…iterals out of template slots, and keep the comment start linear

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

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…he second audit found hex secrets passing them

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot changed the title Secrets check stops flagging code as secrets and catches concatenated and commented secrets (GST-3004) Secrets check stops flagging three code shapes and catches concatenated and commented secrets (GST-3004) Nov 17, 2026
@capy-ai
capy-ai Bot marked this pull request as ready for review November 17, 2026 17:38
…fig files

The dotted field path exemption read only the quoted path, so a secret literal after it on the line (or, ||, a tuple comma) and the same text in a .env or YAML file stopped reporting. It now applies only in source files and only when the rest of the line holds no secret literal or template.

Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit e1cfcea into main Nov 17, 2026
78 of 79 checks passed
This was referenced Nov 18, 2026
capy-ai Bot added a commit that referenced this pull request Nov 18, 2026
- A test, or a scratch repository in the temp directory, can no longer write approval rows into your real Capy Drive (GST-3027). (#4466)
- An unattended /autoplan run on Claude Code no longer says the publication guard is off while it is on. (#4481)
- A phase report written only in reasoning now gets a denial that says so and names the fix. (#4481)
- `gstack-autoplan revise` no longer refuses a plan that the first `next` accepted. (#4470)
- `revise --plan` with a different file now says the run follows that file. (#4470)
- A second-model plan review in `/autoplan` is no longer reported as unavailable when it actually ran (GST-3051). (#4471)
- The /ship conductor trial plan now lets case reverts that conflict with later code be resolved by hand in docs, tests and the planted file, so large pull requests can be cases (GST-3003). (#4460)
- A locked plan for a trial of /ship without its separate conductor subagent (GST-3003). (#4456)
- A driven /ship now runs each phase as one command, counts its calls, and stops itself at 100 minutes. (#4451)
- /ship stops asking owners to clear two kinds of bookkeeping noise: base-side merge text and a reviewer's confirmation prose. (#4458)
- A base merge that only touched base-side text no longer stops `/ship` finish for an owner's grant. (#4458)
- A reviewer's confirmation prose no longer becomes a Critical finding that only an owner can clear. (#4458)
- A CI run that passed only after its failed jobs were re-run is now marked wherever gstack reuses it. (#4473)
- /ship reuses CI's passing test run when merging the base changed no file, and stops instead of quietly starting hour-long test runs or reviewing an empty diff (GST-3019). (#4461)
- /ship on Codex no longer stops at the test coverage audit. (#4489)
- A cold first-use check before an app build reaches its owner (GST-3025). (#4465)
- `skill_prefix=true` now survives updates when gbrain is installed. (#4454)
- The OpenClaw docs no longer send you to ClawHub, which held only April 2026 builds of office-hours, ceo-review and retro and no longer has gstack skills (the docs also said four skills while listing three). (#4454)
- `gstack-issue-links` no longer reads other repositories' issues as gstack's. (#4454)
- /ship's pre-gate finds the tests of a monorepo app that imports through its own `@/` alias. (#4464)
- /office-hours explains why it recommends a mode. (#4450)
- /office-hours keeps its 34 founder videos and essays out of the skill file. (#4463)
- Two `gstack-owner-answers add` runs for the same answer no longer collide. (#4490)
- A Captain can check an ask against the owner's earlier answers before sending it. (#4467)
- `gstack-post` stops reading /ship's own receipt identifiers as phone numbers, so posting a /ship PR body no longer needs a confirm. (#4488)
- GitHub release notes now list every change in plain words, with a link to its pull request. (#4390)
- gstack's router no longer gives bug reports a special rule, so the model fixes a bug the way it would without gstack. (#4442)
- /ship's review plan now sorts Swift and Xcode files by risk instead of sending every iOS PR to the full review panel (GST-3041). (#4469)
- /ship's review plan now sends Swift code that touches private user data to the full review panel (GST-3052). (#4472)
- A round grant at /ship's review round cap now buys the fix round it names, in the same run or the next (GST-2968). (#4479)
- The secrets check stops flagging three kinds of ordinary code as a secret, and catches two misses. (#4457)
- A security finding's location and reason no longer go into a PR body. (#4486)
- The token-capped /ship child on Claude Code now starts its prompt with the typed `/ship` command, so the skill actually loads. (#4487)
- A /ship receipt now counts the second-model review's blocking findings, and refuses to be written while one is still open. (#4485)
- A `/ship` with a token cap on Claude Code no longer stops at its first handoff. (#4452)
- /ship's push step now always ends with one line that says whether it pushed (GST-3053). (#4474)
- A PR's review-round count can no longer be overwritten by the body `/ship` posts. (#4440)
- One queued record with a malformed path no longer stops artifacts sync for every project. (#4455)
- A failed artifacts push stays reported until a push succeeds. (#4455)
- The /sync-gbrain memory row no longer says OK when pages failed to import. (#4455)
- ### Tests (#4495)
- A policy-floor test no longer fails once gstack's own version reaches the minor after the newest policy key; it now checks a floor above both, so the v1.101.0.0 release can pass CI. (#4495)
- CI now uploads free-suite test results to Trunk with analytics-uploader v2.1.8 and analytics-cli 0.17.0, up from v2.1.6 and 0.16.2. (#4453)
- Packing a checkout for a Ubicloud run no longer fails when git beside it is rewriting a ref. (#4447)
- The /plan-ceo-review HOLD SCOPE eval no longer fails a review because its follow-up question didn't repeat the mode name. (#4447)
- Unattended /autoplan now records the owner's relayed gate reply instead of refusing it. (#4484)
- Unattended /autoplan now runs the second-model review you turned on, and waits for it instead of ending the session. (#4459)
- Two /autoplan runs started in the same second no longer share a run id. (#4459)

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