Skip to content

fix(mcp): redact secrets from /mcp show in group chats#103396

Merged
obviyus merged 2 commits into
mainfrom
fix/mcp-show-redact-credentials
Jul 10, 2026
Merged

fix(mcp): redact secrets from /mcp show in group chats#103396
obviyus merged 2 commits into
mainfrom
fix/mcp-show-redact-credentials

Conversation

@obviyus

@obviyus obviyus commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Closes #103053

What Problem This Solves

Fixes an issue where an owner running /mcp show (or /mcp show <name>) from a group or channel would post the full MCP server config—including credential-bearing headers and env values—into that shared chat for every member to read.

Why This Change Was Made

/mcp show was owner-gated but still rendered raw server JSON with no secret redaction. This change reuses the existing config redaction contract (redactConfigObject + schema uiHints) so show output never contains live secrets, and marks MCP env values sensitive the same way headers already were.

Write-side safety is included: /mcp set restores redaction sentinels from the existing server entry (and rejects unrestorable sentinels), so a show → edit → set round-trip cannot overwrite real credentials with the display placeholder.

User Impact

  • Owners can run /mcp show in groups without leaking MCP Authorization headers, env tokens, or other sensitive server fields.
  • Non-secret fields (command, args, server names, etc.) still appear for inspection.
  • Operators who copy redacted show output into /mcp set keep existing secrets instead of silently writing __OPENCLAW_REDACTED__.

Evidence

Focused tests:

pnpm test src/auto-reply/reply/commands-mcp.test.ts src/config/schema.test.ts src/config/mcp-config.test.ts
→ 69 tests passed

Coverage added:

  • Group /mcp show named + list forms with secret headers/env must emit the redaction sentinel and never the secret values.
  • setConfiguredMcpServer restores secrets when the payload contains the redaction sentinel.
  • Unrestorable sentinels for a new server fail closed.
  • Schema assert: mcp.servers.*.env.* is sensitive.

fable-5 closeout review: accepted show→set restore gap and fixed it; remaining P3 note about short env values affecting raw snapshot text view is intentional/shared with other all-sensitive env maps and is fail-safe (no leak).

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 10, 2026
@obviyus obviyus self-assigned this Jul 10, 2026
@obviyus

obviyus commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Live ephemeral-gateway E2E proof

Added and ran test/mcp-show-redact.e2e.test.ts against a real gateway process (not unit-mocked handlers).

What it does

  1. Starts an ephemeral OpenClaw gateway with commands.mcp: true and MCP servers containing live headers.Authorization + env secrets on disk.
  2. Connects as an operator (operator.admin) over the gateway WS.
  3. chat.send /mcp show billing-server and bare /mcp show.
  4. Asserts the chat final reply contains non-secret fields + __OPENCLAW_REDACTED__, and never contains the live secrets.
  5. chat.send /mcp set … with redacted sentinel values; proves on-disk config still has the real secrets (restore path).
  6. Same restore again via openclaw mcp set CLI in the same process env.

Result

pnpm test test/mcp-show-redact.e2e.test.ts
✓ starts an ephemeral gateway and redacts MCP secrets from /mcp show chat replies  (17s)

obviyus added 2 commits July 10, 2026 11:26
Prevent owner /mcp show from dumping raw headers/env credentials into
group chats. Mark MCP env values sensitive, restore redaction sentinels
on set so show→set cannot overwrite real secrets.

Fixes #103053
Spin up an ephemeral gateway process, chat.send /mcp show with live
credential-bearing config, and prove secrets never leave the reply path.
Also prove show→set sentinel restore on disk via chat and CLI.
@obviyus
obviyus force-pushed the fix/mcp-show-redact-credentials branch from cea9ee0 to 718c5d8 Compare July 10, 2026 05:58
@obviyus
obviyus merged commit 08b6996 into main Jul 10, 2026
7 checks passed
@obviyus
obviyus deleted the fix/mcp-show-redact-credentials branch July 10, 2026 05:58
@obviyus

obviyus commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Landed via squash onto main (landpr, no scripts/pr wrapper).

  • Scoped tests (post-rebase): pnpm test src/auto-reply/reply/commands-mcp.test.ts src/config/schema.test.ts src/config/mcp-config.test.ts test/mcp-show-redact.e2e.test.ts → 70 passed (unit + live ephemeral gateway e2e)
  • Changelog: not updated (release-only; release-note context is in the squash message / PR body)
  • Land commit (rebased head): 718c5d8
  • Merge commit: 08b6996

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
* fix(mcp): redact secrets in /mcp show replies

Prevent owner /mcp show from dumping raw headers/env credentials into
group chats. Mark MCP env values sensitive, restore redaction sentinels
on set so show→set cannot overwrite real secrets.

Fixes openclaw#103053

* test(mcp): e2e redaction of /mcp show secrets on live gateway

Spin up an ephemeral gateway process, chat.send /mcp show with live
credential-bearing config, and prove secrets never leave the reply path.
Also prove show→set sentinel restore on disk via chat and CLI.
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
* fix(mcp): redact secrets in /mcp show replies

Prevent owner /mcp show from dumping raw headers/env credentials into
group chats. Mark MCP env values sensitive, restore redaction sentinels
on set so show→set cannot overwrite real secrets.

Fixes openclaw#103053

* test(mcp): e2e redaction of /mcp show secrets on live gateway

Spin up an ephemeral gateway process, chat.send /mcp show with live
credential-bearing config, and prove secrets never leave the reply path.
Also prove show→set sentinel restore on disk via chat and CLI.

(cherry picked from commit 08b6996)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/mcp show leaks raw MCP server credentials (env/headers) into group chats

1 participant