Skip to content

REST server enumeration ignores agent-token scope: /api/v1/servers and /api/v1/config list every server regardless of allowed_servers #1166

Closed

Description

@Dumbris

Summary

GET /api/v1/servers and GET /api/v1/config enumerate every configured upstream to any caller holding an agent token, with no filtering by that token's allowed_servers scope. The MCP surface does filter — internal/server/mcp.go:3733 gates each entry on authCtx.CanAccessServer(s.Name) — so the REST doors are a scope bypass for enumeration.

Credentials are masked on both routes (/servers via redactServerSecrets, /config since #1165), so this is a metadata disclosure: names, protocols, commands, URLs, enablement, topology.

Sites

  • internal/httpapi/server.go:1504 — handleGetServers: no CanAccessServer filter on either the management-service path or the legacy fallback.
  • internal/httpapi/server.go — handleGetConfig: serves the whole mcpServers array (masked) to a non-admin.

Why it matters

In the server edition this crosses a tenant boundary. A regular user mints an agent token for themselves at POST /api/v1/user/tokens (internal/serveredition/api/user_handlers.go:707), then reads the admin's entire upstream inventory — including servers with shared: false that the per-user door (/api/v1/user/servers) correctly hides. The per-user door was the subject of #1161; these two routes reach the same data on the same mux, past a different gate.

In the personal edition the impact is smaller (the token's owner configured the servers), but allowed_servers is documented as a scope and it does not hold here.

Found during

The #1161 residual sweep (#1165). Deliberately not folded into that PR: scope-filtering REST enumeration is a behaviour change affecting both editions and the Web UI, and wants its own decision about what a scoped token should see — an empty list, its allowed subset, or names-only.

Suggested direction

Filter both handlers through the same CanAccessServer predicate the MCP door uses, so a scoped token sees exactly its allowed subset. Admin contexts (API key, tray socket, OAuth admin) are unaffected. Consider whether /config should omit mcpServers entirely for a non-admin rather than render a filtered array.

Activity

  1. added
    kind/bugSomething isn't working
    area/teamsServer edition multi-user / teams features
    on Sep 1, 2026
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/teamsServer edition multi-user / teams featureskind/bugSomething isn't workingkind/securitySecurity fix or hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions