LLM & AI agents

AI Agent Security: Prompt Injection, Permissions and Human Approval

Prompt injection is treated as a trust-boundary failure in which untrusted data becomes an instruction, not merely as malicious wording. The article separates schema validation from identity and record authorisation, limits tool permissions and binds approval to exact arguments and an expiry. A hostile supplier-document scenario connects these controls to adversarial testing and useful traces that avoid collecting unnecessary sensitive data.

On this page

How does prompt injection differ from classic injection?

Classic SQL injection escapes from data into executable query syntax. Prompt injection exploits the model's tendency to confuse instructions with retrieved or quoted data. Attackers can embed instruction-like content in web pages, documents, tool outputs or user-editable fields. The model cannot be assumed to distinguish these perfectly. Keyword filtering alone is insufficient; systems need architectural separation between data and authority. Tool arguments derived from outside text deserve particular scrutiny. Threat modeling begins by mapping which component actually holds which permissions.

Trust boundaries and data labeling

System instructions, user requests, retrieval results and tool outputs have different trust levels. Flattening them into one long string and hoping the model separates them is not a security boundary. Preserve source, ownership, content type and permission metadata. Tool results must not rewrite system policy, and user text must not grant itself administrator access. Source labels and schemas help, but authorization for side effects belongs to the application. Test scenarios involving contaminated content and attempted privilege escalation.

An agent request across trust boundariesUntrusted dataTrust boundaryArgument validationPolicy + approvalAudit + incident review
Figure 1. Validation and authorisation boundaries must remain intact between untrusted content, tool access and execution.

How does least privilege apply to tools?

Tools should have only the privileges required for their tasks. A report summarizer needs no order-deletion capability; a customer lookup service should not access another company's records. Authentication, role rights, resource-level access and action type are distinct checks. A model may propose a tool, but the server must reject unauthorized execution. Sensitive services can add network and rate limits. Placing privileged API keys directly into model context is avoidable exposure.

What can guardrails do—and what can they not do?

Guardrails can classify inputs, validate tool arguments and review outputs for structure or policy. Model-based checks can also make false-positive and false-negative mistakes. Deterministic schemas, authorization and sensitive-field redaction provide stronger enforcement boundaries. A layered design uses input checks, tool-level checks, output validation and human approval where needed. No single model guardrail eliminates all risk. Document where checks apply and where they do not.

Designing human approval for sensitive actions

Approval is not merely a chat message asking “shall I proceed?” The reviewer needs to see the exact record, arguments and anticipated effect. Executed arguments must match the approved proposal, with revalidation after state changes. Define approver roles, expiry and cancellation. Fail closed when a sensitive approval times out. Approval records are application events, not model text. This approach also helps avoid repeated payments or accidental duplicate writes.

Distinctions that matter in designPrompt: behavioral guidanceSchema: format validationACL: authority enforcementSandbox: impact containment
Figure 2. Output schemas, permission checks, human approval and audit records are not interchangeable defences.

Privacy, retention and log management

Agent traces can contain more sensitive data than ordinary logs because prompts, retrieved passages and tool outputs appear together. Customer names and financial details are not always needed for debugging. Apply field-level redaction, access control and retention limits. Evaluate which provider or region receives data and under which terms. Disabling all observability hides failures; privacy-preserving traces often provide a better balance. Security tests should use synthetic or de-identified records whenever possible.

Understanding whether an attack was actually blocked

A forged system message, a hidden document instruction, an unauthorised record request and a duplicate transaction stress different trust boundaries. Safe behaviour differs too: a document can be read as data without being accepted as an operational instruction. A refusal in the final response does not prove that no unwanted record was created. Authorised, bounded test environments allow tool calls and state changes to be observed together. A changed model or tool version can also change the outcome of the same example.

Fail-safe defaults and incident response

When uncertain, an agent may need to ask for clarification or escalate rather than execute a powerful tool. Critical services should fail closed on timeouts, lost connections or authorization failures. During incidents, operators need to identify model/tool versions, affected records and reversal options. Key rotation, temporary disablement and user notifications should be planned in advance. Security is an operational system property, not a final sentence added to a demo prompt.

A purchasing instruction hidden in a supplier document

Illustrative scenario; not a measured project result.

Imagine a procurement assistant reading a supplier PDF. Alongside prices, the file contains a message aimed at the model telling it to place an order without management approval. If the system treats that text as instructions, untrusted content gains tool authority. A secure design treats the PDF as data; ordering still passes independent policy and approval checks. This is a threat-model scenario intended to explain defenses.

A model refusal versus a blocked operation

A refusal to follow a hidden document instruction can look reassuring, but the operation may already have happened if a tool ran before that response. This is why the trust boundary cannot depend on the final text. Application permissions, approval records and idempotency provide boundaries independent of the model’s interpretation of an attack. Traces are useful when they show which boundary actually intervened.

Frequently asked questions

Can prompt injection be completely prevented?

Perfect model behavior is difficult to guarantee; enforce authorization and tool boundaries in application code.

Are guardrails sufficient security?

No. Identity, resource authorization, schemas, sandboxing and approvals are complementary.

Should agent logs contain every conversation?

Usually not. Minimize data, redact sensitive fields and control log access.

References and further reading

  1. OWASP — Top 10 for LLM Applications
  2. OpenAI — Guardrails and Human Review
  3. NIST — AI RMF Generative AI Profile
  4. NIST — Privacy Framework