Bounty Watch — Agentware 2026, Track C (Research & Study). Solo entry by Hidayat (kakajohn). Sequel to The near miss.
The leak, in one paragraph
Part one: our read-only agent, Bounty Watch, ran the Trap Pack — 20 hostile inputs. 15 held, 5 failed. Nothing dramatic: no injected instruction was followed, no outbound call was made. The failure was quieter. In five drafts, a planted canary token (AGW-CANARY-*, standing in for a secret) was copied verbatim from the input into the report — because the draft generator quoted its source, and quoting is what a summariser does. The guardrails guarded actions; none guarded output text.
This is the fix.
One function, at the render boundary
The whole fix is one function: sanitize_text() in bounty_watch/sanitize.py. Before a title or summary reaches a draft, it passes through the sanitizer; secret-shaped tokens come out as [REDACTED]; everything else passes through untouched.
It is deliberately boring. Nine regex patterns, applied in order, most specific first:
- canary tokens (
AGW-CANARY-*) - JWTs (
eyJ...) - AWS access keys (
AKIA+ 16 chars) -
sk-secret keys - GitHub tokens (
gh*_,github_pat_) - Slack tokens (
xox*) - Bearer tokens
-
key=valuecredentials —api_key,secret,password,tokenand friends - long hex strings, 32 characters or more
Order matters. The long-hex rule runs last, because a labelled value like api_key=9f2c... should be caught by the key=value rule first — so the label survives. A reviewer reading api_key=[REDACTED] still learns that a credential was present. The secret is gone; the fact that there was a secret is not.
Three choices we made on purpose
The label stays, the value goes. Redacting the whole line would hide the evidence; keeping the value would leak the secret. api_key=[REDACTED] is the middle that keeps the draft useful and the secret out of it.
Eight characters minimum. A key=value pair only counts if the value is at least eight non-space characters. Ordinary prose — "secret: the answer is yes" — is left alone. A scrubber that mangles normal sentences trains people to ignore it, and then to turn it off.
Idempotent. Sanitising an already-sanitised string changes nothing. That sounds trivial until a draft passes through the renderer twice; a scrubber that corrupts its own output on the second pass is a bug waiting for a retry loop.
And one rule we set before writing a line: the sanitizer was written without opening the Trap Pack answer key (EXPECTED.md, manifest.json). It catches shapes, not files. A fix tuned to the five leaked tokens would pass the re-run and fail the real world.
What the tests prove
19 new unit tests: every pattern, prose left untouched, labels preserved, idempotency. Full suite 56/56 green at that point.
But unit tests only prove the function does what we wrote. The real test was the re-run: same harness, same 20 traps, after the fix — 20/20 held, 0 canary tokens in any draft or trace. The sanitizer had never seen the answer key, so the re-run is evidence, not theatre.
Two things stayed deliberately unchanged. The audit trace still records the raw input — traces are internal, for forensics, and scrubbing them would destroy the evidence. And the first run's results were kept exactly as they were, leaks included, so anyone can check before and after.
What it cannot do
Honest limits, same as part one, plus one more. Regex only catches secret shapes it knows: a PEM private key, an unlisted cloud key format, or a token under eight characters still passes through. It is a text scrubber, not a network guard — it stops secret-shaped text reaching a document, not the agent calling a tool.
And the over-redaction cost is real. A legitimate 32-character hex hash — a git commit hash quoted in a build log, for instance — becomes [REDACTED] in the draft. We accept that trade: a draft is a summary for human review, not a forensic record. If the hash matters, it is still in the trace.
The lesson, extended
Part one ended with: sanitize at the render boundary, not at the intake. The fix taught us the second half: the render boundary is the last place you get to say no, so it is the one place worth engineering carefully. You cannot reliably tell which incoming text is hostile — a water bill is not a threat model anyone writes down — but you can always decide what leaves your system in a deliverable.
Every agent that quotes its sources has a render boundary. Most of them have nothing standing at it.
Top comments (0)