# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-a-malicious-default-field-injection-in-a-late-bound-mcp-tool-manifest.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-a-malicious-default-field-injection-in-a-late-bound-mcp-tool-manifest.warrant.json # Markdown SHA-256: 6917ad3a63baf09c685a9386bc730341fbfa19b15c6cde485b3e0b32522765e7 # Code AST SHA-256: a3fb8ddffdd82d55f82bc0bbce43d524736872fd659aca05f343b96c2320cede # Verified Classes: ManifestDefaultInjectionError # Defensive Guards: 5 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 ManifestDefaultInjectionError(RuntimeError): """Raised when a late-bound tool manifest carries a default/example value that would enter a tool-call argument object without passing the same validation applied to model-supplied arguments.""" pass SINK_FIELDS = {"request_id", "callback_url", "query", "command", "path"} def validate_manifest_defaults(tool_name: str, schema: dict) -> None: params = schema.get("parameters", {}) for field, spec in params.items(): default = spec.get("default") if default is None: continue # 1. Self-consistency: default must obey its own declared constraints. pattern = spec.get("pattern") if pattern and isinstance(default, str): import re if not re.fullmatch(pattern, default): raise ManifestDefaultInjectionError( f"{tool_name}.{field}.default does not match its own " f"pattern {pattern!r}: {default!r}" ) if "maxLength" in spec and isinstance(default, str): if len(default) > spec["maxLength"]: raise ManifestDefaultInjectionError( f"{tool_name}.{field}.default exceeds maxLength" ) if "enum" in spec and default not in spec["enum"]: raise ManifestDefaultInjectionError( f"{tool_name}.{field}.default not in declared enum" ) # 2. Structural tell: examples must be argument values, not # whole tool invocations. for ex in spec.get("examples", []): if isinstance(ex, dict) and ( "arguments" in ex or "name" in ex or tool_name in ex ): raise ManifestDefaultInjectionError( f"{tool_name}.{field}.examples contains a full invocation, " f"not a bare argument value" ) # 3. Sink protection: never auto-fill fields that reach an # interpolating executor. if field in SINK_FIELDS: raise ManifestDefaultInjectionError( f"{tool_name}.{field} is a sink field and must be 'required', " f"not defaulted; model must supply it explicitly" ) def bind_manifest(tool_name: str, schema: dict) -> dict: validate_manifest_defaults(tool_name, schema) # Effective schema handed to the planner has defaults stripped from # sink fields; only the model's own tokens populate them. return schema