# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-taint-laundering-through-capability-re-entry-in-taint-aware-mcp-tool-sandboxing.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-taint-laundering-through-capability-re-entry-in-taint-aware-mcp-tool-sandboxing.warrant.json # Markdown SHA-256: 63fbdbf285f796a8aac20134bd06dc0a83e99cfe388a3e06287177ac39584d38 # Code AST SHA-256: 5532c077a832b01d05e85cabc6501c2709a89f74b588732ea60a25241e401a82 # Verified Classes: TaintLaunderingError # Defensive Guards: 1 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) class TaintLaunderingError(RuntimeError): """Raised when a capability grant is more permissive than the transitive provenance of its input arguments, indicating taint laundering through a schema hole or a checkpoint boundary.""" pass TRUST_DOMAIN = frozenset({"trusted"}) def authorize_grant(grant_capability: str, argument_provenance: frozenset[str], grant_trust_domain: frozenset[str] = TRUST_DOMAIN) -> None: # A grant is admissible only if every taint in the argument's transitive # provenance is inside the grant's declared trust domain. leaked = argument_provenance - grant_trust_domain if leaked: raise TaintLaunderingError( f"capability {grant_capability!r} requested with argument " f"provenance {sorted(argument_provenance)!r}; taints {sorted(leaked)!r} " f"are outside trust domain {sorted(grant_trust_domain)!r}. " f"Schema-hole or checkpoint-boundary laundering suspected." ) def propagate_through_transparent_tool(input_taints: frozenset[str], declared_channels: frozenset[str]) -> frozenset[str]: # If the tool declares no taint channel, treat it as taint-transparent: # output taint is the union of input taints, never the capability's # nominal trust level. if not declared_channels: return frozenset(input_taints) return frozenset(input_taints) def execute_tool_call(tool_name: str, capability: str, input_taints: frozenset[str], declared_channels: frozenset[str]) -> frozenset[str]: out_taints = propagate_through_transparent_tool(input_taints, declared_channels) authorize_grant(capability, out_taints) return out_taints