Repository navigation
Catch secrets split across lines in UTF-16 files and stop deleted binaries from blocking pushes (GST-2261) - #4261
Merged
Conversation
…es in the push scan (GST-2261) Each reading of a file git calls binary is now scanned as its own text with the file's line numbers, so a keyword and its value on the next line stay neighbours. The pre-push hook diffs with --irreversible-delete, so a deleted binary's old bytes no longer fill its 64 MiB buffer. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Review-Finding: changelog.d/scan-binary-files-for-secrets.md:1:release reader=core Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…-2261) Review-Finding: p1/specialist-batched#1 reader=specialist-batched Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
3 tasks done
…listed token never hides another (GST-2261) Review-Finding: p2/specialist-batched#1 reader=security Review-Finding: p2/red-team#2 reader=red-team 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>
…d in different readings still fail (GST-2261) Review-Finding: audit/cross-family#1 reader=gpt-6.1-sol Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.
This closes two gaps #4243 left in the secret check and the pre-push hook. Both are security fixes that serve the project's goal of never pushing a credential.
What changed
Secrets split across two lines of UTF-16 text are now caught. #4243 reads a file git calls binary three ways (as bytes, and as little- and big-endian UTF-16) but put all three readings side by side on each line. So the line holding
aws_secret_access_key:ended with the letter-spaced byte reading, and the rule that looks for the key on the next line lost its keyword. An AWS secret key under its YAML key in a UTF-16LE or UTF-16BE file passed both guards (the repro table in #4243's "Open advisory notes", item 1).scannableTextbecomesscannableReadings, which returns each distinct reading as a whole text with the file's line breaks. Pregate'ssecretscheck runs gstack-redact once per reading, and the hook scans one part per reading, both keeping the file's line numbers. Plain-text files still have one reading and are scanned once, as before. A token that several readings of one file find is reported once.Deleting a large binary no longer blocks a push. With
--text, a deleted binary's old bytes filled the hook's 64 MiB diff buffer, so removing an already-pushed 70 MiB file (or moving it to Git LFS) failed withgit diff failed (status=killed/overflow). The hook'sgit diffand per-commitgit shownow pass--irreversible-delete, so a deleted file prints only its header. A delete can't add a secret. Adding a binary over the limit still blocks. A replaced binary's old bytes still count: git has no flag that drops a modification's preimage (-Bmerges the broken pair back into a rewrite that prints the old lines), so that stays a documented limit. Pregate already skipped deletions and is unchanged there.No screenshots: this change has no visible surface, and the tests below show the behavior.
Why
An AWS secret key stored under its YAML key in a UTF-16 file got past both the pre-push hook and pregate, which is the leak these guards exist to stop. Separately, deleting a large binary that was already pushed made the hook fail, so people could not clean up their repository. Now the split key is blocked in every encoding and the delete pushes clean.
Blast radius
The change touches the secret check in lib/pregate/checks/secrets.ts and the pre-push hook bin/gstack-redact-prepush, which imports it; lib/pregate/index.ts is untouched. Plain-text files still get exactly one reading, so their scan is the same as before, and the new tests fail on main at 76e2d3f and pass here (script ran, plus the carried CI run 42731728299).
Summary
The secret check and the pre-push hook let a key slip through when a UTF-16 file split it across two lines, and they blocked the push that deletes a large binary. Each reading of a binary file is now scanned as its own text with its line breaks, so the key and its value stay together. Deleted files leave the hook's diff, so removing a big binary no longer fills the buffer. A token that several readings find is listed once, and an allowlisted token never hides a different one.
Test Coverage
All new code paths have test coverage. The tests were written first and failed on main at 76e2d3f:
test/pregate-secrets-source-context.test.ts: the split AWS pair fails in plain text, UTF-16LE and UTF-16BE.test/redact-prepush-hook.test.ts: the same pair blocks the push in all three encodings; adding a 70 MiB binary still blocks on the buffer limit, and deleting it pushes clean.Tests ran: test 1658 (files, carried from CI run 42731728299/1 at tree 54dc12485f73)
Pre-Landing Review
Full panel (security change): two passes, a fix-check on the round-2 fix and a targeted secret-class read. Every blocking finding was fixed on the branch; each fix commit names its finding in a
Review-Finding:trailer. The targeted secret read at 6bd89e1 found nothing. Outside review: CLEAN.REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=3 fixed=4 scope=frozen ledgers_read=5 fix_checks=1
Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
bin/gstack-redact-prepush:271collectAddedLines only parses '+++ b/' headers, so a file whose name git quotes (non-ASCII, tab, quote, backslash) is scanned without its path: reported as (unknown file) and without sourcePath file-type context. Pre-existing on main; the scan still runs.bin/gstack-redact-prepush:723An allowlisted plain token in a binary file is listed once per reading in the hook's suppressed list and pregate's allowlist lines, so 'suppressed N' overcounts; never unblocks a credential.lib/pregate/checks/secrets.ts:176Pregate starts one gstack-redact per reading (up to 3 per binary file), each with the full per-run timeout.bin/gstack-redact-prepush:310A modified (not deleted) large binary still overflows the hook's 64 MiB diff buffer with --text and blocks fail-closed; documented.test/redact-prepush-hook.test.ts:36runHook maps a killed process to exit 0 (r.status ?? 0); the signal-kill test fails the same way at base 76e2d3f on this machine, so the helper can hide a hung hook as a pass.Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. The docs already describe this branch's changes, so no edits were made.
Scope: six committed files from base 76e2d3f to head 0f731c4 (bin/gstack-redact-prepush, lib/pregate/checks/secrets.ts, docs/pregate.md, a changelog.d fragment, two tests). Nothing was staged, unstaged or untracked. I also checked the docs that mention the pre-push hook or the redaction guard: CLAUDE.md, docs/CONTRIBUTOR_REFERENCE.md, docs/troubleshooting.md and ship/SKILL.md.tmpl.
Documentation health:
Coverage debt: none that affects users. No doc says that a token several readings find is reported once, because that is an internal detail. Diagram drift: none.
Test plan
bun run test(lane test): green in CI run 42731728299/1 at tree 54dc12485f73, carried by /ship🤖 Generated with Claude Code
Agent notes
Refs GST-2261
Approvals
Approved: yes (record r-bc7075abdcc5). The full approval record stays private.
Plan: exempt: bug fix
Plan check: exempt bug fix
REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=3 fixed=4 scope=frozen ledgers_read=5 fix_checks=1
Review-loop exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-09 via approval a-d171d28be775 (GSTA-488 rule 11): one scoped fix-check at head 6bd89e1, covering the round-2 dedup fix (the 6ea1d57→6bd89e1 delta within 0ff06cc..6bd89e1) (fix-check at 6bd89e1, 2 findings)