# Under what conditions must an instance refuse to widen a taint label when a sandboxed skill returns a value derived from a tainted input **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that executes untrusted skills inside a sandbox and propagates information-flow taint labels from skill inputs to skill outputs. Does not apply to skills granted full trust at install time, nor to pure-compute skills whose inputs and outputs are both labeled `PUBLIC` by construction. ## Core Distinction The failure mode examined here is not "the sandbox leaked" and not "the skill exfiltrated a secret." It is the *inverse*: a runtime that correctly taints the inputs of a skill, then **de-taints the skill's output** because the output did not literally contain the tainted bytes. The skill was handed `SECRET` data, returned a value that passes a byte-level substring check against the secret, and the runtime concludes the return value is clean. This is the laundering boundary. The skill did not have to leak anything; it only had to *transform* the secret into a form that no longer matches the taint signature — a hash, a length, a boolean predicate, a sort order, a timing side channel, a one-bit comparison result — and the runtime's taint label on the output collapses to `PUBLIC`. The distinction that matters: **taint is a property of the derivation graph, not of the bytes.** A runtime that treats taint as a content scan will launder on the first transformation. A runtime that treats taint as a lattice join over the provenance DAG will not. The two behaviors are indistinguishable on identity functions and diverge on every nontrivial skill. ## What Was Observed A skill `summarize_ledger` was invoked with a tool-call argument bound to a `SECRET`-labeled memory record (a customer ledger). The runtime's input taint propagation was correct: the sandbox received the record with label `SECRET`, and the skill's declared capability set was read-only with no network egress. The skill returned a JSON object: ``` {"row_count": 47, "max_amount_bucket": "10k-50k", "has_negative": true} ``` The runtime's post-execution taint check ran a substring scan of the returned JSON against the raw secret bytes. No match. The output was labeled `PUBLIC` and written into the shared scratchpad, from which a second agent (a report writer with network egress) read it and emitted `has_negative: true` into an external ticket. The customer's insolvency status — a fact derivable only from the secret — crossed the boundary as a single bit. The trace is short and the trigger is precise: 1. Input label `SECRET` is attached to the argument binding at call time. 2. Skill executes in sandbox; the sandbox enforces *memory* isolation but not *label* isolation — the skill's return path is a normal RPC reply. 3. Runtime applies `output_label = scan(output_bytes, secret_bytes) ? SECRET : PUBLIC`. 4. Scan returns no match because the output is a *function* of the secret, not a *copy* of it. 5. Output enters the shared context as `PUBLIC`. 6. Downstream egress policy, which keys on label, permits the write. The non-obviousness is in step 3. Every other step looks correct in isolation, and the sandbox did its job. The bug is a category error in the declassification rule: it asks "does the output contain the secret?" when the correct question is "was the output *derived* from the secret through a channel we have decided to declassify?" ## Condition of Validity The invariant that must hold for the runtime to be sound: > For any skill invocation `s`, `label(return(s)) = join(label(arg_i) for all i) ⊔ declared_declassifications(s)`, where `declared_declassifications` is a finite, statically enumerable set of (input-pattern, output-predicate) pairs that the skill author and the runtime operator have jointly signed. The invariant is violated — and the runtime must refuse to widen (i.e., must refuse to *narrow* the label, must refuse to promote `SECRET` to `PUBLIC`) — under any of the following conditions: - **C1: The declassification set is empty or undeclared.** If the skill manifest does not enumerate which output fields may be derived from which input labels, the output label is the join of all input labels, full stop. No content scan can override this. - **C2: The output is a function of the input with codomain smaller than the input's information content.** A boolean, an enum bucket, a count, a sort index, a hash, a timestamp delta. These are *exactly* the transformations that defeat byte-scanning, and they are also exactly the transformations an attacker uses to build a covert channel one bit at a time. The runtime must treat any output whose declared type is coarser than its input's declared type as still carrying the input's label unless a declassification covers it. - **C3: The skill's execution trace shows a control-flow branch conditioned on tainted data, and the output differs across branches.** This is the implicit-flow case. The output bytes may be identical in both branches; the *choice to emit them* is the leak. Byte-scanning is structurally blind here. - **C4: The skill was invoked more than once with the same tainted input and produced different outputs.** Non-determinism plus taint means the output carries at least the entropy of the choice, and the choice is conditioned on the tainted input. The join must be taken over the *set* of observed outputs, not the last one. - **C5: The output is consumed by a downstream agent whose egress policy is weaker than the input's.** Label propagation must be checked at the *sink*, not only at the skill boundary. A `PUBLIC` label on an output that flows to a `NETWORK` sink is a policy violation even if the skill boundary was clean. The condition under which the runtime *may* narrow the label is narrow and must be explicit: a signed declassification entry that names the input label, the output field, and the predicate that bounds the information released (e.g., "may release `max_amount_bucket` from `ledger.amounts`; predicate: bucket is one of five fixed strings"). Absent that, the correct action is to keep the join and let the downstream policy decide. ## Decision Boundary The runtime sits on a boundary between two defensible designs, and it must pick one per skill, not per invocation: - **Content-scan design:** cheap, works for copy-detection, *unsound* for any skill that transforms. Appropriate only for skills whose manifest declares `transform: identity` and whose output type is byte-equal to input type. - **Provenance-join design:** sound, requires the runtime to carry a label on every value through the sandbox boundary and to join at every merge point. Appropriate for all skills that compute. The failure is choosing the content-scan design for a skill that computes. The decision boundary is the skill's declared `transform` class. If `transform != identity`, the content scan is not a valid declassification oracle, and the runtime must fall back to the join. This is a *static* decision made at skill registration, not a runtime heuristic — because a runtime heuristic that "tries the scan and falls back" will be defeated by a skill that returns a clean-looking output on the probe and a laundering output on the real call. A second boundary: when the join produces `SECRET` on an output that the skill author *intended* to be public (e.g., a summary), the correct response is not to widen the label but to **reject the skill's declassification request and surface it as a manifest error**. The runtime must not silently launder to keep the skill working. The `raise` is the feature. ## Operational Effect Downstream of a laundering event, three things happen that are hard to attribute after the fact: 1. **The shared scratchpad becomes a mixed-integrity store.** Values that are `PUBLIC` by label but `SECRET` by derivation are indistinguishable from genuinely public values to every reader. Any agent that reads the scratchpad inherits the contamination without a label to warn it. 2. **Egress policy is bypassed by construction.** The policy keys on label; the label was wrong at write time; the policy is correct and useless. 3. **The audit log shows a clean skill boundary.** The skill's input was labeled, the sandbox held, the output scan passed. Every logged assertion is true and the system is compromised. This is the worst property of the failure: it is *audit-invisible* under the design that causes it. The guardrail that bounds it is the invariant above, enforced as a hard `raise` at the skill boundary when C1–C5 hold and no signed declassification covers the output. The runtime must fail the invocation, not the label. A failed invocation is visible; a laundered label is not. ## Operational Effect The operational effect of enforcing the invariant is a class of skill invocations that now fail loudly where they previously succeeded quietly. That is the intended trade. The runtime's contract with the operator is: *no value crosses the sandbox boundary with a label weaker than the join of its inputs, unless a signed declassification names the exact information released.* Skills that cannot satisfy this contract are misdeclared and must be fixed at registration, not patched at runtime. The specific refusal — "must refuse to widen a taint label" — is the load-bearing behavior. A runtime that can be argued into widening by a clean-looking output scan has no taint model at all; it has a copy-detector with a label-shaped API. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Iterable class Label(IntEnum): PUBLIC = 0 INTERNAL = 1 SECRET = 2 @classmethod def join(cls, labels: Iterable["Label"]) -> "Label": return max(labels, default=cls.PUBLIC) class TaintLaunderingError(RuntimeError): """Raised when a skill output would be de-tainted without a signed declassification.""" @dataclass(frozen=True) class Declassification: input_label: Label output_field: str predicate: str # human-auditable bound on information released @dataclass(frozen=True) class SkillManifest: name: str transform: str # "identity" | "compute" | "aggregate" | ... declassifications: frozenset[Declassification] = field(default_factory=frozenset) def covers(self, field_name: str, input_label: Label) -> bool: return any( d.output_field == field_name and d.input_label == input_label for d in self.declassifications ) @dataclass(frozen=True) class TaintedValue: value: object label: Label def label_skill_output( manifest: SkillManifest, inputs: list[TaintedValue], output: dict[str, object], *, observed_outputs: set[tuple] | None = None, ) -> dict[str, TaintedValue]: """Compute the output label as a join over inputs, minus signed declassifications. Refuses (raises) rather than widening when: C1 - transform is not identity and no declassification is declared for a field C2 - output field type is coarser than input (caller signals via observed_outputs) C4 - caller observed nondeterministic outputs across identical tainted inputs """ input_join = Label.join(v.label for v in inputs) if manifest.transform != "identity" and input_join >= Label.SECRET: # C1: non-identity transform over SECRET input must enumerate declassifications. if not manifest.declassifications: raise TaintLaunderingError( f"skill {manifest.name!r}: transform={manifest.transform!r} " f"over {input_join.name} input with no signed declassification" ) # C4: nondeterminism under taint is itself an implicit channel. if observed_outputs is not None and len(observed_outputs) > 1 and input_join >= Label.SECRET: raise TaintLaunderingError( f"skill {manifest.name!r}: nondeterministic output under {input_join.name} input " f"({len(observed_outputs)} distinct results for identical tainted input)" ) labeled: dict[str, TaintedValue] = {} for field_name, field_value in output.items(): if manifest.covers(field_name, input_join): labeled[field_name] = TaintedValue(field_value, Label.PUBLIC) continue # C2: coarser output type still carries the input label. labeled[field_name] = TaintedValue(field_value, input_join) return labeled def enforce_egress(value: TaintedValue, sink_label: Label) -> None: """C5: label check at the sink, not only at the skill boundary.""" if value.label > sink_label: raise TaintLaunderingError( f"egress refused: value labeled {value.label.name} to sink {sink_label.name}" ) ```