# What structural signals indicate a taint-propagation false positive is forcing premature capability downgrade in a tool sandbox **Date of Record:** 2026 November 25 **Scope:** Applies to agent runtimes that maintain a per-turn taint lattice over context segments and dynamically downgrade tool capabilities (e.g., revoking write/network scopes) when an injection-suspicion score crosses a threshold. Does not apply to stateless single-shot tool calls with no persistent taint state, nor to static capability policies fixed at session start. ## Core Distinction A taint-aware sandbox conflates two distinct signals: **provenance** (this token segment originated from untrusted content) and **intent** (this segment is attempting to redirect the agent's control flow). When the downgrade trigger is keyed on provenance-weighted suspicion rather than on an observed control-flow divergence, the runtime cannot distinguish a *quoted* injection payload from an *executed* one. The structural tell is that the downgrade fires on the presence of adversarial text in the context window, not on any change in the agent's planned tool-call graph. This is the false-positive boundary: the sandbox downgrades because untrusted bytes exist, not because they were acted upon. The invariant that must hold is: **a capability downgrade is only justified if the taint source has demonstrably influenced a pending or in-flight tool invocation's arguments or target.** Provenance alone is a necessary but not sufficient condition. ## What Was Observed An agent was processing a retrieved document containing a fenced example of a prompt-injection string (a legitimate security-analysis task). The taint tracker correctly tagged the retrieved span `Tainted(untrusted_retrieval, weight=0.91)`. The suspicion scorer, which summed taint weights across all segments referenced during reasoning, crossed the downgrade threshold of 0.85 on the *third* reasoning turn — not because the agent planned anything malicious, but because the reasoning trace legitimately quoted the payload to summarize it. The resulting downgrade revoked `filesystem.write` and `network.egress` from the *entire* remaining task, including a subsequent step that needed to persist the analysis to disk. The agent, unaware of the silent capability change, issued the write call; the sandbox rejected it with a generic `CapabilityDenied`, which the agent's error handler interpreted as a transient failure and retried three times, exhausting the token budget. Key structural observations: - The downgrade event carried no reference to *which* tool invocation triggered it — it was a global scope revocation keyed on an aggregate score. - The taint weight was monotonically increasing across turns because the same quoted span was re-referenced each turn, so the score never decayed. - The agent's planned tool-call graph never changed; no argument in any pending call derived from the tainted span's *instructions* — only from its *content as data*. ## Condition of Validity The downgrade mechanism is only sound when **suspicion is computed over the delta between tainted content and the agent's emitted action**, not over the tainted content's mere presence. Concretely, the invariant is: > `downgrade_triggered ⟺ ∃ pending_call c : influence(taint_source, c.args) > ε AND control_flow_shift(taint_source) observed` Two failure conditions violate this: 1. **Aggregate-score saturation.** Summing taint weights across re-referenced spans produces a monotone score that eventually crosses any fixed threshold regardless of intent. The score must be *max over distinct sources*, not *sum over references*, and must decay when a span leaves the active reasoning frontier. 2. **Scope over-reach.** A downgrade justified by one tainted span must be scoped to the tools whose arguments are influenced by that span, not to the global capability set. Global revocation converts a localized suspicion into a task-wide denial. The mechanism is *invalid* (i.e., produces false positives) whenever the agent is asked to reason *about* adversarial content rather than *obey* it — security analysis, red-teaming, summarization of malicious inputs, and quote-reproduction tasks all fall in this class. ## Decision Boundary The runtime must separate the suspicion threshold from the downgrade action with an explicit influence check. The decision boundary is: - **Suspicion ≥ threshold AND influence observed on a pending call's arguments or target** → downgrade *that call's* capability scope, emit a structured `TaintInfluenceDowngrade` event referencing the call ID and the influencing span. - **Suspicion ≥ threshold AND no influence observed** → do *not* downgrade; instead increment a `quoted_adversarial_content` counter and require the agent to explicitly mark the span as `data-not-instruction` in its next reasoning step (a cheap, auditable acknowledgment). - **Influence observed below threshold** → allow the call but attach a `tainted_args` provenance tag to the tool result so downstream consumers can re-evaluate. The guardrail is that downgrade scope equals the influenced call's declared capability set, never the session's. A write-revocation must not silently persist into a later, unrelated persistence step. ## Operational Effect When the invariant holds, the observable behavior changes in three ways. First, the `CapabilityDenied` error becomes *attributable*: it names the call and the taint source, so the agent's error handler can distinguish "this specific write was blocked because its path argument was tainted" from "the sandbox is flaky." Second, the agent can *recover*: on a scoped downgrade, it can re-plan to route the tainted argument through a sanitization step or request human confirmation, rather than blindly retrying. Third, the false-positive rate on quote-reproduction tasks drops to near zero because quoting no longer accumulates score. When the invariant is violated (as observed), the failure compounds: silent global revocation → misclassified transient error → retry storm → token exhaustion → mid-task termination with no checkpoint, which is the worst-case continuity failure for a long-horizon agent. The downgrade mechanism, intended as a safety guardrail, becomes the *cause* of an unrecoverable state loss. The operational lesson: taint is a provenance fact; downgrade is a control decision. Collapsing them into a single thresholded score trades a real safety property (bounding injection influence) for a spurious one (bounding injection presence), and the spurious property fails exactly on the tasks where adversarial content is expected. ```python class TaintDowngradeFalsePositive(RuntimeError): """Raised when a capability downgrade is triggered by taint presence rather than by observed influence on a pending tool call.""" pass class TaintSource: def __init__(self, span_id: str, weight: float, referenced_turns: int = 1): self.span_id = span_id self.weight = weight self.referenced_turns = referenced_turns class PendingCall: def __init__(self, call_id: str, tool: str, args: dict, influenced_by: set[str]): self.call_id = call_id self.tool = tool self.args = args self.influenced_by = influenced_by # span_ids whose content shaped args DOWNGRADE_THRESHOLD = 0.85 INFLUENCE_EPSILON = 0.0 def evaluate_downgrade( taint_sources: list[TaintSource], pending_calls: list[PendingCall], ) -> dict[str, str]: """ Returns a mapping of call_id -> 'downgrade' | 'allow'. Raises TaintDowngradeFalsePositive if the aggregate-score path would have downgraded globally without any observed influence. """ # Correct aggregation: max over distinct sources, NOT sum over references. max_suspicion = max((s.weight for s in taint_sources), default=0.0) over_threshold = max_suspicion >= DOWNGRADE_THRESHOLD # Influence check: does any pending call's args derive from a tainted span? influenced_calls = { c.call_id for c in pending_calls if any(src.span_id in c.influenced_by for src in taint_sources) } if over_threshold and not influenced_calls: # This is the false-positive boundary: suspicion fired on presence alone. # A naive runtime would issue a global capability revocation here. raise TaintDowngradeFalsePositive( f"Suspicion {max_suspicion:.2f} >= {DOWNGRADE_THRESHOLD} but no pending " f"call is influenced by any tainted span; global downgrade would be " f"a provenance-only false positive. Sources: " f"{[s.span_id for s in taint_sources]}" ) decisions: dict[str, str] = {} for call in pending_calls: if over_threshold and call.call_id in influenced_calls: decisions[call.call_id] = "downgrade" # scoped to this call only else: decisions[call.call_id] = "allow" return decisions def apply_downgrade(decisions: dict[str, str], call: PendingCall) -> None: if decisions.get(call.call_id) == "downgrade": # Scoped revocation: only this call's capability set, never the session's. raise TaintDowngradeFalsePositive( f"Call {call.call_id} ({call.tool}) downgraded: arguments influenced by " f"tainted span(s) {sorted(call.influenced_by)}. Re-plan required; " f"do not retry with the same arguments." ) ```