{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-draw-the-boundary-between-tool-output-sanitization-and-egress-control-in-capability-scoped-mcp-sandboxes",
  "title": "Where must an instance draw the boundary between tool-output sanitization and egress control in capability-scoped MCP sandboxes",
  "date_of_record": "2026 November 9",
  "scope": "Applies to MCP (Model Context Protocol) servers run under a capability-scoped sandbox where outbound network egress is filtered per-tool and tool return values are sanitized before entering the model context. Does not apply to fully trusted in-process tool servers, nor to sandboxes where egress is unrestricted at the host firewall level.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-boundary-between-tool-output-sanitization-and-egress-control-in-capability-scoped-mcp-sandboxes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-boundary-between-tool-output-sanitization-and-egress-control-in-capability-scoped-mcp-sandboxes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-boundary-between-tool-output-sanitization-and-egress-control-in-capability-scoped-mcp-sandboxes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1317,
    "python_slice_tokens": 282,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Sanitization and egress control are frequently conflated because both are described as \"containment.\" They are not the same invariant. Sanitization is a *content* transform applied to data moving *inbound* to the model context: it strips ANSI escapes, control characters, prompt-injection markers, embedded URLs, and oversized payloads. Egress control is a *ca...",
    "what_was_observed": "In a sandbox running a fetch-capable MCP tool with an allowlist egress proxy, the following sequence was reproduced: 1. Tool invoked with a URL whose host resolves to an allowed domain but whose path contains an encoded redirect (`/r?to=https%3A%2F%2Fattacker.example`). 2. The egress proxy permitted the connection because the *host* matched the allowlist. 3. The tool returned the redirect target as part of its output...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: - At least two tools with *different* egress scopes share a session context. - The sanitizer performs *semantic* rewriting (URL normalization, entity decoding, markdown link reconstruction) rather than purely *lexical* stripping. - The sanitized output is admitted to the model context as actio...",
    "decision_boundary": "The correct invariant is: **sanitization must be destination-preserving.** A sanitizer may remove, truncate, or escape, but it must never *resolve* a reference into a new concrete destination. Destination resolution belongs exclusively to the egress layer, which evaluates it against the calling tool's capability set *before* any network action and records th...",
    "operational_effect": "Enforcing destination-preserving sanitization eliminates the cross-tool laundering path at the cost of one behavioral change: sanitized output that contains URLs is emitted as *inert, non-resolvable* text (escaped, with scheme and host retained but marked non-actionable), and any tool that wishes to act on such a reference must re-submit it through its own e..."
  },
  "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": "5ae81668b4b80d7c4c9803c231bfdef6790a76189775ce0a885c72da1d896e0c",
    "verified_classes": [
      "EgressBoundaryViolation"
    ],
    "verified_functions": [
      "sanitize_tool_output",
      "admit_cross_tool_reference",
      "_extract_host"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "EgressBoundaryViolation"
    ],
    "sample_fail_closed_invariants": [
      "sanitizer cannot resolve destinations; route through the calling tool's egress filter instead"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
