You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 62c01ba
Browse filesBrowse the repository at this point in the historyBrowse files
Algis Dumbris
committed
fix(security): mask secrets on MCP server payloads and stop nil/anonymous auth revealing them (smart-mcp-proxy#1148)
`quarantine_security list_quarantined` json.Marshal'd the raw
[]*config.ServerConfig from storage, so every credential the struct
carries left through the MCP surface in the clear — and /mcp is
unprotected by default, so any caller could read them. The leak was
wider than reported: env values, header values, oauth.client_secret,
URL query credentials AND argv tokens. The response was then recorded
verbatim into the activity store (BBolt, SSE, `activity list`).
Redacted view (a):
New internal/server/mcp_server_view.go builds MCP-facing server
payloads by walking the config's OWN JSON through the shared
redaction walker from smart-mcp-proxy#1149, not from a hand-written key list — so
the next field added to ServerConfig is masked by default rather
than leaked by default. The walker is now policy-driven: live
surfaces render with oauth.MaskValue, persisted ones with
oauth.AuditMaskValue.
Env, header and URL leaves deliberately reproduce internal/oauth's
own rendering byte for byte on live surfaces, because
UnmaskEnvValues/UnmaskHeaders/UnmaskURL recognise an echoed mask by
that exact string; rendering them any other way would make a
read-modify-write client persist the mask over the real secret.
Every other leaf — argv tokens and any future field — is
detector-masked unconditionally. argv had no unmask contract, so
one is added (unmaskArgv) alongside masking it.
Auth gate (b):
The gate read `authCtx != nil && !authCtx.IsAdmin()`, so absence of
a token passed where a scoped agent token failed. The real path is
narrower than "nil is admin": mcpAuthMiddleware deliberately
installs an admin context for unauthenticated /mcp back-compat.
That upgrade stays — it is why unauthenticated MCP clients work —
but the context is now marked Anonymous, and the new nil-safe
CanRevealSecrets() distinguishes it from an authenticated admin.
Its single consumer is `reveal_secret_headers`. stdio now installs
an explicit admin context instead of relying on nil.
Behaviour change, exhaustively: list_quarantined is masked for
everyone; reveal_secret_headers:true returns raw values only to an
API-key/agent admin, a tray socket connection, or stdio; tail_log
lines and connection_message strings are scrubbed; activity rows
for both management built-ins record the audit-masked response.
NOT changed: ordinary tool calls, retrieve_tools, add/update/patch/
enable/disable/restart and every quarantine approval still work for
an unauthenticated /mcp session. The REST API is untouched.
Sibling paths (c):
- upstream_servers list: reveal gate above; argv now masked; the
projection is sourced from the view so it cannot drift.
- tail_log: lines and connection_status.last_error scrubbed. Fixed
at the source too — Connect() logged the raw upstream URL into
server-<name>.log on every attempt (logSafeURL).
- connection errors: the three unscrubbed sites in
monitorConnectionStatus / handleUpdateUpstream now use the same
scrubUpstreamText as the list path's last_error.
- add_from_registry summary: url and args from the view.
- inspect_quarantined: verified safe — it emits tool analysis only,
never the server config. Unchanged.
0 commit comments