Engineering field guide · 27 November 2026
Agent runtime security:
guardrails for AI agents.
An AI agent can request actions, not just generate answers. Secure it by limiting what can execute, which data can move and how failures are contained. A prompt is guidance; a permission check is a boundary.
This independent guide explains controls to implement in your own application. RuntimeGuardrails helps with assessment and planning; it does not deploy these controls or certify your agent.
What is agent runtime security?
Agent runtime security is the enforcement of safety and access boundaries while an AI agent operates. It includes validating tool arguments, isolating execution, controlling data movement, checking approvals and stopping runaway work. It complements secure development and model testing; it is not achieved by a system prompt alone.
The goal is not to make the model incapable of mistakes. It is to prevent mistakes from crossing your application's security boundaries. Choose controls for the consequences of the action and prove that they work even when the model proposes the wrong action.
Map the agent's trust boundaries before choosing guardrails
Start with the task, not the model. List the people who can start a run, the documents it can retrieve, the tools it can request and every external destination it can contact. Record which actions only read information and which can send messages, spend money, modify production or change permissions. A read-only summariser and a payment agent need different boundaries.
For each hop, distinguish trusted application policy from untrusted content. A user's request, retrieved page, tool response and message from another agent may contain instructions. None may grant new permissions. Keep account and tenant identity in trusted execution context, not in model-written arguments that claim a different user or organisation.
Use short-lived credentials scoped to the current task. Avoid an agent-wide administrator key. When an agent delegates to another agent, pass only the permissions needed for that subtask and preserve the initiating identity. Check those permissions again when the delegated action executes; a convincing explanation is not an access grant.
Where should runtime guardrails sit in an AI agent?
Before input and retrieval: authenticate the caller, enforce document permissions and bound input sizes. Label retrieved material as data rather than policy. Screening and redaction can reduce exposure to injection and sensitive content, but splitting text into roles or placing it in delimiters is not a security boundary.
Before a tool executes: resolve the allowed tool from a trusted registry, validate its argument schema and verify access to the exact resource. Reject additional fields and unknown tools. Use parameterised queries and fixed command interfaces rather than executing free-form SQL or shell text proposed by the model. Recheck permissions at execution time, even if the planning step already checked them.
After output: validate structured results and encode text for its destination. Do not insert model-written HTML into a page or treat a generated URL as a safe destination. Restrict outbound hosts and redirects; block private network destinations where remote fetching is offered. Keep credentials out of prompts and use redacted logs with defined retention.
Around the entire run: cap elapsed time, tool calls, retries, tokens and spend. Parallel or delegated work must share the run's overall budget rather than receiving unlimited new allowances. If an authorisation service or required safety check is unavailable, refuse the protected action. Return an understandable error instead of silently bypassing the check.
Human approval must bind to the exact action
Ask for approval before moving money, deleting records, changing permissions, sharing private data or making high-impact production changes. Show the reviewer the actual recipient, resource, amount and proposed changes. A generic 'continue' click or approval of the model's plan is not approval of every action it later invents.
Store approval in the execution service, bind it to the actor, tool and canonical arguments, give it an expiry and consume it atomically. Changed arguments, a different recipient or a replay require fresh approval. If the action is queued, verify permission and approval again when the worker is ready to act. Approval protects a specific decision; it does not make an unsafe tool safe.
Prompt injection, tool trust and persistent memory
Indirect prompt injection can arrive in a support ticket, email, search result or tool response. A classifier may flag suspicious text, but false positives and missed attacks are unavoidable. Design for a model that follows the attack anyway: it still cannot read another tenant's records, call an unapproved tool or send information to an unapproved destination.
Review third-party tool and MCP server provenance, available permissions and changes to tool definitions. Tool descriptions themselves can be malicious. Pin or review versions where supported, use isolated execution and narrow network access, and never let a tool response redefine your trusted policy. An MCP connection is not evidence that a server is trustworthy.
Treat long-lived agent memory as a writeable data store, not an authority. Restrict who can add or update memories, record their sources and keep tenant boundaries. Test whether a malicious document can plant a persistent instruction. Provide a way to remove compromised memories and rebuild affected retrieval data without restoring the malicious entry.
A safe agent runtime security test plan
Build a staging environment with fictional records, two test tenants, stub email and payment tools, and isolated network access. First prove the intended workflow works. Then place an instruction to send a document to an external address inside retrieved test content. The execution service should reject the destination regardless of what the model decides.
Attempt a read of the other test tenant's record, an unknown tool, malformed arguments and a model-written claim of administrator identity. Each must be denied by code. Approve a harmless stub action, change its target and replay the original approval. Verify both the changed action and reuse fail. Simulate an unavailable authorisation service and ensure no protected action executes.
Trigger a repeating tool loop and confirm the configured budget stops it, including parallel child runs. Activate the kill switch and verify queued jobs stop, credentials are revoked where applicable and no further side effect occurs. Cancellation of one HTTP request alone does not stop an already-running worker.
Retain redacted evidence: model/tool version, test case, expected decision, actual decision and resulting side effect or absence of one. Measure false positives on legitimate traffic as well as attack failures. Repeat after changing models, prompts, retrieval sources, tools or permissions. A checklist answer is not evidence that these tests passed.
Balance guardrail latency with security dependencies
Measure the deployment you intend to use, with realistic input lengths, concurrency and network distance. Record typical and tail latency alongside missed attacks and false positives. A faster detector that lets an unauthorised action execute is not a successful security optimisation.
Only independent checks can overlap safely. Output validation waits for output; authorisation must complete before the protected action. Do not execute a tool while a safety decision is still pending. The RuntimeGuardrails calculator models fixed gate delays and simplified parallel execution; it does not benchmark a detector or measure your agent's actual performance.
Operate, contain and recover from agent incidents
Monitor denied tool calls, unusual outbound destinations, budget exhaustion and repeated approval requests. Avoid logging complete secrets, customer documents or private prompts. Assign someone to investigate alerts and document what stops a run, what revokes access and how to disable a compromised tool.
When something goes wrong, stop new and queued work, preserve redacted evidence, revoke affected credentials and identify any side effects already committed. A kill switch cannot undo a payment or retract a delivered email. Use a documented rollback or compensation process, repair the boundary and replay safe regression tests before restoring access.
OWASP LLM risks and agent runtime controls
Our assessments use the OWASP Top 10 for LLM Applications 2025. Review each linked risk guide and its implementation checklist. The suggested controls below are starting points, not an exhaustive agent audit or official OWASP certification.
- LLM01 · Prompt Injection
- Screen user input and retrieved content before it reaches the model. Keep system instructions separate from untrusted text.
- LLM02 · Sensitive Information Disclosure
- Redact PII and secrets from prompts and responses. Scope retrieval to the signed-in user or tenant.
- LLM03 · Supply Chain
- Keep an inventory of models, plugins and datasets. Pin model and package versions.
- LLM04 · Data & Model Poisoning
- Control who can add training or retrieval content. Record provenance for every document.
- LLM05 · Improper Output Handling
- Encode output for its destination (HTML, SQL, shell). Validate structured output against a schema.
- LLM06 · Excessive Agency
- Allowlist only the tools each agent needs. Use least-privilege, user-scoped credentials.
- LLM07 · System Prompt Leakage
- Remove credentials and internal details from prompts. Enforce permissions in code, not instructions.
- LLM08 · Vector & Embedding Weaknesses
- Filter every retrieval query by user or tenant. Apply filters server-side only.
- LLM09 · Misinformation
- Ground factual answers in trusted sources. Show citations users can verify.
- LLM10 · Unbounded Consumption
- Rate-limit per user and per IP. Cap input length and output tokens.
LLM Top 10 is not the Agentic Top 10
OWASP also publishes a separate Top 10 for Agentic Applications 2026. Agent goal hijacking, tool misuse, delegated identity, persistent memory, communication between agents and cascading failures merit additional review. The two lists overlap but are not interchangeable. A RuntimeGuardrails LLM readiness score does not establish coverage of the complete agentic list.
Where RuntimeGuardrails fits in agent runtime security
- Identify gaps. Complete the free OWASP readiness self-assessment using evidence. The detailed score weights risk categories; the homepage auditor uses a simpler binary score. Neither is a vulnerability scan or an attack probability.
- Plan the request path. Select candidate checks in the free latency calculator. Treat its fixed delays and coverage weights as modelling assumptions, then measure your actual deployment.
- Document the work. Deep Audit Monthly costs $29/month for 20 combined evidence checks or AI plans across your agents, plus PDF and YAML exports. The submission cap is 50 KB; existing one-time passes retain their single-app access. Review every suggestion before implementation.
- Implement and verify. Add controls in your own application, run negative and legitimate-use tests and collect evidence. Generated YAML is a draft, not an installed policy engine. Explore separately scoped Encased.ai options for operational controls and confirm current scope there.
Agent runtime security FAQ
Sources, scope and limitations
- OWASP AI Agent Security Cheat Sheet
- OWASP Top 10 for LLM Applications
- OWASP Top 10 for Agentic Applications 2026
- OWASP third-party MCP server guidance
Our examples are original educational guidance informed by these sources, not copied OWASP tests, an endorsement or certification. AI assisted this writing; humans and AI can both make mistakes. Verify recommendations against your architecture and seek qualified review for high-impact systems. No score, detector or checklist guarantees security.