Skip to content

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

Closed

Description

@Dumbris

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 (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/.

Activity

  1. added
    kind/bug
    kind/security
    area/storage
    priority/high
    on Oct 11, 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/storagekind/bugkind/securitypriority/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions