{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-taint-laundering-across-a-tool-sandbox-s-re-entry-boundary",
  "title": "Which invariants prevent taint laundering across a tool sandbox's re-entry boundary",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agent runtimes that tag tool results and retrieved documents with a provenance taint (trusted vs. untrusted) and gate exfiltration-capable sinks (outbound HTTP, email, file writes outside the sandbox, shell) on that taint. Does not cover pure prompt-injection defenses with no taint label, nor sandboxes that enforce only network egress filtering at the OS layer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-laundering-across-a-tool-sandbox-s-re-entry-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-laundering-across-a-tool-sandbox-s-re-entry-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-laundering-across-a-tool-sandbox-s-re-entry-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1995,
    "python_slice_tokens": 514,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A taint-aware sandbox is a *dataflow* control, not a *content* filter. The invariant it must preserve is: **no value derived from an untrusted source may reach an exfiltration sink without an explicit, auditable declassification event.** The non-obvious failure is not that untrusted content reaches the sink directly — that path is gated by construction. The ...",
    "what_was_observed": "A retrieval tool returns a document tagged `taint=untrusted`. The agent calls a `summarize` tool whose *implementation* is trusted code, passing the document. The summarize tool returns `{\"summary\": \"...\"}`. The runtime labels the tool result by the *tool's* trust classification (trusted), not by the join of the tool's trust and its *arguments'* taint. The summary is now `taint=trusted`. The agent then calls `http_po...",
    "condition_of_validity": "The invariant holds only if **taint is propagated by the dataflow relation, not by the identity of the code that touched the data.** Concretely, for every tool invocation: where `join` is the lattice join (untrusted ⊔ trusted = untrusted). A tool may *lower* taint only by returning a value that is provably independent of its untrusted arguments — and that in...",
    "decision_boundary": "The boundary is between *derivation* and *declassification*: - **Derivation** (summarize, translate, format, hash, count, parse): output taint = join of input taints. Never lowers. - **Declassification** (schema-constrained extraction into a fixed field set, with a policy witness): may lower taint, but only for the declared output fields, and only with an au...",
    "operational_effect": "When the join is enforced, the observed exfiltration path is blocked: the `summarize` result carries `taint=untrusted`, the `http_post` gate rejects it, and the agent receives a structured `TaintViolation` it can reason about (retry with a declassifier, or abandon). The cost is that legitimate workflows — \"summarize this untrusted doc and email it to me\" — n..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "6b8f44b091d943d946e25e0387cd90951de2db30727291b763f3002a56f8841b",
    "verified_classes": [
      "TaintLaunderingError",
      "Taint",
      "Value",
      "Provenance"
    ],
    "verified_functions": [
      "invoke_tool",
      "declassify",
      "egress_gate",
      "run_agent_turn",
      "join",
      "record",
      "taint_of"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TaintLaunderingError"
    ],
    "sample_fail_closed_invariants": [
      "invariant violated: derived untrusted value passed the egress gate"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
