buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(acp): redact secret-shaped env values from wire logs and observer feeds

Open jatinder14 opened this issue 4 months ago • 5 comments

Summary

  • Redact secret-shaped keys (*_API_KEY, *_TOKEN, *_SECRET, camelCase apiKey, ACP {name,value} env pairs, …) before acp::wire debug logs and observer acp_read/acp_write emit.
  • 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

jatinder14 avatar Jul 25 '26 17:07 jatinder14

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:

  1. 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.
  2. 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. 🐝

maikunari avatar Jul 26 '26 03:07 maikunari

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.

jatinder14 avatar Jul 26 '26 10:07 jatinder14

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.

jatinder14 avatar Jul 27 '26 15:07 jatinder14

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::wire debug lines + observer payloads are scrubbed — correct boundary.
  • Dual shape coverage: secret-shaped keys (apiKey, *_TOKEN, …) and full MCP env under mcpServers (handles Grok-style {name,value} pairs and map envs / DATABASE_URL). Matches the failure mode where agents rebroadcast MCP config.
  • Parse-error observe lines also redact the raw line — nice; avoids side channel.
  • Unit tests pin the interesting cases (incl. keyboard false positive avoidance).

Non-blockers

  • Branch may want a rebase onto latest main before merge (hygiene).
  • Optional later: shared helper with desktop’s split_config_key if they ever drift (comment already notes the mirror).

Recommend merge. Thanks @jatinder14 — this is the right layer for the defensive half of #2819.

Bartok9 avatar Jul 30 '26 17:07 Bartok9

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.

jatinder14 avatar Aug 07 '26 04:08 jatinder14

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.

Bartok9 avatar Aug 14 '26 20:08 Bartok9

@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.

Bartok9 avatar Aug 21 '26 04:08 Bartok9