Technical Article

Security and Least Privilege in Tool Calling

Giving an AI agent access to tools does not magically turn a hazardous operation into a safe one. When a model is empowered to query, transmit, mutate, delete, or execute system commands, every invocation carries a blast radius that the hosting architecture must explicitly constrain.

Tool calling must be treated as a hardened API boundary, governed by strict input schemas, authentication, authorization, and rate limits. The fact that an LLM generated an intent to invoke an action does not grant it the authority to decide whether that action is permissible.

Decoupling Intent from Authority

This architectural separation decouples intent from authority in the agent runtime. The language model merely proposes a candidate next step; the execution harness enforces least privilege, sanitizes and validates parameters, verifies tenant boundaries at runtime, and rejects any operation that exceeds granted privileges.

Risk-Tiered Policies and Idempotency

Operational impact should dictate security policy. Reading data is not equivalent to mutating it, writing is not equivalent to deleting, and irreversible operations should require explicit human-in-the-loop approval. Furthermore, state-changing actions must mandate idempotency keys to guard against accidental duplicate execution during retries.

Defending Against Prompt Injection at the Boundary

Indirect prompt injection stems from the same security model failure. Malicious instructions embedded in retrieved documents, external webpages, or third-party tool outputs may manipulate model attention, but they must never be allowed to escalate privileges or bypass guardrails enforced by the host execution boundary.

Verifiable Boundaries over Model Goodwill

Reliable agents never rely on the premise that a model will simply "behave." They depend on scoped tools with minimal capabilities, validated inputs, external tool outputs treated as untrusted data, and explicit validation gates prior to high-impact actions—granting autonomy only within verifiable, deterministic boundaries.