Skip to content

vMCP: session-init backend dials cannot install a dial-control (SSRF) guard #6545

Closed

Description

@tgrunnagle

Summary

pkg/vmcp/session opens a persistent connection to every backend during
session initialize (the MCP handshake plus capability listing). These
session-init dials use http.DefaultTransport and carry no
net.Dialer.Control hook, and NewSessionFactory exposes no option to
inject one. This is asymmetric with the per-call backend client in
pkg/vmcp/client, which already offers WithDialControl for exactly this
purpose.

The consequence is a gap for any embedder that installs a dial guard (for
example, an SSRF / DNS-rebinding guard that refuses dials resolving into
private IP ranges) on the backend client: the guard covers the aggregator
and tool-call paths, but it does not cover the session-init dials the
session factory performs. If a backend endpoint is operator- or
attacker-influenceable, session initialize will dial it — and run the
handshake and capability listing against it — regardless of the guard
installed elsewhere.

Why this matters

The dial-control hook fires after DNS resolution and before the TCP
handshake, receiving the resolved peer IP. That is what defeats
DNS-rebinding: a hostname can pass a name-based check and then resolve to a
blocked IP. Because the session-init path has no such hook, there is
currently no way to enforce a private-address (or any other) dial policy on
the connections opened at session creation.

Investigation (current main, v0.47.0)

  • pkg/vmcp/session/factory.go — NewSessionFactory(registry, opts ...MultiSessionFactoryOption)
    exposes only WithMaxBackendInitConcurrency, WithBackendInitTimeout,
    WithRequestTimeoutResolver, and WithRevisionLookup. There is no
    dial-control option.
  • pkg/vmcp/session/internal/backend/mcp_session.go — createMCPClient
    builds the transport chain from base := http.RoundTripper(http.DefaultTransport)
    for both the streamable-http and sse branches. The default transport
    has no net.Dialer.Control, so the resolved peer IP is never inspected.
  • Precedent already in-tree: pkg/vmcp/client/client.go defines
    WithDialControl(control func(network, address string, c syscall.RawConn) error) Option,
    plumbed through backendDialer and newBackendTransport onto the
    per-backend *http.Transport. Its doc comment documents the caveats an
    embedder must understand (per-TCP-dial not per-request; proxy transparency;
    both IP families).
  • pkg/networking already provides the building blocks
    (NewPrivateIPBlockingDialContext, protectedDialerControl,
    IsPrivateIP) an embedder would use to construct such a control.

Proposed change

  1. Add session.WithDialControl(control func(network, address string, c syscall.RawConn) error) MultiSessionFactoryOption,
    mirroring the signature and doc caveats of vmcpclient.WithDialControl
    exactly.
  2. Thread it into backend.NewHTTPConnector as an HTTPConnectorOption and
    into createMCPClient, so that when set, the base transport is built from
    a cloned *http.Transport whose DialContext uses a
    net.Dialer{Control: control} — instead of bare http.DefaultTransport —
    for both the streamable-http and sse branches.
  3. Reuse the same dialer/transport construction the client package already
    uses (backendDialer / newBackendTransport) so the two paths stay in
    sync; consider extracting a small shared helper rather than duplicating.
  4. Optionally wire the option in pkg/vmcp/cli/serve.go where the session
    factory is constructed, so a production deployment can opt into a guard.

Done when

  • A MultiSessionFactoryOption exists to supply a dial control to
    NewSessionFactory.
  • When the control is set, it fires on session-init backend dials for
    both streamable-http and sse transports — pinned by a test that
    installs a deny-all control and asserts the backend receives zero
    requests during initialize.
  • When the control is unset, behavior is byte-for-byte identical to
    today (default transport, no hook).
  • The option's signature matches net.Dialer.Control and the existing
    vmcpclient.WithDialControl exactly, and carries the same caveat
    documentation.

Activity

  1. added
    enhancement
    vmcp
    on Sep 8, 2026
  2. tgrunnagle commented on Sep 8, 2026

    @tgrunnagle
    CollaboratorAuthor

    Related: #6546 — both stem from the same MultiSessionFactory ownership boundary over per-session backend connections (dial control on the way in; teardown on the way out).

  3. added
    needs-triage
    on Sep 8, 2026
  4. self-assigned this
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementneeds-triagesecurityvmcp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions