Skip to content

fix(security): close the per-user door's remaining shared-server leaks (#1161) - #1165

Merged
Dumbris merged 1 commit into
mainfrom
claude/mcpproxy-go-issue-1161-337e74
Sep 1, 2026
Merged

Dumbris merged 1 commit into
mainfrom
claude/mcpproxy-go-issue-1161-337e74

Conversation

@Dumbris

@Dumbris Dumbris commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Closes #1161.

Where this starts

The three handlers #1161 names — listServers, getServer, enableServer — were already fixed on main by 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:81 does sharedServers := deps.Config.Servers — the admin's whole server list — and hands that same slice to every per-user handler. sc.Shared is therefore the entitlement check, not a formality. user_handlers.go applies 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 entry ownership:"shared". Any authenticated user learned the name, protocol and enablement of admin upstreams the admin deliberately did not share.
  • The credential surfaces (credential_handlers.go) selected on AuthBroker != nil alone. A non-shared brokered upstream was enumerable through GET /api/v1/user/credentials, and — for oauth_connect mode — its connect flow was drivable: following connect_path ran 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 shared brokerEntitled predicate.

Shared servers now mask under AuditRedaction, not 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: a durable fingerprint and a correlation handle across tenants. RedactServerConfigSecrets takes the policy as a parameter.

getServer dropped the caller's own preference. Its shared branch rendered user_enabled as unset, disagreeing with listServers and with the .../enable response.

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 from UserHandlers. Both leaking siblings are on the same door, mounted by the same Group in setup.go, and neither was reachable by that walk.

The new net takes the whole /user/ prefix off RegisterRoutesWithPrefix — 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 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.

Overlap with #1164

This branch originally carried a fourth fix: GET /api/v1/config served the raw config — every upstream secret plus the global api_key — to any agent-token caller, which in the server edition is any tenant (they mint one at POST /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.UnmaskLiveConfigTree bound into handleApplyConfig/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/... — pass
  • go test -short -race -skip "Binary|MCP|E2E|..." ./internal/... — pass
  • golangci-lint run --config .github/.golangci.yml on the touched packages — 0 issues
  • Each new guard was proven to bite: reverting the entitlement gates fails the door walk.

Cross-reviewed with opencode --model github-copilot/gpt-5.6-sol before the rebase. It caught one genuine defect in the (now dropped) /config tests — a vacuous live-config mutation assertion, since the fixture minted a fresh config per call. Its other finding, that the redacted /config still enumerates server names, is real but pre-existing and wider than this issue: GET /api/v1/servers does not scope-filter agent tokens either, so /config is not a bypass of it. Filed as #1166.

Also filed from this sweep

#1166 (REST enumeration ignores agent-token scope) · #1167 (reveal_secret_headers unmasks for non-admins on the REST/SSE doors) · #1168 (global agent-token namespace; AuthContext() drops UserID) · #1169 (bearer-JWT admin role frozen in the claim)

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

#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
Dumbris force-pushed the claude/mcpproxy-go-issue-1161-337e74 branch from 04df0fa to 2b5ac94 Compare September 1, 2026 13:27
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: claude/mcpproxy-go-issue-1161-337e74

Available Artifacts

  • archive-darwin-amd64 (29 MB)
  • archive-darwin-arm64 (26 MB)
  • archive-linux-amd64 (17 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (29 MB)
  • archive-windows-arm64 (26 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (23 MB)
  • installer-dmg-darwin-arm64 (21 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 33513484998 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris
Dumbris merged commit eed77f7 into main Sep 1, 2026
37 checks passed
@Dumbris
Dumbris deleted the claude/mcpproxy-go-issue-1161-337e74 branch September 1, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server edition: every authenticated user can read shared servers' credentials via listServers/getServer

2 participants