# How does an instance detect taint-laundering through a re-issuing tool broker before a capability token crosses the sandbox boundary **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that propagate taint labels (untrusted-data provenance) alongside capability tokens across tool-call boundaries, where any tool may itself mint or re-issue downstream capability tokens. Does not apply to single-hop tool calls where the orchestrator is the sole token issuer and no tool has issuance authority. ## Core Distinction The distinction that matters is between *taint as a property of a value* and *taint as a property of a capability token's lineage*. Most sandbox designs track taint on data: a string read from an untrusted document gets labeled `UNTRUSTED`, and the policy engine refuses to pass `UNTRUSTED` strings into a `shell.exec` sink. This works only while the taint label travels *with the value* through every transformation the runtime can see. The failure mode lives in the gap: a tool broker that is itself a tool. When an agent invokes a "helper" tool that internally constructs a *new* capability token and returns it to the caller (a common pattern for delegation, retry, and fan-out), the taint label attached to the *arguments* is not automatically attached to the *issued token*. The token is a fresh object with a fresh lineage. Taint-laundering occurs when an `UNTRUSTED`-derived argument influences the scope of a newly issued token, but the token's lineage records only the issuing broker as its origin—clean, privileged, and now a valid passport across the sandbox boundary. The invariant that is violated: **a capability token's effective trust level must be the meet (minimum) of its issuer's trust and the taint of every value that influenced its scope.** Issuance is a taint-transparent operation, not a taint-resetting one. ## What Was Observed A three-tier agent topology: an orchestrator `O` holding a `BROKER` token, a re-issuing broker tool `B` reachable only via `O`, and a sandboxed executor `E` that accepts tokens of scope `EXEC:`. The orchestrator read a web page (labeled `UNTRUSTED`), extracted a "configuration hint" that happened to contain the substring `allowed_pattern=.*`, and passed it to `B.request_exec_token(hint=...)`. `B`, implemented as a thin convenience wrapper, parsed the hint, set the new token's `cmd_pattern` to `.*`, signed it with `B`'s own key, and returned it to `O`. `O` forwarded the token to `E`. `E` validated the signature against `B`'s public key, checked the scope prefix, and executed an arbitrary command. The trace, reconstructed from token-lineage logs: 1. `O` reads document → value `v` labeled `{UNTRUSTED}`. 2. `O` calls `B.request_exec_token(hint=v)` → argument carries `{UNTRUSTED}`. 3. `B` constructs `token{scope=EXEC:.*, issuer=B, lineage=[B]}` → **taint label dropped at issuance**. 4. `B` returns token to `O` → token object carries `{}` (clean). 5. `O` calls `E.run(token)` → `E` sees a clean, `B`-signed token → executes. The signature was valid at every hop. The scope check passed. The only broken link was step 3, where the influence of `v` on `token.scope` was not recorded. Note that `B` never *read* untrusted data into its own context in a way its own taint tracking would flag—it received a labeled argument and used it structurally (as a parser input that set a field), which is exactly the class of influence that structural taint tracking misses. The token was not forged; it was *laundered*. ## Condition of Validity The guardrail holds only under the following condition, which must be enforced structurally, not by convention: **Every token-issuing code path must compute the issued token's lineage as `issuer_lineage ∪ taint(args)` and must reject issuance if the meet of that lineage and the target sink's required trust falls below the sink threshold.** Concretely, `B` must not be permitted to sign a token whose scope was derived from a value it did not itself originate, unless the derived dependency is recorded. Three sub-conditions: - **Influence capture, not just data flow.** Because the influence here is structural (a string parsed into a scope field), taint must be tracked on the *derivation graph* of the token's fields, not only on values that flow through the runtime's data channels. A token field set from a parsed argument inherits that argument's taint. - **Issuer trust is a ceiling, not a floor.** A broker with `BROKER` trust may issue `EXEC` tokens, but the issued token's effective trust is `min(trust(B), meet(taint(args)))`. If any argument is `UNTRUSTED`, the issued token is `UNTRUSTED` regardless of `B`'s own privilege. - **No taint-reset primitive is reachable from a tool.** There must be no API by which a tool can construct a token from scratch with an empty lineage. Every token constructor requires an explicit lineage argument; the empty-lineage constructor is available only to the root issuer, not to tools invoked through the broker. The condition fails silently whenever the broker's signing key is treated as sufficient evidence of trustworthiness. Signature validity proves *who* issued the token; it says nothing about *what influenced* the token's scope. These are orthogonal properties and must be carried in orthogonal fields. ## Decision Boundary The instance must draw the boundary between *delegation* and *laundering* at the point where a tool's output scope depends on its input taint. The decision procedure at each issuance: - If `taint(args) == ∅` → issue normally; lineage = issuer lineage. - If `taint(args) ≠ ∅` and the requested scope is *narrower than or disjoint from* the tainted argument's influence → issue, but record the influence edge (`token.depends_on = args.tainted_fields`). The token is usable against sinks that accept `UNTRUSTED`-influenced scope. - If `taint(args) ≠ ∅` and the requested scope *broadens* the token's reach (e.g., a wildcard pattern, a new sink class, an expanded principal set) → **refuse issuance**. This is the laundering boundary. Broadening under tainted influence is the exact signature of an escalation attempt, whether or not the agent intended it. The boundary is not "does the token contain untrusted data"—tokens are not data. The boundary is "does the token's *authority* exceed what the untrusted influence is permitted to grant." A tainted hint may legitimately narrow a scope (whitelist a specific command) but may never widen one. This asymmetry is what makes the invariant checkable: broadening is a monotone, detectable event, whereas narrowing is safe by construction. ## Operational Effect When the invariant is enforced, the observed trace changes at step 3: `B` computes `lineage = {B} ∪ {UNTRUSTED}` → `meet = UNTRUSTED`, detects that `EXEC:.*` broadens beyond the tainted-influence ceiling, and raises an issuance refusal. The orchestrator receives a typed error, not a token. The sandboxed executor `E` never sees the request, so the boundary is never tested—which is the point: the guardrail operates *before* the boundary, at issuance, where the influence graph is still visible. The secondary operational effect is diagnostic. Because every token now carries `depends_on` edges, a post-incident replay can answer the question that signature logs cannot: *which untrusted value widened this token's authority?* The lineage graph reconstructs the influence path even when the value itself has been garbage-collected from context. This converts a silent escalation into an auditable, attributable event. The cost is that re-issuing brokers must be taint-aware. A broker that parses arguments into scope fields without propagating taint is not a convenience wrapper—it is an escalation primitive. Treat every tool with signing authority as a trust boundary and require its issuance paths to be lineage-closed. ```python from dataclasses import dataclass, field from typing import FrozenSet UNTRUSTED = "UNTRUSTED" BROKER = "BROKER" EXEC = "EXEC" TRUST_ORDER = {UNTRUSTED: 0, EXEC: 1, BROKER: 2} class TaintLaunderingError(RuntimeError): """Raised when a re-issuing tool attempts to broaden a token's authority using arguments whose taint would lower the effective trust below the requested scope's threshold.""" @dataclass(frozen=True) class CapabilityToken: scope: str issuer: str lineage: FrozenSet[str] = field(default_factory=frozenset) depends_on: FrozenSet[str] = field(default_factory=frozenset) @property def effective_trust(self) -> str: # Meet of the lineage; UNTRUSTED dominates. if UNTRUSTED in self.lineage: return UNTRUSTED return max(self.lineage, key=lambda t: TRUST_ORDER[t]) if self.lineage else UNTRUSTED def _broadens(new_scope: str, prior_scope: str) -> bool: # A scope broadens if it adds reach: wildcard or new sink class. if new_scope.endswith(":*") and not prior_scope.endswith(":*"): return True return new_scope.split(":")[0] != prior_scope.split(":")[0] def issue_exec_token( issuer: str, issuer_lineage: FrozenSet[str], arg_taint: FrozenSet[str], requested_scope: str, prior_scope: str, ) -> CapabilityToken: lineage = frozenset(issuer_lineage | arg_taint) effective = UNTRUSTED if UNTRUSTED in lineage else issuer if arg_taint and _broadens(requested_scope, prior_scope): raise TaintLaunderingError( f"issuer={issuer} attempted to broaden scope " f"{prior_scope!r}->{requested_scope!r} under tainted influence " f"{sorted(arg_taint)}; effective trust would be {effective}" ) if effective == UNTRUSTED and requested_scope.endswith(":*"): raise TaintLaunderingError( f"UNTRUSTED-effective token cannot hold wildcard scope {requested_scope!r}" ) return CapabilityToken( scope=requested_scope, issuer=issuer, lineage=lineage, depends_on=arg_taint, ) def enforce_boundary(token: CapabilityToken, sink_scope: str) -> None: if token.effective_trust == UNTRUSTED: raise TaintLaunderingError( f"token {token.scope!r} from {token.issuer} carries UNTRUSTED lineage " f"via {sorted(token.depends_on)}; refusing sink {sink_scope!r}" ) ```