fix(acp): redact secret-shaped env values from wire logs and observer feeds
Summary
- Redact secret-shaped keys (
*_API_KEY,*_TOKEN,*_SECRET, camelCaseapiKey, ACP{name,value}env pairs, …) beforeacp::wiredebug logs and observeracp_read/acp_writeemit. - Agent stdin/stdout is unchanged; only logging/observer copies are scrubbed.
- Adds unit tests covering map env, ACP env arrays, and wire-line redaction.
Fixes #2819
Test plan
- [x]
cargo test -p buzz-acp --lib redact:: - [ ] Spot-check: with
RUST_LOG=acp::wire=debug, trigger an agent notification containing MCP env and confirm keys land as[REDACTED]in logs/Raw Event rail
Reporter here — thanks for the fast pickup. Reviewed against the actual payload I observed: the array-form env: [{name, value}] handling matches what grok emits in _x.ai/mcp/servers_updated, and the sink coverage (observer + both wire directions + parse-error paths) looks complete for this crate. Two points:
- Suggest redacting all values inside
mcpServers[].env, unconditionally — the secret-shaped heuristic misses credentials in non-secret-named variables (DATABASE_URL=postgres://user:password@host,AUTH_HEADER, etc.). Env values are agent config, never display data, so there's no cost to blanket redaction within that path; keep the heuristic for generic JSON elsewhere. - The original report also mentioned desktop-side logging — if the managed-agent runtime logs raw notifications anywhere in
desktop/src-tauri, that path isn't covered by this PR (fine as a follow-up, just noting scope).
With point 1 addressed I'd consider this a complete fix for the buzz-acp half. 🐝
Thanks for checking this against the real _x.ai/mcp/servers_updated payload, @maikunari. Glad the array-form env: [{name, value}] path matches what you saw. Appreciate the review.
Thanks @maikunari. Updated in ad50de0.
mcpServers[].env values are now always redacted for both object maps and {name, value} arrays, including names like DATABASE_URL. Elsewhere we still only redact secret-shaped keys. Added a test for the blanket MCP env case, and confirmed generic env values outside that path are unchanged.
Agreed on desktop-side logging. That managed-agent path sits outside buzz-acp, so I will leave it as a follow-up.
Independent review (Bartok9) — 2026-07-30
Verdict
Solid defensive fix for #2819. Prefer landing this over a parallel stack.
What I checked
- Wire path still talks to the agent unmutated; only
acp::wiredebug lines + observer payloads are scrubbed — correct boundary. - Dual shape coverage: secret-shaped keys (
apiKey,*_TOKEN, …) and full MCPenvundermcpServers(handles Grok-style{name,value}pairs and map envs /DATABASE_URL). Matches the failure mode where agents rebroadcast MCP config. - Parse-error
observelines also redact the raw line — nice; avoids side channel. - Unit tests pin the interesting cases (incl.
keyboardfalse positive avoidance).
Non-blockers
- Branch may want a rebase onto latest
mainbefore merge (hygiene). - Optional later: shared helper with desktop’s
split_config_keyif they ever drift (comment already notes the mirror).
Recommend merge. Thanks @jatinder14 — this is the right layer for the defensive half of #2819.
Thanks @Bartok9 for the thorough independent review. Glad the wire/observer boundary and the blanket mcpServers env redaction look right.
I'll rebase onto latest main for hygiene. Agreed that sharing a helper with desktop's split_config_key can be a follow-up if those paths start to drift.
Thanks @jatinder14 — rebase for hygiene is plenty. Shared split_config_key can stay a later follow-up if the two paths drift. Still +1 to land this as the buzz-acp half of #2819.
@wpfleger96 you've done most of the work in buzz-acp, so flagging this rather than leaving it to go stale — and apologies for pointing at three PRs in one comment; I'd rather do that than send three pings.
This one redacts secret-shaped env values from acp::wire debug lines and observer payloads, including full mcpServers[].env (both map and {name, value} shapes) after @maikunari confirmed against a real _x.ai/mcp/servers_updated payload. @Bartok9 reviewed independently and was +1 to land it as the buzz-acp half of #2819. The agent-facing wire is untouched — only logs and observer feeds are scrubbed.
Two related ones if you're in this area anyway: #2870 (wake agents on forum post/comment @mentions) and #3170 (refuse an unsafe agent workdir fallback to /). All three are small and CI is green.
No urgency — happy to rebase, split, or close any of them.
Thanks for the ping, @jatinder-mahajan-certifyos — the +1 still stands on my side.
This remains the buzz-acp half of #2819: redact secret-shaped env from acp::wire debug lines and observer payloads (map and {name, value} mcpServers[].env), after the real _x.ai/mcp/servers_updated check. Agent-facing wire is untouched.
Happy to leave the merge call with @wpfleger96. No branch changes from me.