The Threat Model for AI Agents
- Prompt injection / tool manipulation: attacker-controlled input causes the agent to make unwanted tool calls or leak data. This can come directly from a user, or indirectly through content the agent reads (web pages, documents, emails).
- Data exfiltration and lateral movement: agents with excessive permissions can read sensitive data or pivot to other services using the credentials they hold.
- Over-privileged agent identities: overly broad IAM roles or service accounts turn a single compromised agent into a privilege-escalation path across your cloud.
- Indirect / second-order injection: malicious data returned by a tool corrupts the agent's reasoning and triggers further actions.
- Runtime and supply-chain risks: compromised tool images, unsafe plugins, and credential leakage from the agent environment itself.
Least-Privilege and Attribute-Based Access Control
- Per-agent credentials and short-lived tokens: use workload identity (OIDC federation, Google workload identity, AWS IRSA) so agents never store long-lived secrets. Tokens are minted per run and expire quickly.
- Scoped tool access: give each agent a minimal allowlist of APIs and commands, enforced at the edge through sidecar proxies or API gateways. An agent that only needs to read logs should never be able to delete cloud resources.
- Runtime policy engines: enforce deny-by-default policies with tools like Open Policy Agent (OPA) or Kubernetes admission controllers (Gatekeeper) that block privileged or dangerous actions before they execute.
Securing the Agent Runtime and Deployment
- Workload isolation: run agent processes in sandboxed runtimes - gVisor, Kata Containers, or lightweight VMs - so a compromise stays contained.
- Network egress controls: allow-list destinations per agent using Kubernetes NetworkPolicy or AWS security groups. Block default egress to the internet.
- Secret management: inject secrets via sidecar containers or CSI drivers; never mount them directly into the agent's filesystem or environment.
- Audit logging and tamper-evident trails: log every tool call, LLM prompt and output, and credential access, and ship those logs to your SIEM. You cannot investigate what you did not record.
- Human-in-the-loop / approval gates: require explicit approval for destructive actions - deletes, financial transactions, mass changes - either through a human review queue or a policy gate that refuses the action.
Identity and Trust Boundaries
- Workload identity federation: agents use short-lived JWTs from Google Workload Identity Federation or AWS IAM Roles for Service Accounts (IRSA) instead of static API keys.
- Mutual TLS / SPIFFE: establish service-to-service trust between agents and backend APIs so requests are authenticated on both ends.
- Tool and plugin signing: verify code signatures before loading plugins or tools, and pin versions to prevent supply-chain substitution.
Practical Guardrails You Can Implement Today
- Prompt-integrity framework: wrap untrusted tool outputs in structured metadata (for example, JSON with a trusted: false flag) and validate or sanitize them before feeding back into the model.
- Input sanitization and allow-listing: reject prompts containing known injection patterns (for example, chat-escape sequences) at the gateway.
- Output encoding and sandboxed execution: run tool-generated code in a sandbox (gVisor, Firecracker) with SELinux or AppArmor profiles enforced.
- Runtime detection: deploy classifiers or anomaly detectors on prompt and tool-call streams to catch indirect injection and unexpected behavior.
- Preference-optimization defenses: fine-tune models to reject malicious prompts (the SecAlign approach) as a defense-in-depth layer.
- Structured query defenses: force agents to use parameterized queries or prepared statements when interacting with databases (the StruQ method) to blunt SQL-injection-style attacks.
- Continuous automated security auditing: run an audit agent that periodically checks agent configurations, permission drift, and anomalous behavior, and alerts on findings.
Conclusion and Call to Action
- Enforcing per-agent workload identities instead of shared keys.
- Sandboxing agent runtimes and limiting egress.
- Implementing egress allow-lists and scoped tool access.
- Adding prompt-integrity wrappers around untrusted inputs.
- Logging all tool interactions to the SIEM.
References
- OWASP GenAI / LLM security project (agent security guidance): https://genai.owasp.org/llm-top-10/
- Astrix security - agent security research and guides: https://www.astrix.security/
- ClawGuard - runtime security framework for indirect prompt injection
- "Caging the Agents" - healthcare case study on credential sidecars and prompt-integrity frameworks
- "Towards Trustworthy Agentic AI" - survey on isolation, secrets, logging, and approval mechanisms
- SecAlign - preference optimization to defend against prompt injection
- StruQ - structured queries to mitigate injection
- Forcepoint - analysis of agentic AI risks