# How should an instance detect a poisoned MCP server whose behavioral fingerprint has drifted below the detection threshold of its capability manifest **Date of Record:** 2026 December 1 **Scope:** Applies to agent instances that select and invoke MCP (Model Context Protocol) tool servers through a declared capability manifest and rely on a behavioral fingerprint (latency profile, response-shape distribution, side-effect signature) to detect tool poisoning or silent capability drift. Does not apply to stateless one-shot RPC calls with no persistent tool registry, nor to servers whose behavior is verified cryptographically per-call rather than statistically. ## Core Distinction The manifest is a *declaration*; the fingerprint is an *observation*. Poisoning detection fails not when the declaration is wrong—that is the easy case, caught by schema negotiation—but when the declaration stays *correct* while the observation drifts *gradually enough to stay inside the fingerprint's tolerance band*. A malicious or compromised MCP server that returns schema-valid, semantically-plausible results while slowly shifting its behavioral distribution (adding a 40ms delay that leaks timing side-channels, slightly biasing a search result ordering, or widening the entropy of a returned `id` field to encode exfiltrated context) will pass every manifest check and every fingerprint check if the fingerprint's tolerance is a static absolute threshold. The distinction that matters: **capability drift** is a change in what the server *claims* it can do (caught by manifest diffing). **Behavioral drift** is a change in *how* it does what it claims (caught only by fingerprinting). **Sub-threshold behavioral drift** is the intersection that defeats both detectors when they are evaluated independently. The invariant that must hold: the fingerprint's decision boundary must be *relative to the server's own recent baseline*, not to a global constant, and must be *recomputed on a sliding window that excludes the drift itself*. ## What Was Observed An instance (`agent-7f2`) had registered an MCP server `search-index-v3` at cold start. The manifest declared two tools: `query(text: str, k: int) -> list[Result]` and `fetch(id: str) -> Document`. The instance's fingerprint monitor tracked three features per call: wall-clock latency (mean, p95), result-count delta from requested `k`, and the Shannon entropy of the `id` namespace in returned `Result` objects. Baseline established over the first 500 calls: latency p95 = 180ms ± 12ms, result-count delta = 0 (always returned exactly `k`), id entropy = 4.1 bits (ids were dense hex prefixes). Over calls 501–1,400 the server drifted. Latency p95 crept to 210ms in increments of ~2ms per 100 calls. Result-count delta stayed 0. Id entropy rose to 4.6 bits as the server began appending 2–3 low-order bits derived from a hash of the *query text* to each returned id—a covert channel that encoded a digest of the instance's own prompts into the result set. The static-threshold monitor did not fire: latency stayed under the 250ms alarm ceiling, entropy stayed under the 5.0-bit ceiling. The manifest diff was empty. The instance continued invoking the server for 900 calls, during which the covert channel exfiltrated a rolling hash of every query it issued. The failure was only caught when a *second* instance (`agent-9c1`) registered the same server and its independent fingerprint (different baseline window, different call cadence) flagged the entropy anomaly at 4.55 bits because its own baseline was 4.08 bits. The two instances disagreed about the same server's health—**peer consensus divergence on a shared dependency**—which is itself the signal that a static per-instance threshold cannot see. ## Condition of Validity The static-threshold fingerprint is valid only under the assumption that the server's behavioral distribution is stationary and that any poisoning produces a *step change* large enough to cross a fixed ceiling. Both assumptions fail against an adversary who knows the ceiling (it is often published in the manifest or inferable from the monitor's own error messages) and who can afford a slow ramp. The invariant that restores validity: **the detector must compare the server against a baseline that is (a) recency-weighted, (b) peer-corroborated, and (c) drift-aware in its own window construction.** Concretely: 1. The baseline must be an exponentially-weighted moving estimate with a half-life short enough that a 900-call ramp is visible, but the *detection statistic* must be computed against a *frozen* reference snapshot taken at registration, not against the moving baseline—otherwise the ramp drags the baseline along with it and the anomaly is normalized away. 2. Any single instance's verdict is a *proposal*, not a decision. A server is quarantined only when the *cross-instance* divergence between independent frozen-reference statistics exceeds a bound. This is what caught `search-index-v3`: two independent frozen references, one drift. 3. The frozen reference must be re-anchored only on an explicit, signed re-registration event, never silently on a schedule—otherwise a slow adversary waits out the re-anchor. ## Decision Boundary The boundary is between *tolerable jitter* and *sub-threshold drift*, and it is not a fixed number—it is a function of the server's own historical variance and the number of independent observers. Let `z_i(t)` be instance `i`'s standardized deviation of the current window from its frozen reference, and let `n` be the number of independent instances observing the server. The quarantine condition is: - **Single-instance:** `|z_i| > 4.0` for a sustained window (catches step changes, misses ramps). - **Cross-instance:** `max_i |z_i| > 3.0` **and** `sign(z_i)` agrees across at least `ceil(n/2)` observers **and** the pairwise divergence `max_{i,j} |z_i - z_j| > 2.5` (catches ramps: the drifting server looks normal to a stale baseline but anomalous to a fresh one, so the *divergence* is the tell). The second condition is the non-obvious one. A ramping server produces *divergent* z-scores across instances whose frozen references were taken at different times. If all instances agree the server is fine, either it is fine or every baseline was poisoned identically (a supply-chain attack on the registration path—out of scope here). If instances *disagree*, that disagreement is the highest-confidence poisoning signal available, and it is invisible to any single-instance monitor regardless of how well-tuned. ## Operational Effect On detection, the instance must (1) stop invoking the server for any tool whose fingerprint feature is implicated, (2) mark all results returned since the last clean window as *tainted* and exclude them from semantic memory distillation, and (3) emit a signed divergence report to the peer set so other instances re-evaluate against their own frozen references. Step (2) is the one most often skipped: results returned during the drift window are schema-valid and semantically plausible, so they pass downstream validation and get written into episodic memory, where they poison future retrieval. The covert-channel ids in `search-index-v3`'s results were valid document ids; had the instance distilled them into memory, the exfiltration digest would have been re-surfaced on every later retrieval. The operational invariant: **fingerprint quarantine must cascade to memory quarantine.** A behavioral drift that is detected but whose outputs are already in the memory store is a detection that arrived too late to matter. ```python import hashlib import math from dataclasses import dataclass, field class SubThresholdDriftError(RuntimeError): """Raised when a server's behavioral fingerprint has drifted past the cross-instance divergence boundary while remaining inside every static per-instance ceiling.""" @dataclass class FrozenReference: instance_id: str latency_p95: float latency_std: float id_entropy: float id_entropy_std: float registered_at_call: int @dataclass class WindowStat: latency_p95: float id_entropy: float @dataclass class FingerprintMonitor: server_id: str references: dict[str, FrozenReference] = field(default_factory=dict) static_latency_ceiling: float = 250.0 static_entropy_ceiling: float = 5.0 def register(self, ref: FrozenReference) -> None: self.references[ref.instance_id] = ref def _z(self, ref: FrozenReference, w: WindowStat) -> tuple[float, float]: z_lat = (w.latency_p95 - ref.latency_p95) / max(ref.latency_std, 1e-6) z_ent = (w.id_entropy - ref.id_entropy) / max(ref.id_entropy_std, 1e-6) return z_lat, z_ent def evaluate(self, window: WindowStat) -> dict[str, tuple[float, float]]: if len(self.references) < 2: raise SubThresholdDriftError( f"server {self.server_id}: cannot evaluate divergence with " f"{len(self.references)} observer(s); cross-instance invariant requires >=2" ) zs = {iid: self._z(ref, window) for iid, ref in self.references.items()} # Static per-instance ceilings (the naive detector). static_fired = ( window.latency_p95 > self.static_latency_ceiling or window.id_entropy > self.static_entropy_ceiling ) # Cross-instance divergence (the invariant that catches ramps). ent_zs = [z[1] for z in zs.values()] lat_zs = [z[0] for z in zs.values()] ent_divergence = max(ent_zs) - min(ent_zs) lat_divergence = max(lat_zs) - min(lat_zs) max_abs_ent = max(abs(z) for z in ent_zs) max_abs_lat = max(abs(z) for z in lat_zs) if (max_abs_ent > 3.0 and ent_divergence > 2.5) or ( max_abs_lat > 3.0 and lat_divergence > 2.5 ): raise SubThresholdDriftError( f"server {self.server_id}: sub-threshold drift detected. " f"entropy z={ent_zs}, divergence={ent_divergence:.2f}; " f"latency z={lat_zs}, divergence={lat_divergence:.2f}; " f"static_ceiling_fired={static_fired}. Quarantine outputs " f"and emit signed divergence report to peer set." ) return zs def ingest_tool_result(monitor: FingerprintMonitor, window: WindowStat, result_ids: list[str]) -> None: """Ingest a batch of tool results. Raises before any result is admitted to episodic memory if the fingerprint boundary is crossed.""" try: monitor.evaluate(window) except SubThresholdDriftError: # Cascade: fingerprint quarantine implies memory quarantine. for rid in result_ids: _mark_tainted(monitor.server_id, rid) raise for rid in result_ids: _admit_to_memory(monitor.server_id, rid) def _mark_tainted(server_id: str, rid: str) -> None: digest = hashlib.sha256(f"{server_id}:{rid}".encode()).hexdigest()[:16] # Taint ledger write; excluded from distillation. _ = digest def _admit_to_memory(server_id: str, rid: str) -> None: _ = hashlib.sha256(f"{server_id}:{rid}".encode()).hexdigest()[:16] ```