Repository navigation
fix(security): mask shared servers on the server edition's per-user door - #1162
Merged
Merged
Conversation
…mous auth revealing them (#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 #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.
#1148 review found Round-2 review of #1148. All nine findings were reproduced against the real code before anything was changed; eight are fixed, one was a request to enumerate rather than a defect. 1 (MAJOR, introduced by #1148). unmaskArgv reverted a masked argv token by VALUE with no binding, so a caller could relocate a stored credential anywhere in the vector. The sharper half is not execution — anyone who can patch a server can already exfiltrate env secrets by pointing `command` at a shell — it is RE-DISCLOSURE: a value masked because of the FLAG in front of it (`--api-key <secret>`) has no credential shape of its own, so moving it into a bare positional slot made the very next `upstream_servers list` hand it back in the clear. Masked read → relocate write → clear read-back undid all of #1148 over an endpoint that is unauthenticated by default. The revert is now bound to the INDEX it was masked at plus the flag that bound it, which is the same shape as the safeguards the sibling contracts already carry (UnmaskEnvValues / UnmaskHeaders bind to the map key; UnmaskURL refuses a new scheme/host). A reordered or resized vector no longer round-trips its masks — the caller resends the real values, which is the safe direction. The old "ambiguous mask" refusal is gone: positional binding resolves a collision correctly instead of giving up on it. 2 (MAJOR). inspect_quarantined — the sibling of the list_quarantined path #1148 fixed, one screen away — still rendered the raw GetConnectionStatus() map (last_error included) and raw ListTools errors into its response. The claim that it "emits tool analysis only" was wrong. Two response builders extracted and scrubbed. 3 (MAJOR). scrubUpstreamText applied the 512-byte ACTIVITY-STORE cap to LIVE reads, silently truncating every tail_log line and connection error. tail_log is the primary debugging surface and a long line is what an operator opens it for. The cap moved to scrubUpstreamTextForAudit; the live scrubber no longer truncates. 4 (MAJOR). Neither tokenPattern, secretPattern nor the `<param>=` sweep has a `user:pass@` shape, so basic-auth passwords survived every free-form scrubber. Fixed at the source in oauth.RedactSensitiveData, so the REST last_error / health.detail / Diagnostic.Cause scrubbers inherit it too. 5 (MAJOR). redactArgvWith ran the value-shaped detector ALONE on unpaired tokens — it knows database connection strings, not `https://user:pass@host` or `?token=…`. So `--endpoint <url>` and a bare positional URL leaked on BOTH policies while `--endpoint=<url>` was masked: the same inline-vs-space asymmetry #1146 round 3 fixed once. Unpaired tokens now go through redactStringWith, the same function the inline branch delegates to, so the spellings agree by construction. 6 (MAJOR). #1148 started masking oauth.client_secret on the MCP read surface without giving the write path anything to recognise the mask by, so an unedited echo through oauth_json — which REPLACES the block — persisted `••••42 (17 chars)` as the client secret. unmaskLiveOAuth reverts it, bound to the field. The contract is now stated in the docs: the argv mask is an MCP rendering, reverted only by the MCP write path; REST returns and accepts `args` unredacted and stays self-consistent, and contracts.OAuthConfig carries no client_secret at all. 7 (MINOR). With the detector off for contracted leaves, the LIVE surface returned `ghp_…` in the clear whenever it sat under a benign env/header name, while the audit policy masked it — and live is the surface an unauthenticated caller reads. The detector now also runs on live, but only over a leaf the name rule left BYTE-IDENTICAL, which is exactly the gap and deliberately spares #872's component-wise connection-string rendering (`postgres://u:••••(N chars)@host/db` stays readable and editable). Because that rendering is no longer oauth's, unmaskLiveEnv / Headers / URL reproduce it and run first on the write path, so closing the disclosure does not open the read-modify-write corruption. 8 (MINOR). internal/transport/http.go logged the raw cfg.URL on 14 sites — at Error level on the streamable-HTTP path, so it fired regardless of log level — plus the OAuth client_secret at Debug. #1148's "fixed at the source" claim covered only internal/upstream/core. logSafeURL mirrors the helper that package already has; the client_secret field is now a boolean. 9 (MINOR). Not a defect: enumerated on stdioAuthContext instead. Three paths change for stdio and all three make it behave as the API-key admin it is — principalFromContext ("" → "admin"), sessionPreflightScope (nil → a scope over the full server universe, which an admin is wholly inside) and CanRevealSecrets, which is the point of the change. Three more change shape with an identical outcome (code_execution's AuthInfo, direct-dispatch gates, the preflight record's empty UserID). The rest gate on agent/user identity and are untouched. The two substantive ones are pinned by a test. No REST or MCP schema changed, so no swagger regeneration.
…d redact URL credentials in connection errors Round 3 of the #1148 review. 1. argv masks are never reverted again — they are REFUSED (MAJOR). unmaskArgv still relocated a stored credential into a caller-chosen command line whenever the mask was not flag-bound. argvFlagBoundMasks marks index i only when stored[i-1] is a sensitive flag, so a token masked by the value-shaped detector — or any mask at index 0 — was bound to nothing but its index. Reproduced against the real code: stored = ["mcp-foo", "run", "ghp_16Cabcdef…"] incoming = ["--silent", "--data", "ghp_…****"] -> the live token was substituted into the attacker's argv. Option (b) from the review, and (a) is not salvageable: an argv slot has no key, and the caller supplies the whole vector AND `command` in the same patch, so every candidate binding — index, preceding flag, even a byte-identical vector — is caller-controlled. A "same surrounding context" rule still lets the secret move from `mcp-foo --api-key X` to `curl --api-key X`, because the meaning of argv lives in `command`. unmaskArgv/argvFlagBoundMasks are gone. checkArgvMaskEcho refuses the write when args_json carries a mask (an exact echo of a stored token's live rendering, or any token bearing a mask marker) and tells the caller to resend the real value. That is safe in both directions: the secret never moves, and the mask is never persisted over the credential either — the read-modify-write corruption the revert existed to prevent. Refusing beats silently ignoring args_json, which REPLACES the vector. Tests: a mask at every position, in argv vectors of every shape (including neighbours copied verbatim from the stored vector), for a flag-bound mask, a detector-shaped mask and a mask at index 0, is always refused and never reverted; the marker list is pinned to the functions that render masks; and the write path itself (buildPatchConfigFromRequest) rejects the relocation attempt with the stored vector untouched. 2. Raw upstream URLs in logs — the remaining siblings (MINOR, pre-existing; identical on origin/main). internal/upstream/manager.go logged client.GetConfig().URL at Info on every connect attempt; internal/upstream/cli/client.go and connection_oauth.go's deprecated-endpoint error did the same. All three now go through oauth.RedactURLQueryParams / the existing logSafeURL helper. The observer test written for the manager site showed the field masks were only half of it: a net/http error quotes the request URL inside its own message (`Post "https://host/mcp?token=…": dial tcp …`), so the credential still reached main.log at Error level through zap.Error, and was stored as the client's last error. Redacted once at the seam where the transport error enters mcpproxy (core Connect), plus the log sites that fire before it (both auth-strategy loops, the SSE connection-lost handlers, the transport's request-failure log). The wrapper keeps the original reachable through Unwrap, so errors.Is/As and the substring classification the connect paths do are unaffected.
…sweep found Round 4 of the issue #1148 review, plus the exhaustive raw-URL sweep across internal/upstream, internal/transport and internal/server it asked for. - managed/client.go onStateChange logged the raw configured URL as `current_url` at ERROR level on the deprecated-endpoint (410 Gone) branch — the exact twin of the connection_oauth.go site round 3 fixed. Routed through a new Client.logSafeURL, matching core.Client and HTTPTransportConfig. - transport/retry_after.go rendered the request URL with the stdlib's url.URL.Redacted() on every 429/503-with-a-hint, at Info. That masks ONLY the userinfo password and leaves `?token=…` verbatim. Uses the project's own redactor now. - oauth.RedactURL had no `user:pass@` rule at all. It is the fallback RedactURLQueryParams takes when url.Parse FAILS — i.e. exactly the URL a connection error is being logged about — so every logSafeURL() call site in three packages leaked the basic-auth password down that path. The userinfo masking is factored out of RedactSensitiveData and shared, so the two scrubbers cannot drift. - The two OAuth client-creation failures and the SSE stream-read failure in internal/transport logged their error bare; mcp-go builds the first two from url.Parse and *url.Error quotes the raw URL it was handed. They use logSafeErrorField now. - upstream/manager.go GetStats put the raw cfg.URL and last_error into the per-server status map. Round 3 deferred this as out of scope; deciding it now: the map is served verbatim as `upstream_stats` on /api/v1/status, on the /api/v1/servers response and on every SSE `status` event, alongside a server list that httpapi.redactServerSecrets and Runtime.redactServerSecrets already mask — so one half of a single payload was masked and the other was not. Both fields are masked here, honouring the same reveal_secret_headers opt-out. Explicitly out of scope, with evidence: the registry-source URLs in internal/server (list_registries, add/edit/remove_registry_source). A config.RegistryEntry carries no credential — `requires_key` marks a registry whose key is configured elsewhere — and the URL is the identity of the catalog. Docs: docs/configuration/upstream-servers.md still described the argv revert that round 3 deleted, so an operator would expect a masked args_json echo to round-trip safely when it now returns a hard error. The binding table and the prose state the new contract: argv masks are REFUSED, resend the real value or omit args_json. No other page repeats the old claim.
… the REST twins Round 4 of the #1148 review. Two of the four are corruption paths the earlier rounds of this branch created: a field newly MASKED on a read surface with no matching, key-bound revert on the write path lets a read-modify-write client persist the MASK STRING over the real credential. 1. oauth_json REPLACES the whole oauth block, but unmaskLiveOAuth reverted only client_secret. extra_params routinely holds an RFC 8707 resource indicator with a signed URL (masked by the URL rule) and any leaf can be masked by the value-shaped detector. Per field: client_secret / client_id / redirect_uri are REVERTED bound to the field name, extra_params is REVERTED bound to the parameter name, and scopes — whose only context is a position in a caller-supplied slice, the same non-binding an argv token has — is REFUSED. The residual check walks the whole block, so a field added to config.OAuthConfig later fails closed instead of round-tripping its own mask. 2. Editing a URL persisted a detector mask. For https://host/old?opaque=ghp_… the live detector masks the value; changing /old to /new defeats the whole-URL comparison and oauth.UnmaskURL ignores the unrecognised parameter. The revert is now per PARAMETER, bound to the parameter name and the stored scheme/host and to nothing else, so it survives an unrelated edit; anything it cannot bind (a moved authority, a credential outside the query string) is refused rather than written through. 3. GET /api/v1/servers returned args and oauth.extra_params in plaintext while the MCP surface masked exactly those. Both are masked now, and REST writes stay self-consistent with the argv contract this branch established: POST and PATCH refuse an echoed args mask with 400 rather than reverting it (the oauth block is read-only over REST, so it needs no write-path answer). The redaction rules move to internal/oauth, and the per-server field list to oauth.RedactServerSecretFields. That is the actual root cause of the half-done shape: internal/httpapi sits below internal/server in the import graph, and the REST handler and the /events SSE emitter each carried their own hand-copied field list. Three doors, one implementation now. 4. GET /api/v1/servers/{id}/logs served stored child-process and connection log lines without the scrubbing tail_log got. Scrubbed where a raw line becomes a LogEntry, so every reader of GetServerLogs is covered rather than one handler. Out of scope by maintainer direction, filed separately: the trace-mode transport logging, raw argv logging in the launcher/docker paths, raw URL logging in OAuth discovery, and the structured OAuth failure responses.
…r door Round 6 of the #1148 review found the same shape a sixth time: the field list was shared across the doors, the RULES were not. Finding 1 — a live leak. Redaction.detectContracted gated the value-shaped detector on `masked != original` for the WHOLE string, so once the NAME rule rewrote one component of a URL the detector was skipped for every other one. A URL holding two credentials published the second verbatim on `upstream_servers list`, `quarantine_security list_quarantined`, `GET /api/v1/servers` and the `/events` SSE payload: ?token=abc&opaque=<ghp> -> opaque published in the clear https://u:pw@host?opaque=<ghp> -> opaque published in the clear The detector now runs PER COMPONENT — every query parameter the name rule left alone, plus the path and the fragment — which closes it without collapsing the #872 component-wise rendering UnmaskURL binds to. The same guard leaked one leaf down (an env or header value whose name rule fired on an embedded `token=` pair); it is now skipped in exactly one case: the name rule replaced the WHOLE value with this package's own mask, so no byte of the secret survives for the detector to find. Finding 2 — the same half-done shape one layer down. RedactServerSecretFields applied name-rule-only redaction while the MCP door applied the name rule PLUS the detector, so a credential under a benign env/header name, or under an unrecognised URL query parameter, was masked on MCP and plaintext on `GET /api/v1/servers` and every `servers.changed` SSE payload. It now uses LiveRedaction. Adding that masking without a matching revert would have traded a disclosure for corruption, so the write mirrors move down into internal/oauth (serverwrite.go) — internal/httpapi sits below internal/server and cannot import it. REST PATCH now calls the same UnmaskLiveURL / UnmaskLiveEnvValues / UnmaskLiveHeaders the MCP patch door calls; the round trip is pinned by tests at both the rule level and through the handler. Finding 3 — oauth.scopes was masked on MCP and returned unredacted over REST and SSE. Now masked on both. (contracts.OAuthConfig has no ClientSecret, so that absence stands.) Finding 4 — MCP `upstream_servers add` accepted echoed masks that REST POST refused, silently persisting text like `••••AL (12 chars)` as an argv token. Both create doors now refuse. Structurally: every write door — MCP add/update/patch, REST POST/PATCH — ends in ONE fail-closed residual check. Whatever still carries a mask after the key-bound reverts is refused, never persisted. That covers the fields with no binding (args, oauth.scopes, isolation.extra_args), a mask relocated to another key or host, and any field added to config.ServerConfig later. oauth.ServerFieldMaskDecisions records the per-field answer once, and a reflection test over config.ServerConfig and contracts.Server fails when a field appears on the wire without one. Docs corrected: rest-api.md asserted the shared rule set that did not exist.
…d server fields Three rounds running, the review has found the GUARD failing open rather than the code it guards. Each fix here is structural. Derive the marker set from the renderers. oauth.MaskMarkers was hand maintained beside a separate set of mask renderings and listed only the bullet run and the detector's elision. It did not know about `***REDACTED***`, which oauth.RedactSensitiveData emits — and that runs on every uncontracted leaf through Redaction.Leaf, so an `isolation.extra_args` value of `-e API_KEY=<token>` was rendered `-e API_KEY=***REDACTED***` on the read door and CheckServerWriteMasks then ACCEPTED that echo and persisted it over the live credential. The markers are now assembled from a registry of the renderings themselves (maskRenderings) plus security.MaskMarkers(), and a test runs every registered renderer's probe through the net and fails when the net cannot detect the result. Move the generic redaction WALK from internal/server into internal/oauth, beside the leaf rules. The leaf rules were already shared; the descent was not, so the two doors that cannot import internal/server each re-derived it field by field and each missed the same field. RedactServerSecretFields (GET /api/v1/servers and every /events servers.changed payload) skipped server.Isolation entirely, and `upstream_servers list` republished docker_isolation.server_isolation.extra_args and the whole global docker_status.isolation_config in the clear beside the masked env/url/args. Both now run the shared walk, under the same reveal_secret_headers gate as every other secret-bearing field, and the payload shape is unchanged. Make the decision guard recursive. It reflected over TOP-LEVEL fields only, which is why all of the above lived in a nested field it never looked at. It now walks nested structs, slices and maps, and every leaf that can carry TEXT — derived from its Go type, not asserted — needs an explicit entry. isolation_defaults is re-judged from not-secret to refuse: it is resolved from the operator-supplied global docker_isolation block, so a credential in the global extra_args lands in it verbatim. RedactNested decodes into a fresh value rather than over its destination: encoding/json reuses an existing slice's backing array, so decoding the mask over a projection that still aliases the stored config would overwrite the live credential with its own mask — the #1142 corruption in a new place. Refs #1148
The server edition's ServerResponse EMBEDS the raw *config.ServerConfig, and for a SHARED server that config is the admin's, not the caller's. listServers, getServer and enableServer each built it unredacted, so every authenticated user of a deployment was handed the admin-configured upstreams' `headers` (Authorization, X-API-Key), `env`, URL query credentials, `oauth.client_secret`, `auth_broker.client_secret` and `isolation.extra_args` in the clear. Same defect class as #1148, on a door that sweep did not reach — and reached by the same cure: the rule is the shared one, applied through a walk rather than a field list. - internal/oauth/serverconfigfields.go is the *config.ServerConfig analogue of RedactServerSecretFields. RedactedServerConfigView (the map form) MOVES here out of internal/server, and RedactServerConfigSecrets returns a masked COPY for a door that must hand back the struct. Both walk the config under oauth.LiveRedaction, so a field added to ServerConfig — or to the build-tagged auth_broker block, whose fields internal/oauth cannot name in the personal edition — is masked because the walk reaches it. The typed copy decodes into a FRESH struct: h.sharedServers is the live admin config, and writing a mask through it would be the #1142/#1146 corruption with the whole deployment as the blast radius. It fails closed to {name}. - internal/server/mcp_server_view.go now delegates. One walker serves the MCP view, the REST/SSE view and this one; a rule reachable from only some of its doors is what every round of #1148 has been. PERSONAL servers are deliberately left unmasked and the reason is pinned in a test: they are the caller's own credentials, and updateServer replaces URL, Args and Headers WHOLESALE, so masking them without a key-bound unmask mirror would let a read-modify-write client persist the masks over real secrets. Masking the SHARED half is safe precisely because it is read-only to users — update and delete answer 403, and enable stores a per-user preference. ServerFieldMaskDecisions needs no new rows: the walk reuses paths it already covers, and TestServerFieldMaskDecisions_CoverEveryNestedLeaf passes under both build tags. Tests: per-handler secret checks, a live-config-not-mutated check, the personal-stays-unmasked pin, reflection-derived "every text leaf whose decision is not not-secret must be masked", no-aliasing, non-secret-fields-survive-the- round-trip, and typed-copy-equals-map-view parity. The fail-closed net walks chi's OWN route table, so a fourth route registered under /user/servers is covered the moment it exists rather than when somebody remembers it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
37759e5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fd6b7251.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-laughing-poitras-0575.mcpproxy-docs.pages.dev |
…as-05750d # Conflicts: # internal/upstream/managed/client.go
…w upstream error Merging main brought GH #1145's `retry_stopped` trio onto contracts.Server, and TestServerFieldMaskDecisions_CoverEveryNestedLeaf caught both new text leaves with no decision — the canary doing exactly its job on a field this branch never touched. `retry_stopped_reason` is NOT the fixed catalog string its name implies. diagnostics.PermanentFailureReason falls through to `rawError` whenever the terminal code has no catalog entry, and that raw error is ci.LastError.Error() — which core.enrichTransportClosedError folds the CHILD PROCESS'S captured stderr into, and which routinely carries the upstream URL with its query credentials. So it published them on `GET /api/v1/servers` and on every `/events` servers.changed payload. It is now scrubbed in parity with last_error / health.detail / diagnostic.cause. `retry_stopped_code` is a stable MCPX_* catalog code this proxy produced and stays readable: it is the one field that says WHY a server parked. Decision rows added for both; nothing writes back through either. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 33496461809 --repo smart-mcp-proxy/mcpproxy-go
|
…n startup
The test gave `python3 -c` 3s to cover process spawn, interpreter startup and
the script's own 250ms pre-bind sleep. A loaded ubuntu-latest runner blew it
("url http://127.0.0.1:PORT/mcp not reachable in 3s ... connection refused"),
failing Unit Tests on an unrelated PR; the same test runs in 0.41s locally and
passed 5/5 there.
What the test proves is that Spawn and WaitForURL AGREE on a real listening
child, not how fast a runner can start CPython, so the budget goes to 30s
(outer context 40s). No assertion is weakened: a genuinely broken WaitForURL
still fails, just later, and `elapsed >= 200ms` still pins the polling
behaviour because the child's 250ms sleep guarantees the first dial misses.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This was referenced Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
internal/serveredition/api/user_handlers.go(build tagserver) leaked credentials across tenants.ServerResponseembeds the raw*config.ServerConfig, and for a shared server that config is the admin's, not the caller's.listServers,getServerandenableServereach built it unredacted, so every authenticated user of a deployment was handed the admin-configured upstreams'headers(Authorization, X-API-Key),env, URL query credentials,oauth.client_secret,auth_broker.client_secretandisolation.extra_argsin the clear.Same defect class as #1148 — on a door that sweep did not reach — and closed the same way: the shared rule, applied through a walk rather than a field list.
Changes
internal/oauth/serverconfigfields.go(new) — the*config.ServerConfiganalogue ofRedactServerSecretFields:RedactedServerConfigView/RedactedServerConfigViews— the map form, moved out ofinternal/server/mcp_server_view.go.RedactServerConfigSecrets— a masked copy underoauth.LiveRedaction, for a door that must hand back the struct.Both walk the config, so a field added to
ServerConfig— or to the build-taggedauth_brokerblock, whose fieldsinternal/oauthcannot even name in the personal edition — is masked because the walk reaches it, not because somebody remembered a line. The typed copy decodes into a fresh struct and fails closed to{name}.internal/server/mcp_server_view.go— now delegates. One walker serves the MCP view, the REST/SSE view and this one; a rule reachable from only some of its doors is what every round of quarantine_security list_quarantined returns env/headers/oauth secrets in plaintext, unauthenticated #1148 has been.internal/serveredition/api/user_handlers.go— onesharedServerResponse()funnel behind all three shared branches.Reviewer notes
h.sharedServersis the live admin config. Masking returns a copy that shares no map, slice or pointer with it — writing a mask through it would be the isolation.enabled: nil (inherit global) is reported as false, so isolated servers display as unisolated #1142/Activity log drops the payload of upstream_servers / quarantine_security mutations (records only operation + name) #1146 read-modify-write corruption with the whole deployment as the blast radius. Pinned byTestRedactServerConfigSecrets_LeavesTheInputUntouchedand by a deep-equal check in each handler test.updateServerreplacesURL,ArgsandHeaderswholesale from the request body, so masking them without a key-bound unmask mirror (UnmaskLiveHeaders/UnmaskLiveURL+CheckArgvMaskEcho) would let a read-modify-write client persist the masks over real secrets. Masking the shared half is safe precisely because it is read-only to users:updateServer/deleteServeranswer 403 andenableServerstores a per-user preference without touching the shared config.ServerFieldMaskDecisionsneeds no new rows — the walk reuses paths it already covers, andTestServerFieldMaskDecisions_CoverEveryNestedLeafpasses under both build tags.enableServerwas a third leaking site alongside the two named in the report; the fail-closed net below is driven by chi's own route table so a fourth is covered the moment it is registered, not when somebody notices it.Testing
New tests, all verified to actually bite — neutering
sharedServerResponsefires 48 assertions:internal/serveredition/api/user_handlers_redaction_test.go— per-handler secret checks, live-config-not-mutated, the personal-stays-unmasked pin, andTestUserServerRoutes_NeverEchoASharedServerSecret, which walks the router's own route table.internal/oauth/serverconfigfields_test.go— reflection-derived "every text leaf whose decision is notnot-secretmust be masked", no-aliasing, non-secret-fields-survive-the-round-trip, and typed-copy ≡ map-view parity.Green locally: