Skip to content

security: no retirement barrier for upstream dials - removed/replaced/quarantined servers can still launch or receive credentialed requests #1564

Closed

Description

@Dumbris

Problem

Nothing stops an upstream client from dialing after the server it belongs to was removed, replaced, disabled or quarantined. Manager.AddServer (internal/upstream/manager.go:590) looks up the client with GetClient and calls client.Connect with no re-check of its registration; managed.Client.Connect (internal/upstream/managed/client.go:436) accepts a disconnected client and Disconnect (:651) only cancels an already-installed connect context, so it is not a permanent retirement barrier.

Consequences observed while Sol reviewed a prototype retirement gate in #1553 (a design for any fix must cover them):

  • stdio start uses context.Background() (internal/upstream/core/connection_stdio.go:258), so cancellation cannot stop a launch that is already admitted; the removed server's command can execute.
  • HTTP/SSE: admission released before the auth strategy issues requests (internal/upstream/core/connection_http.go:185-218), so credential-bearing requests can still go to the old endpoint.
  • net/http internal retries re-fire WroteRequest and can resend after retirement; SSE GET is retryable.
  • OAuth uses a separate OAuthConfig.HTTPClient (internal/oauth/config.go:1261-1322) outside any gate: metadata, registration, token/refresh requests with client secrets can reach the old endpoint.
  • Publication of the config (retire) and eventual manager reconciliation are separate steps, so a client captured under the guard can still dial after the commit.

Failure scenario

Goroutine obtains the client pointer, RemoveServer deletes and disconnects it, the goroutine resumes and Connects: process spawned / handshake sent / credentials disclosed for a server the operator already removed or quarantined.

Suggested direction

A per-client retirement latch synchronized with config publication, enforced at actual dial/request admission for stdio, HTTP, SSE and the OAuth HTTP client, including retry attempts; with deterministic tests that count launches/requests (marker process, request counters) when retirement lands between lookup and dial.

Where Sol found it

ux01-r7a.txt #1, ux01-r7b.txt #1, ux01-r8-BC.txt #1, ux01-r9-A.txt #1, ux01-r10-A.txt #1 and #2.

Related: #1563, #1559


Found by OpenCode Sol 6.1 cross-model review of the (now split) oversized PRs #1553 (UX-01) and #1555 (UX-02); verified still present on origin/main (704795c) by reading the cited sites. Pre-existing, deliberately out of scope of the minimal core PRs. Review transcripts: docs/qa/0.70.0-ux-2026-10-10/remediation/reviews/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/oautharea/proxykind/bugkind/securitypriority/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions