Repository navigation
fix(security): close the per-user door's remaining shared-server leaks (#1161) - #1165
Merged
Merged
Conversation
This was referenced Sep 1, 2026
Deploying mcpproxy-docs with
|
| Latest commit: |
2b5ac94
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://71d9c448.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-mcpproxy-go-issue-116.mcpproxy-docs.pages.dev |
This was referenced Sep 1, 2026
#1161) Issue #1161 was fixed for the three handlers it named (listServers, getServer, enableServer, commit ad22f08). This closes the rest of the same class on the same trust boundary. The server edition's whole per-user surface leans on ONE entitlement predicate — `sc.Shared` — because setup.go hands every handler `deps.Config.Servers`, the admin's WHOLE server list, under the name `sharedServers`. Two sibling handlers on that door never applied it: - getDiagnostics iterated the list unfiltered and labelled every entry `ownership:"shared"`, so any authenticated user learned the name, transport and enablement of admin upstreams the admin did not share. - The credential surfaces selected on `AuthBroker != nil` alone. A non-shared brokered upstream was therefore enumerable AND its per-user OAuth connect flow drivable: following the connect path ran the gateway's flow against the admin's registered client and persisted a per-user credential for a server the caller was never granted. They now select through one shared `brokerEntitled` predicate. Shared servers now mask under AuditRedaction rather than LiveRedaction. `••••<last2> (<N> chars)` is an affordance for someone editing their OWN credential; the reader of a shared server is a different tenant who cannot edit it at all (updateServer and deleteServer answer 403, enableServer stores only a per-user preference), so it bought them nothing while publishing the admin credential's exact length and trailing bytes to every user of the deployment. RedactServerConfigSecrets takes the policy as a parameter. getServer's shared branch rendered the caller's own preference as unset, so the detail read disagreed with listServers and with the .../enable response. It now threads the stored preference. Tests: the fail-closed route walk now covers the WHOLE `/user/` prefix and is driven by RegisterRoutesWithPrefix — the form production actually wires — rather than `/user/servers` on a router only assembled from UserHandlers, which is why neither leaking sibling was reachable by it. It asserts both halves: no shared credential is echoed, and an unentitled upstream answers exactly as an absent one (no existence oracle). A parity test pins the two hand-maintained route tables against each other. CI: `./internal/oauth/...` now runs under `-tags server`. The mask decisions for the `auth_broker` block live behind that tag, so the canary enforcing "every text-carrying leaf has a decision" — the guarantee this whole fix rests on — never compiled in CI. The fourth leak this branch originally carried — GET /api/v1/config serving the raw config to any agent-token caller — landed independently in #1164 (round 9), with a stronger fix: masked for everyone by default with a matching write-path unmask twin (oauth.UnmaskLiveConfigTree), rather than gated on caller identity. That work supersedes this branch's version, which is dropped here along with its now-redundant test.
Dumbris
force-pushed
the
claude/mcpproxy-go-issue-1161-337e74
branch
from
September 1, 2026 13:27
04df0fa to
2b5ac94
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 33513484998 --repo smart-mcp-proxy/mcpproxy-go
|
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.
Closes #1161.
Where this starts
The three handlers #1161 names —
listServers,getServer,enableServer— were already fixed onmainby ad22f08 (PR #1162). This PR closes the rest of the same class, found by sweeping the surfaces that fix did not reach.The residual leaks
One predicate, three handlers, two of them missing it.
internal/serveredition/setup.go:81doessharedServers := deps.Config.Servers— the admin's whole server list — and hands that same slice to every per-user handler.sc.Sharedis therefore the entitlement check, not a formality.user_handlers.goapplies it at all six of its loops; two siblings on the same door did not:getDiagnostics(user_activity.go:134) iterated the list unfiltered and labelled every entryownership:"shared". Any authenticated user learned the name, protocol and enablement of admin upstreams the admin deliberately did not share.credential_handlers.go) selected onAuthBroker != nilalone. A non-shared brokered upstream was enumerable throughGET /api/v1/user/credentials, and — foroauth_connectmode — its connect flow was drivable: followingconnect_pathran the gateway's OAuth flow against the admin's registered client and persisted a per-user credential for a server the caller was never granted. They now select through one sharedbrokerEntitledpredicate.Shared servers now mask under
AuditRedaction, notLiveRedaction.••••<last2> (<N> chars)is an affordance for someone editing their own credential. The reader of a shared server is a different tenant who cannot edit it at all —updateServeranddeleteServeranswer 403,enableServerstores only a per-user preference — so it bought them nothing while publishing the admin credential's exact length and trailing bytes to every user of the deployment: a durable fingerprint and a correlation handle across tenants.RedactServerConfigSecretstakes the policy as a parameter.getServerdropped the caller's own preference. Its shared branch rendereduser_enabledas unset, disagreeing withlistServersand with the.../enableresponse.Why the previous net didn't catch these
The #1161 fix shipped a fail-closed route walk — but scoped to
/user/servers, over a router assembled only fromUserHandlers. Both leaking siblings are on the same door, mounted by the sameGroupinsetup.go, and neither was reachable by that walk.The new net takes the whole
/user/prefix offRegisterRoutesWithPrefix— the form production actually wires — and asserts both halves: no shared credential is echoed, and an unentitled upstream answers exactly as an absent one (no existence oracle). A parity test pins the two hand-maintained route tables against each other, since only the prefixed one ships.CI
./internal/oauth/...now runs under-tags server. The mask decisions for theauth_brokerblock live behind that tag, so the canary enforcing "every text-carrying leaf has a decision" — the guarantee this whole fix rests on — never compiled in CI.Overlap with #1164
This branch originally carried a fourth fix:
GET /api/v1/configserved the raw config — every upstream secret plus the globalapi_key— to any agent-token caller, which in the server edition is any tenant (they mint one atPOST /api/v1/user/tokens).#1164 landed that independently, and better. Its version masks for everyone by default with a matching write-path unmask twin (
oauth.UnmaskLiveConfigTreebound intohandleApplyConfig/handlePatchConfig), rather than gating on caller identity as this branch did — so it does not depend on the Web UI happening to authenticate as admin. Rebased onto it; this branch's version and its now-redundant test are dropped.Verification
go test -race -tags server ./internal/serveredition/... ./internal/config/... ./internal/oauth/...— passgo test -short -race -skip "Binary|MCP|E2E|..." ./internal/...— passgolangci-lint run --config .github/.golangci.ymlon the touched packages — 0 issuesCross-reviewed with
opencode --model github-copilot/gpt-5.6-solbefore the rebase. It caught one genuine defect in the (now dropped)/configtests — a vacuous live-config mutation assertion, since the fixture minted a fresh config per call. Its other finding, that the redacted/configstill enumerates server names, is real but pre-existing and wider than this issue:GET /api/v1/serversdoes not scope-filter agent tokens either, so/configis not a bypass of it. Filed as #1166.Also filed from this sweep
#1166 (REST enumeration ignores agent-token scope) · #1167 (
reveal_secret_headersunmasks for non-admins on the REST/SSE doors) · #1168 (global agent-token namespace;AuthContext()dropsUserID) · #1169 (bearer-JWT admin role frozen in the claim)