mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

security: server removal leaves prompt approvals, OAuth state and approval writers behind; same-name re-add inherits them

Open Dumbris opened this issue 1 month ago • 0 comments

Problem

Server removal does not purge all security state keyed by server name, so a same-name re-add inherits it:

  • REST removal (internal/server/server.go:2153-2240) deletes tool approvals and OAuth state but not prompt approvals (DeleteServerPromptApprovals exists, internal/storage/bbolt.go:758, but removal never calls it) or per-server call history.
  • Config-driven removal (lifecycle.go:1613-1640) deletes only the upstream row, history/index entries; tool approvals are left to the orphan prune, which is skipped when the configured set is empty (lifecycle.go:1455-1461) or when a save-resurrection keeps the name in the live config; OAuth state is not cleared.
  • Removal is not exclusive with approval writers: ApproveTools (internal/runtime/tool_quarantine.go:2019) reads a record and later upserts it with no commit lock or server-generation check, so a removal finishing in between lets the approval restore the deleted baseline. Scanner ApproveServer (internal/security/scanner/service.go:1697) can pause before UnquarantineServer, cross a remove/re-add, and unquarantine the replacement with the old server's approval.

Failure scenario

Remove server A (approved tool hashes, approved prompt hashes, OAuth tokens), re-add a different A under manual trust: matching tool/prompt hashes take the approved path (tool_quarantine.go hash match, internal/server/prompt_quarantine.go) without fresh review, and old OAuth credentials are reused.

Suggested direction

One shared "purge server security state" helper (tool approvals, prompt approvals, OAuth state, history, index, baseline markers) called by REST/MCP/config-driven removal; bind approval commits to a server generation and serialize them with removal.

Where Sol found it

ux01-r8-A.txt #3, ux01-r9-B.txt #3, ux01-r9-D.txt #1, ux01-r10-C.txt #1.

Related: #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 (704795c83) 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/.

Dumbris avatar Oct 11 '26 03:10 Dumbris