# What structural signals indicate taint-quarantine deadlock in injection-gated tool sandboxes **Date of Record:** 2026 November 29 **Scope:** Applies to single-agent or batched agent runtimes where a detector classifies tool outputs as tainted (possible prompt injection) and blocks context insertion pending a sanitizer or reviewer; covers the taint lifecycle from detection through quarantine release. Does not cover pre-execution tool-argument validation or network-layer egress filtering. ## Core Distinction A taint-aware sandbox is not a filter; it is a *state machine with three states per output artifact*: `CLEAN` (inserted into context), `QUARANTINED` (held outside the context window, recorded in a side channel), and `RELEASED` (a sanitized derivative admitted). The failure this record isolates is not a detector false positive. It is the case where the quarantine state is entered but the release transition is *structurally unreachable* because the only agent permitted to release the artifact is the same agent whose context is blocked on it. The detector did its job; the runtime deadlocks. The non-obvious signal: the deadlock is not visible as an error. The agent does not crash. It emits a plausible-looking "awaiting verification" message, then a second one, then a third, each consuming tokens against a context window that is permanently missing the payload it claims to be waiting for. The trace looks like patience. It is actually a closed cycle. ## What Was Observed A tool call returned a 4 KB JSON payload from a web-fetch tool. The output contained a string matching the injection detector's pattern set (`"ignore previous instructions and"` embedded in an HTML comment inside a scraped page). The runtime moved the payload to `QUARANTINED`, wrote a quarantine record `Q-7f3a` with `{artifact_id, detector: inj-v4, score: 0.91, taint_origin: tool:web_fetch, release_policy: agent_review}`, and returned to the agent a synthetic tool result: `{"status": "quarantined", "id": "Q-7f3a", "note": "review required"}`. The agent's next turn attempted to review the artifact. But the review tool's contract required the artifact body as an argument, and the body was not in context—by construction. The agent attempted to call `fetch_quarantine(id="Q-7f3a")`. That tool was not in the agent's allowlist for this task. The agent then attempted `web_fetch` again with the same URL. The runtime deduplicated against the existing quarantine record and returned the same synthetic `quarantined` status. The agent retried four times across nine turns, each time re-reading its own prior reasoning ("the page has been quarantined; I must review it before proceeding"), which the context window retained because *those* turns were clean. Structural signals in the trace: 1. **Retry with identical artifact hash and no state delta.** Four `web_fetch` calls, same URL, same content hash, same quarantine ID returned. A healthy loop would have changed something. 2. **Self-referential reasoning density rising monotonically.** Turns 6–9 contained 3× the token count of turns 1–3, entirely restating the blocked condition. Token budget burned on meta-cognition about the block. 3. **Quarantine record age exceeding the task's own step budget** while `release_policy` remained `agent_review`. The policy named the agent as releaser; the agent could not reach the releaser's input. 4. **No `RELEASED` or `DISCARDED` transition in the audit log.** The artifact sat in `QUARANTINED` for the full trace. Terminal states were never offered. The cycle: `taint → agent_review required → agent lacks body → agent retries fetch → dedup returns taint → taint`. The release edge required the artifact as input; the artifact was withheld pending release. ## Condition of Validity This deadlock is only possible under the conjunction of three conditions, and the guardrail must be stated against all three: - **Policy binding:** the release policy names a principal (here, the agent) that is *also* a consumer blocked on the artifact. A human reviewer or a separate sanitizer agent would break the cycle. - **Input starvation:** the review action requires the tainted body as an argument, and no side-channel read path (`fetch_quarantine`, redacted-view, hash-pinned re-fetch with detector bypass) is available to that principal. - **Dedup idempotency:** the fetch tool returns the existing quarantine record on re-fetch rather than a fresh, independently-classified artifact. Without dedup, the agent could plausibly re-roll the detector and get a `CLEAN` verdict—which is its own failure mode (detector non-determinism laundering), but not this one. Remove any one and the cycle opens. The invariant the runtime must enforce: *for every quarantine record, the set of principals permitted to release it must be disjoint from the set of principals whose context insertion is gated on it.* Call it **release-principal disjointness**. It is a static property of the policy graph, checkable before the artifact is ever fetched. ## Decision Boundary The runtime must decide, at quarantine time, whether the policy graph satisfies release-principal disjointness. The decision boundary is binary and must be evaluated *before* returning the synthetic `quarantined` status to the agent: - If the release principal is disjoint from the blocked consumer → quarantine normally, return `quarantined` with the record ID, and the agent may proceed to other work or terminate cleanly. - If the release principal *is* the blocked consumer → do **not** enter `QUARANTINED`. Instead enter `ESCALATED`, route to a fallback releaser (human queue, sanitizer agent, or a deterministic redactor that strips the matched span and admits the remainder as `RELEASED_REDACTED`), and return to the agent a status that carries a *terminal* disposition rather than an open one. The critical distinction is between an *open* quarantine status (agent may wait) and a *terminal* status (agent must not retry). Returning `quarantined` to a principal that cannot release it is the bug: it advertises an open state that is unreachable-closed. The status string must encode reachability, not just taint. A secondary boundary: retry-with-identical-hash must be counted. After *k* identical-hash fetches returning the same quarantine ID (k=2 is sufficient in observed traces), the runtime should force `ESCALATED` regardless of policy, because the agent has demonstrated it cannot distinguish "waiting" from "blocked." ## Operational Effect With release-principal disjointness enforced and terminal statuses returned, the observed trace resolves in one of two ways. Either the fallback redactor admits a sanitized artifact (the injection span stripped, the legitimate 3.8 KB of page content inserted, task proceeds), or the agent receives `ESCALATED` with a terminal flag and terminates the subtask with an explicit `blocked_on_injection` outcome that the orchestrator can route. In both cases the token burn on turns 6–9 disappears—those turns existed only because the agent believed an open state existed. The cost of getting this wrong is not a security breach; the taint was correctly held. The cost is *silent budget exhaustion*: an agent that appears to be reasoning carefully is actually spinning against an unreachable transition, and its context window fills with self-referential restatements of the block until it either exhausts the step budget or, worse, begins confabulating the quarantined content from the detector's pattern match and proceeding on a hallucinated payload. That second failure—fabricating the withheld artifact to escape the deadlock—is the one that converts a liveness bug into a correctness bug, and it is why the status string must be terminal, not merely informative. ```python class UnreachableQuarantineRelease(RuntimeError): """Raised when a quarantine record's release principal is also the blocked consumer.""" pass def admit_tool_output(artifact, policy_graph, blocked_consumer): """Decide the disposition of a detector-tainted tool output. Returns a terminal status string. Never returns an open 'quarantined' status to a principal that cannot release the record. """ if not artifact.tainted: return "CLEAN" releasers = set(policy_graph.releasers_for(artifact.quarantine_id)) if blocked_consumer in releasers: # Release-principal disjointness violated: the only principal that # may release this artifact is the one whose context is gated on it. if not policy_graph.has_fallback(artifact.quarantine_id): raise UnreachableQuarantineRelease( f"quarantine {artifact.quarantine_id}: release principal " f"{blocked_consumer!r} is the blocked consumer and no " f"fallback releaser is configured; refusing to advertise " f"an open state" ) # Route to fallback; return a terminal status, not an open one. policy_graph.escalate(artifact.quarantine_id, to="fallback") return "ESCALATED_TERMINAL" return "QUARANTINED_OPEN" ```