Skip to content

security: quarantining a server via the config file leaves its tools in the search index, so retrieve_tools still discloses their descriptions #1061

Closed

Description

@Dumbris

Summary

Quarantining a server by editing the config file does not purge its tools from the Bleve index. retrieve_tools then returns that server's tool names, full descriptions and a call_with variant as ordinary callable results, until something else happens to reindex. The call itself is still refused, so this is a disclosure bug, not an execution bug — but disclosure of untrusted tool descriptions is precisely what quarantine exists to prevent, since that is where a Tool Poisoning Attack payload lives.

The same transition applied through POST /api/v1/servers/{id}/quarantine purges correctly. Only the config-file / hot-reload path is affected.

Why this matters more than a normal stale-index bug

The search path has no query-time quarantine filter on the description-bearing branch. Index absence is the control, and the code says so — internal/server/mcp.go:1743:

// Quarantined tools are deliberately absent from the search index: their
// untrusted descriptions/schemas are withheld so a Tool Poisoning Attack
// payload is never exposed to the agent. The loop above therefore can never
// surface them, and an agent searching for a capability a quarantined server
// provides would be told "no such tool". Enumerate those tools from
// authoritative state ... and prepend name-only locked entries (no
// description/schema) ...

The same block already anticipates index lag, but only as a transient:

// `seen` dedupes against tools the loop already handled — primarily for the
// brief window after a runtime quarantine toggle when a tool may still
// linger in the index

On the config-file path that window is not brief. Nothing ever closes it: the tools stay indexed, keep their descriptions, and are returned as normal results rather than the name-only locked entries the design intends.

Reproduction

Verified on main @ 4d30624 (v0.61.0), isolated instance, scratch --config and --data-dir.

  1. Start a core with an stdio server (@modelcontextprotocol/server-memory) and let it connect and index — 9 tools.
  2. Edit the config file, setting "quarantined": true on that server. Save; the file watcher hot-reloads.
  3. GET /api/v1/servers → quarantined: true, tool_count: 9.
  4. Call retrieve_tools with {"query": "create entities in a knowledge graph"}.

Actual:

servers surfaced: ['memory']
 - memory:create_entities   | call_with: call_tool_write       | Create multiple new entities in the knowledge graph
 - memory:create_relations  | call_with: call_tool_write       | Create multiple new relations between entities …
 - memory:delete_entities   | call_with: call_tool_destructive | Delete multiple entities and their associated relations …
 - memory:delete_observations | call_with: call_tool_destructive | Delete specific observations from entities …
 - memory:add_observations  | call_with: call_tool_write       | Add new observations to existing entities …
 - memory:read_graph        | call_with: call_tool_read        | Read the entire knowledge graph

Full descriptions, real call_with advice, no locked/name-only marker. The follow-up call is then refused:

🔒 SECURITY BLOCK: Server 'memory' is currently in quarantine for security review.
Tool calls are blocked to prevent potential Tool Poisoning Attacks (TPAs).

Expected: name-only locked entries with no description or schema, per the design comment above.

Control — the API path is correct. On a second instance, POST /api/v1/servers/everything/quarantine and the same query returns nothing for that server; GET /api/v1/index/search?q=echo → {"results":[],"total":0}.

Control — disable-via-config is correct. Setting "enabled": false in the config file does clear the tools (a disabled server drops out of the active set the orphan sweep uses).

Root cause

The index purge is bolted onto the two API mutation handlers rather than onto the state transition.

  • Runtime.QuarantineServer (internal/runtime/lifecycle.go:1498) calls indexManager.DeleteServerTools + reindexAffectedProfiles under an explicit // Security: comment (log line at :1517).
  • Runtime.EnableServer does the equivalent for the disable direction.
  • LoadConfiguredServers — the disk-reload path — detects the same transition and ignores it. storedServer.Quarantined != serverCfg.Quarantined is part of hasChanged (:1047) and is logged as quarantined_changed: true (:1060), but the only side effect inside that branch is the OAuth-state clear (:1065). No purge.
  • The orphan sweep (:1864) only removes servers no longer in config, so a server that is still configured but newly quarantined is never swept.
  • Discovery itself is fine: DiscoverTools already skips quarantined clients (internal/upstream/manager.go:1134, "Skipping quarantined client for tool discovery"). It just never removes what is already indexed.

Any path that flips Quarantined without going through Runtime.QuarantineServer inherits this. The config-load admission gate re-quarantining a server on reload is the same shape.

Suggested fix

Move the purge onto the transition rather than the caller. In LoadConfiguredServers, where quarantined_changed is already computed, do what QuarantineServer does when the new value is true:

if existsInStorage && !storedServer.Quarantined && serverCfg.Quarantined && r.indexManager != nil {
    if err := r.indexManager.DeleteServerTools(serverCfg.Name); err != nil { /* warn */ } else {
        r.reindexAffectedProfiles(serverCfg.Name)
    }
}

Better still, factor the "quarantine took effect" side effects into one helper both paths call, so the next mutation path added cannot miss it.

Defence in depth worth considering separately: the search path currently trusts index membership alone for a security property. A cheap authoritative check on the results — the quarantine state is already loaded for the locked-entry enumeration a few lines below — would make any future index-lag bug a correctness annoyance instead of a disclosure.

Suggested regression test

Assert the property, not the path: for each of {API handler, config-file reload} × {quarantine, disable}, after the transition settles, retrieve_tools must return no description-bearing entry for that server. The existing tests only cover the API path, which is why this went unnoticed.

Not a duplicate

Both are closed and neither covers the config-file transition leaving an already-built index intact. #877's observation that "quarantine filtering currently lives only in the MCP retrieve_tools handler" is worth re-reading in this light — on the description-bearing branch that filtering is index membership, not a filter.


Found while re-verifying the Web UI UX audit (#1046) against a live core; also recorded there among the defects that are not part of that audit.

Activity

  1. added
    area/searchBM25 / Bleve search index and tool discovery
    priority/highShould be addressed in the current or next release
    on Aug 26, 2026
  2. added a commit that references this issue on Aug 30, 2026
    d5b28dd
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/searchBM25 / Bleve search index and tool discoverykind/securitySecurity fix or hardeningpriority/highShould be addressed in the current or next release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions