Conversation
A live Resend API key was found in plaintext in ~/.ringer/runs/*.json. The mechanism is general: when a test suite's HTTP mock blocks an outbound call it prints the request's full headers, including Authorization: Bearer <token>. That is the check command's stdout, and Ringer stored it verbatim. redact_secrets() replaces credential VALUES with [REDACTED] while keeping key names and structure, so the text stays diagnostic for the retry prompt. It is idempotent, byte-identical on clean input, and FAILS CLOSED — if redaction raises, the input is dropped rather than returned, because returning it hands back the exact cleartext the function exists to remove. Wired at the three funnels where captured output escapes: the Verifier's check excerpt (feeding check_output_tail, check_excerpt, notes and the retry prompt), tail_lines, and tail_file_text. scripts/scrub-run-logs.py cleans what is already on disk — runs/*.json, the runs.jsonl model log, artifacts/**/*.html, and worker logs. Dry-run by default. JSON and JSON Lines go through their parsed structure, never raw text: run records embed specs whose inner quotes are backslash-escaped, and a text-level regex rewrites across the escaping. That corrupted two real run records in a dry-run rehearsal before it was caught. After rewriting the model log it zeroes the scoreboard's cached read cursor, which the rewrite invalidates — a stale cursor resumes mid-record and drops rows. Swept this machine: 214 files, 1752 replacements, no secrets left and no record lost. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.
The problem
A live Resend API key was found sitting in plaintext in
~/.ringer/runs/*.jsonon my machine.The mechanism is general, and not specific to any one language or service: when a test suite's HTTP mock blocks an outbound call, its failure message prints the blocked request's full headers, including
Authorization: Bearer <token>. That failure message is the check command's stdout — and Ringer stores check stdout verbatim in the run record and serves worker log tails to the dashboard. So any credential the worker's environment happens to hold can land on disk in cleartext.Distinct from the existing
redact_specflag, which hides the request packet you sent from the dashboard. This is about credentials appearing in output coming back.What this adds
redact_secrets(text)replaces credential values with[REDACTED]while keeping key names and surrounding structure, so the text stays diagnostic — it is injected into the retry prompt, so making it unreadable would cost more than it saves. Covers bearer tokens in any quoting style, known credential prefixes (sk-ant-,sk-,re_,ghp_/gho_/ghu_/ghs_,github_pat_,xox*,glpat-, AWSAKIA…, Stripesk_live_/rk_test_…), and genericapi_key=/token:/secret =>assignments.It is idempotent, byte-identical on clean input, and fails closed: if redaction itself raises, the input is dropped rather than returned. Returning it would hand back the exact cleartext the function exists to remove, silently, on the one path nobody watches.
Wired at the three funnels where captured output escapes into something persisted or served:
Verifier's check excerpt (which feedscheck_output_tail,check_excerpt, the notes and the retry prompt)tail_lines(feedslog_tail/log_tail_fullin the run record)tail_file_text(served to the dashboard by the log endpoint)Redacting at the funnels rather than at each consumer means new consumers are covered by default.
scripts/scrub-run-logs.pyCleans what is already on disk:
runs/*.json, theruns.jsonlmodel log,artifacts/**/*.html, and worker logs. Dry-run by default; only writes with--write;--state-dirfor pointing at a fixture.Two details worth flagging, both found the hard way:
runs.jsonlit resets the scoreboard's cached read cursor. The read model reads that log incrementally from a stored byte offset, and rewriting the file invalidates it — the observed symptom was the scoreboard reporting "894 rows, 1 skipped lines" against a file whose 895 records all parsed cleanly. The existinglog_size < offsetguard only catches the log getting shorter; redaction can leave it longer.Swept my own machine with it: 214 files, 1752 replacements, no secrets left and no record lost.
Tests
tests/test_redact_secrets.py, 25 tests. Pattern coverage, idempotency, the byte-identical no-op, and the ordinary-identifier case (require_authenticationmust not matchre_). Executed assertions throughtail_lines,tail_file_textand the real check-output path rather than greps over source, plus the fail-closed path, the JSON-escaping regression, the JSONL round-trip and the cursor reset.Full suite green on this branch: 280 passed.
🤖 Generated with Claude Code