Skip to content

Residual scope-filter gaps from the #1166/#1167 review: fail-open stats filter, unclassified SSE event, total_tools drift #1184

Closed

Description

@Dumbris

Residual findings from the final cross-review of #1182, kept out of that PR to stop it growing further. None is an escalation; all are narrowing or correctness gaps in the scope filter it introduced.

1. sensitive_data.detected is not an identity-bearing SSE event type (internal/httpapi/sse_scope.go:127). It is emitted once per tool call that tripped the detector and reaches a scoped subscriber unchanged. Payload is activity_id + detection metadata, so it discloses that some server tripped the detector and when — a timing and volume signal about servers the caller cannot see.

2. filterUpstreamStatsServers fails open on an unexpected shape (internal/httpapi/scope.go:82). When stats["servers"] is absent or is not a map[string]interface{}, it returns the input map unfiltered — including total_servers, connected_servers, quarantined_servers, total_tools and whatever the per-server structure actually is. A producer change would silently reopen the count oracle. Fail closed instead.

3. total_tools recomputation counts servers the producers exclude (internal/httpapi/scope.go:122). The scoped recomputation sums entry["tool_count"] over every visible entry, but both producers only add a server's ToolCount when config.ServerContributesTools(Enabled, Quarantined) holds. A disabled server keeps a non-zero tool_count, so a scoped caller's total disagrees with the admin's for the same set.

4. SetTokenRevoker is called unconditionally three lines after a nil-guard on the same value (internal/serveredition/setup.go:127, from #1183). Either the guard is unnecessary or this call needs one.

5. createServer still distinguishes admin-config names by status (internal/serveredition/api/user_handlers.go:411, from #1183). The bodies were made identical, but a name held by the admin config returns 409 while an unused name returns 201 and is then deletable — so a tenant can still probe for admin-private server names. Narrower than the oracle that was closed, but the same shape.

6. mcpproxy status masks the API key but not the URL carrying it (cmd/mcpproxy/status_cmd.go:157). info.APIKey is masked without --show-key; info.WebUIURL carries the same key unmasked. Cosmetic — the CLI reads the key off the operator's own config file — but it is inconsistent with the masking the same function performs.

Activity

  1. added
    kind/bug
    kind/security
    area/proxy
    priority/medium
    on Sep 2, 2026
  2. Dumbris commented on Sep 7, 2026

    @Dumbris
    MemberAuthor

    Triage of the six findings against current main — finding 5 is refuted, the rest stand. Leaving the issue open for the other five.

    5 — createServer name-collision oracle: REFUTED. Both refusal paths already return the identical status and body: internal/serveredition/api/user_handlers.go:410-428 uses one const nameUnavailable and http.StatusConflict for both the admin-held name and the caller's own. The residual 409-vs-201 distinction is inherent to enforcing name uniqueness at all; the real fix is owner-qualified names in auth.AuthContext.CanAccessServer, which the code already documents at :401-408. Nothing at this door can close it.

    6 — CONFIRMED, and the highest practical impact of the six. cmd/mcpproxy/status_cmd.go:157 masks info.APIKey, then :456-458 builds http://%s/ui/?apikey=%s from the unmasked key and :549 prints it two lines later. The masking exists so mcpproxy status is safe to paste into a bug report or screen-share, and the next line hands over the full admin key. ~6 lines.

    1 — CONFIRMED, low/moderate. sensitive_data.detected is absent from identityBearingEventTypes (internal/httpapi/sse_scope.go:114-128). It is a timing/volume/secret-type oracle over invisible servers rather than a content leak — activity_id cannot be pivoted (activity.go:268-271 404s with status parity). Better fix than deletion: record.ServerName is in scope at both emit sites, so add server_name and let the existing key scan filter it, preserving the event for the caller's own servers.

    2 — CONFIRMED, latent. scope.go:82-85 returns stats unfiltered on !ok. Unreachable today (both producers always allocate "servers"), but it is the wrong fail direction and both siblings fail closed. ~4 lines.

    4 — PARTLY CONFIRMED; location and framing in the issue are wrong. The guard is at setup.go:57, the call at :167 — not "three lines after" — and the guard is not redundant. The bug is worse than described: a nil *storage.Manager boxed into the adminTokenRevoker interface becomes a non-nil interface, defeating the h.tokenRevoker != nil check at admin_handlers.go:228 and panicking in RevokeAgentTokensForOwner. Unreachable in production (serveredition_wire.go:22-26 bails first). 3 lines.

    3 — CONFIRMED, cosmetic. Quarantined servers already agree (entry is 0); only disabled ones diverge, and the sum runs over entries the caller may already see, so it is not a disclosure. Needs a design call: the entry map carries no enabled key, so either add one or zero tool_count at the producer — which changes what an admin UI shows.

    Suggested split: do 6 now (trivial and user-facing), batch 1/2/4 as fail-closed hardening, and take a design call on 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/proxykind/bugkind/securitypriority/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions