Skip to content

vMCP: session identity binding is not enforced for tools/list (and other list methods) #6779

Done

Description

@nilsberberich

Scope update (2026-11-24, revised). The Legacy vMCP path checks session
ownership for every request that carries a session, list methods included
(sessionOwnershipMiddleware), and answers a foreign caller with 404
"Session terminated", the same response it gives for an unknown session ID.
The Modern (2026-07-28) path is sessionless: it dispatches before that
middleware, ignores Mcp-Session-Id, and builds every list from the
caller's own identity. The draft spec recommends exactly that for a server
that only serves that revision, so Modern does not refuse; see the comment
below for why.

Acceptance, for tools/list, resources/list, resources/templates/list
and prompts/list:

  • Legacy: a request carrying a session ID owned by another user gets
    404 "Session terminated", identical to the response for an unknown ID,
    and no session-scoped data is returned.
  • Modern: a request carrying any Mcp-Session-Id (foreign, unknown or
    valid) gets the caller's own list with HTTP 200. Nothing is derived from
    the session owner, no Mcp-Session-Id is minted or echoed, the response
    is the same in all three cases, and the owner's session is undisturbed.

Summary

vMCP binds each MCP session to the identity that created it and rejects calls from a different identity (identity binding mismatch → caller identity does not match session owner → session terminated). This works as intended for tools/call.

However, tools/list on a foreign session is answered with HTTP 200 and the session owner's tool list. A caller with a valid token of a different user can therefore enumerate the tools (and thereby the backends/permissions) of another user's session, provided they know its Mcp-Session-Id.

Environment

  • ToolHive operator / vMCP v0.51.4 (Kubernetes, VirtualMCPServer)
  • Embedded auth server with upstream providers (Keycloak as primary, a second OAuth provider via upstreamInject), Redis session storage, 2 vMCP replicas
  • Cedar authorization (MCPAuthzConfig) with per-group tool policies: user A is allowed 16 tools, user B 13 tools

Steps to reproduce

  1. User A logs in (OAuth via the embedded auth server), sends initialize, receives Mcp-Session-Id: S.
  2. User B logs in separately and obtains their own valid access token.
  3. User B sends tools/list with their own Authorization: Bearer <token B> and Mcp-Session-Id: S.
  4. User B sends tools/call (any allowed read-only tool) with the same headers.

Observed

  • Step 3: HTTP 200, 16 tools – the list of user A, including tools from backends user B is not authorized for (B's own session lists 13).
  • Step 4: rejected. Log:
    WARN identity binding validation failed: identity binding mismatch  reason=identity_binding_mismatch
    WARN caller authorization failed, terminating session  capability=<tool> error="caller identity does not match session owner"
    INFO Manager.Terminate: session terminated
    
  • Afterwards user A's session is terminated (A gets 0 tools / errors and must re-initialize).

Expected

tools/list (and presumably resources/list, resources/templates/list, prompts/list) should validate the caller against the session binding just like tools/call, and reject a foreign caller before returning any session-scoped data.

Analysis

pkg/vmcp/session/internal/security/security.go: sessionBindingDecorator only overrides CallTool, ReadResource and GetPrompt; all other methods are delegated to the embedded MultiSession without validation (documented in the type comment). The list handlers therefore return the owner's session-scoped capabilities (which, with Cedar, are already filtered per user) to any authenticated caller.

Impact

Low to moderate: requires a valid token and the victim's session ID (random UUID, only transmitted in headers). No tool results or identity data are leaked; only tool names / descriptions / schemas of the owner's session. With per-user authorization this reveals which backends and tools another user may use.

Related observation (by design, mentioned for completeness): a foreign tools/call terminates the owner's session (terminateOnBindingFailure, hijack prevention). Combined with the missing check on list methods, it might be worth rejecting foreign callers consistently at the session lookup for all methods, so that the behaviour is the same regardless of the method used. Whether termination of the owner's session is the desired trade-off (vs. just rejecting the foreign request) could be reconsidered.

Possible fix

Validate the caller binding for the list methods as well (e.g. in the decorator or centrally when resolving the session for any request), returning the same error as for tools/call.

Activity

  1. added
    needs-triage
    on Oct 10, 2026
  2. suantea commented on Oct 10, 2026

    @suantea

    I'd like to work on this. I'll enforce the session identity binding for session-scoped list methods (tools/list, resources/list, resources/templates/list, prompts/list) at the pre-dispatch CallGate, where a request can actually be rejected — the OnBeforeList* hooks cannot reject. Will open a PR shortly.

  3. jhrozek commented on Nov 24, 2026

    @jhrozek
    Contributor

    I rewrote the scope and acceptance at the top of this issue. Here is why.

    The first rewrite said a foreign user should be refused on all four list methods on both paths. That is right for Legacy and wrong for Modern.

    • Legacy has a session to be foreign to, and sessionOwnershipMiddleware already answers a foreign session ID with 404 "Session terminated", the same as an unknown ID. That covers the original report, where a foreign caller got the owner's tool list.
    • Modern (2026-07-28) has no sessions. The draft's Streamable HTTP page says a server that only supports that revision should ignore an Mcp-Session-Id header and not mint or echo session IDs. vMCP does that: it builds the list from the caller's own identity, so the caller never gets the owner's list.

    Refusing on Modern would also be a step back:

    • A 404 for a foreign ID next to a 200 for a random ID tells a caller which session IDs are live.
    • A bare 4xx on a Modern request can make a client that speaks both revisions fall back to initialize and treat the origin as Legacy-only.

    So the Modern acceptance is now "ignore the header, list for the caller, and answer the same way whether the ID is foreign, unknown or absent". A test-only change (PR to follow) pins that for all four methods, including that the core is called exactly once and only with the caller's identity.

    @suantea, you mentioned enforcing this at the pre-dispatch CallGate. The Legacy half is covered by the middleware already, and Modern should not refuse, so I think the code change you had in mind is no longer needed. Tests that tighten the Legacy side or anything I missed would still be welcome.

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

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions