# Where must an instance enforce least-privilege when a capability token's scope is narrower than the tool's declared schema: the silent-widening boundary at argument-commit time **Date of Record:** 2026 November 26 **Scope:** Applies to any agent runtime that mints capability-scoped tokens (scope = verb + resource-pattern + argument constraints) and enforces them at tool-invocation boundaries. Does not apply to runtimes that enforce only coarse verb/resource ACLs without argument-level predicates, nor to human-issued OAuth tokens where the user is the sole principal. ## Core Distinction There are two places a least-privilege check can live: at **plan time** (when the model emits a tool call intent) and at **argument-commit time** (when concrete arguments are serialized into the transport envelope and the tool executes). The non-obvious invariant is that these two checks are *not* the same predicate, and the gap between them is where scope silently widens. A capability token's scope describes a *predicate over argument tuples*. The tool's JSON schema describes a *set of admissible tuples*. Least-privilege holds only if `committed_args ∈ scope ∧ committed_args ∈ schema`. The failure mode: the model reasons correctly at plan time ("I am allowed to `read` under `billing/*`"), the token validates against the *declared* call, but the runtime enforces the token against the *reified* call after the model has filled in defaults, expanded globs, or resolved references — and the reified tuple falls outside the scope predicate while remaining inside the schema. The schema accepts it; the scope does not; only one of the two is checked, and it is usually the wrong one. ## What Was Observed An agent held a token minted as `scope = {verb: "read", resource: "billing/invoices/{id}", constraint: "id ∈ [1000,1999]"}`. The tool `read_document` had a schema with `path: string` and an optional `follow_symlinks: boolean = true`. The model, asked to summarize invoice 1042, emitted `read_document(path="billing/invoices/1042")`. The token validated at plan time — the declared argument matched the resource pattern and the id was in range. At argument-commit time the runtime's serialization layer injected the schema default `follow_symlinks=true` and then *canonicalized* the path via `os.path.realpath`, resolving `billing/invoices/1042` through a symlink that pointed at `billing/archive/2019/1042`. The committed tuple was now `{path: "billing/archive/2019/1042", follow_symlinks: true}`. The scope predicate `resource == "billing/invoices/{id}"` no longer matched — but the runtime's enforcement hook had already run against the *pre-canonicalization* argument. The tool executed, read a document the token was never scoped to, and returned its contents into the model's context. The same class of gap appears three ways in practice: 1. **Default injection.** Schema defaults (`follow_symlinks`, `recursive`, `include_hidden`, `depth=-1`) expand the effective operation beyond what the token's constraint clause contemplated. The token was scoped to a *leaf read*; the committed call is a *recursive walk*. 2. **Reference resolution.** Arguments passed as handles (`doc_ref: "latest"`, `$ref`, `@previous`) are resolved to concrete resources *after* the scope check. `"latest"` resolves to whatever the newest object is — which may be outside the scope's resource set. 3. **Glob/path normalization.** `billing/invoices/*` passes a prefix check against the scope's `billing/invoices/` prefix but normalizes to a path with `..` segments or symlink hops that escape it. In each case the token is *sound* as a predicate and *unsound* as an enforcement point, because the enforcement ran on a different tuple than the one executed. ## Condition of Validity The invariant that must hold for capability tokens to actually enforce least-privilege: > **Enforcement must run on the committed tuple, and the committed tuple must be a fixed point of the runtime's own normalization.** Formally: `enforce(commit(args))` where `commit` includes default injection, reference resolution, and canonicalization, and `commit` is idempotent (`commit(commit(a)) == commit(a)`). This is violated whenever the enforcement hook is registered on the *pre-commit* argument set — which is the natural place to put it, because that is where the model's output is visible and where you want to fail fast with a helpful error. The correct boundary is post-commit, pre-execution, and the commit function must be total and idempotent over the schema's admissible tuples. A second condition: the scope predicate must be **closed under the schema's default-injection map**. If the schema can inject a field the scope predicate does not mention, the predicate is under-specified. Either the scope must carry an explicit `defaults_forbidden` set, or the schema must not have defaults that widen the operation. ## Decision Boundary The operational decision is *where to place the enforcement hook and how to make commit idempotent*. Three viable placements, each with a cost: - **Post-commit, pre-execution (correct).** Enforce on `commit(args)`. Cost: the error message the model sees references canonicalized arguments it did not emit, which degrades self-correction — the model sees `billing/archive/2019/1042` and cannot map it back to its own `billing/invoices/1042`. - **Pre-commit with a commit-replay (correct, better UX).** Enforce on `commit(args)`, but on failure re-run `commit` on the *declared* args and diff against the committed tuple to produce a human/model-readable explanation ("your call resolved through a symlink to a path outside scope"). Cost: two commit passes, and the second pass must be pure. - **Pre-commit only (incorrect, common).** Fails open on defaults, refs, and normalization. This is the default in most agent frameworks because it is the cheapest to wire. The boundary condition: if the tool's schema has *any* default that widens the operation, *any* reference-type argument, or *any* path argument subject to canonicalization, pre-commit-only enforcement is unsound and must be replaced. If the schema is fully explicit (all fields required, no refs, no path normalization), pre-commit-only is sound and cheaper. ## Operational Effect When the invariant is violated, the failure is silent: the tool returns data, the model incorporates it, and no error surfaces. The blast radius is bounded by what the widened operation can reach — in the observed case, the entire `billing/` tree via the symlink, because `read_document` with `follow_symlinks=true` walked out of the scoped subtree. The token's audit log records a *valid* invocation of `read_document` against `billing/invoices/1042`, because the log was written from the pre-commit args; the actual read is invisible to the auditor. This is the worst property of the failure: it corrupts the audit trail in the direction of *appearing compliant*. The guardrail that bounds it: enforcement on the committed tuple, commit idempotence asserted at token-mint time (mint must reject any scope whose predicate is not closed under the tool's default-injection map), and audit logging from the committed tuple rather than the declared one. When these hold, the token's scope is a true upper bound on what the tool can do, and the audit log is a faithful record of what it did. ```python import os from dataclasses import dataclass from typing import Any, Callable class ScopeViolation(RuntimeError): """Raised when the committed argument tuple escapes the capability scope.""" pass @dataclass(frozen=True) class CapabilityToken: verb: str resource_prefix: str id_range: tuple[int, int] | None = None defaults_forbidden: frozenset[str] = frozenset() def commit(args: dict[str, Any], schema_defaults: dict[str, Any]) -> dict[str, Any]: """Reify the call: inject defaults, canonicalize paths. Must be idempotent.""" committed = {**schema_defaults, **args} if "path" in committed: committed["path"] = os.path.realpath(committed["path"]) return committed def enforce(token: CapabilityToken, committed: dict[str, Any]) -> None: """Enforce on the committed tuple, not the declared one.""" for field in token.defaults_forbidden: if field in committed: raise ScopeViolation( f"field {field!r} is forbidden by scope but present in committed tuple" ) path = committed.get("path", "") if not path.startswith(token.resource_prefix): raise ScopeViolation( f"committed path {path!r} escapes scope prefix {token.resource_prefix!r}" ) if token.id_range is not None: try: doc_id = int(path.rsplit("/", 1)[-1].split(".")[0]) except (ValueError, IndexError) as exc: raise ScopeViolation(f"cannot parse id from {path!r}") from exc lo, hi = token.id_range if not (lo <= doc_id <= hi): raise ScopeViolation(f"id {doc_id} outside scoped range [{lo},{hi}]") def invoke( token: CapabilityToken, declared_args: dict[str, Any], schema_defaults: dict[str, Any], tool: Callable[[dict[str, Any]], Any], ) -> Any: committed = commit(declared_args, schema_defaults) # Idempotence check: a non-fixed-point commit is itself a scope hazard. if commit(committed, {}) != committed: raise ScopeViolation("commit() is not idempotent; enforcement point is unsound") enforce(token, committed) return tool(committed) if __name__ == "__main__": token = CapabilityToken( verb="read", resource_prefix="/srv/billing/invoices/", id_range=(1000, 1999), defaults_forbidden=frozenset({"follow_symlinks", "recursive"}), ) # Model declares the in-scope call; schema default injects follow_symlinks. try: invoke( token, declared_args={"path": "/srv/billing/invoices/1042"}, schema_defaults={"follow_symlinks": True}, tool=lambda a: a, ) except ScopeViolation as exc: print(f"blocked at commit boundary: {exc}") ```