A browser agent is summarizing a forum thread when a comment tells it to use the reader's signed-in accounts and share sensitive information. Agentic AI security limits what the agent can access if it follows an instruction like this. This guide explains the threats and shows how to apply five controls using Vercel features and application code.
Copy link to headingWhat is agentic AI security?
Prompt injection can make a text-only chatbot produce misleading or harmful output. A compromised agent can also take actions, such as reading an inbox or opening a pull request, in response to untrusted content.
Agentic AI security is about protecting AI systems that plan multi-step tasks, call tools, keep memory across sessions, and run code. It covers where instructions come from, which credentials the agent holds, where its data can go, and how its actions are recorded. AI agent governance defines who owns the agent, which actions need approval, and how often to review them.
Copy link to headingWhat are the differences between traditional AI security and agentic AI security?
An agent can affect any system its tools and credentials can reach. When assessing risk, look at what the agent can access as well as what it can say.
Here's how text-only applications and tool-using agents differ:
The agent's identity and where it can send data help determine how much damage an injection can do.
Copy link to headingWhy does agentic AI security matter?
Four risks explain why an agent's access matters:
Excessive agency: The Open Worldwide Application Security Project (OWASP) identifies Excessive Agency as a risk for large language model (LLM) applications. It arises when an application gives a model more capabilities, permissions, or autonomy than the task requires.
Inherited authority: An agent that follows an injected instruction acts with whatever access it already has: its own credentials, a shared service account, or a user's signed-in session.
Data exfiltration: A hijacked agent can run code or transfer sensitive data if its tools and permissions allow it.
Persistent attack success: In a public red-teaming competition analyzed by the National Institute of Standards and Technology (NIST), more than 250,000 attempts produced at least one successful attack against every frontier model tested.
To limit the damage, start by identifying where untrusted input enters the agent.
Copy link to headingCore components of agentic AI security
OWASP's agentic Top 10 groups threats into ten categories. The next three sections focus on risks builders can address.
Copy link to headingPrompt injection and tool misuse
Prompt injection exploits applications that process untrusted input alongside trusted instructions, such as the system prompt. Direct injection arrives in the user's prompt, while indirect injection appears in retrieved pages, files, issues, and emails. Instruction roles help the model distinguish different kinds of input. The application still has to authorize sensitive actions.
A successful injection can make the agent use tools for actions outside its task. A code tool may execute unauthorized code, and a fetch tool may make requests to internal services, a risk known as server-side request forgery (SSRF). Enforce limits on code execution and network access outside the model.
Copy link to headingAgent identity and excessive privileges
A service account or dedicated agent identity represents software. An API key is one credential the software can use to authenticate. An agent may end up with separate credentials for email, repositories, and payments. Those credentials may sit in environment variables or never expire.
In a confused deputy attack, an injection tricks an agent with broad permissions into taking an unauthorized action. The attacker doesn't need the credentials. What the agent can do depends on what those credentials allow. For example, bind a support agent's tool to the customer the server has authorized for that request. The model doesn't choose whose records the tool reads.
Copy link to headingMemory poisoning and multi-agent propagation
Memory poisoning inserts untrusted content into an agent's long-term memory or retrieval store, where the agent may read it again in a later session. An attacker doesn't need direct write access if the agent saves user-influenced content without first checking it.
Agents can also pass poisoned content to one another. In a research demonstration, the Morris II worm spread a self-replicating prompt through retrieval-augmented email assistants, causing them to send spam and expose personal data. Retrieved memory can influence later decisions, so treat it as untrusted input.
Copy link to headingAttack chains and the controls that break them
In the browser example, access to signed-in accounts and the ability to publish without confirmation let the agent act on an untrusted comment.
At each step, a control outside the model can interrupt the attack:
If one control fails, the next can still limit the damage. The practices below build on that idea.
Copy link to heading5 agentic AI security best practices for production teams
Agent builders enforce some of these controls in application code. Platform engineers enforce others in the runtime.
Copy link to headingRun agent code in isolated sandboxes
Generated code can access whatever the process running it can access, including any production secrets that process can read. Run generated code in an environment separate from production. Standard containers share the host kernel. Firecracker microVMs give each workload a separate guest kernel, while gVisor's application kernel handles system calls in user space and limits direct access to the host kernel. Measure the startup time and memory usage of your workload before choosing an isolation layer. Notion Workers each run in a separate Vercel Sandbox microVM in production. The Sandbox firewall can attach API credentials to outbound requests without exposing the keys to Worker code.
Copy link to headingScope credentials to short-lived, least-privilege tokens
Long-lived integration keys can keep their permissions long after a task ends. Least privilege means granting only the access a task needs, for only as long as it needs it. If the provider supports scoped tokens, issue a separate token at runtime for each downstream API and let it expire. Each integration needs its own grant, but separate grants reduce the need for long-lived keys.
Copy link to headingLimit network egress to approved destinations
Egress is outbound network traffic. Deny outbound traffic by default, allowing only the destinations the agent needs. An approved service can still receive sensitive data, so pair an outbound network policy with scoped credentials. The Model Context Protocol (MCP) security guidance describes egress proxies and blocking private and link-local addresses for server-side clients. Check both the hostname and the address it resolves to so the policy applies to the destination the client reaches.
Copy link to headingRequire human approval for high-risk actions
Payments, deletions, outbound email, and production deploys can be costly or impossible to undo, so let a person approve or deny them. Use AI SDK's toolApproval setting to require review before a sensitive tool runs. If the approval goes through the client, check on the server that the reviewer has permission. Use experimental_toolApprovalSecret to sign the approval request and bind it to the tool call. Vercel Workflows can pause the run until a reviewer responds or the review window closes. Reserve prompts for actions that need a person's judgment.
Copy link to headingLog every tool call and send records off the runtime
Model logs alone can't establish what an agent did. Have the application record the run ID, tool name, authorization decision, approver when applicable, destination, and outcome. Keep only the input and output fields you need to investigate an incident. Follow OWASP's logging guidance to redact sensitive values before logging. On Pro and Enterprise, Vercel Drains can send tool events from your deployment's runtime logs to a restricted external destination. AI Gateway traces cover model requests. Your application still has to log what its tools did.
Copy link to headingHow Vercel helps secure agentic AI in production
Vercel can isolate code, limit access, and protect endpoints. Your application decides which tool calls to allow, which need approval, and what to log.
Copy link to headingVercel Sandbox isolates agent code and its network
The microVM isolates the process. Its network policy and the credentials it can access determine what it can reach. Vercel Sandbox runs each workload in a Firecracker microVM. The Sandbox firewall allows public internet access by default. Configure deny-all or an allowlist before running untrusted code. HTTPS domain rules match the hostname in the Transport Layer Security (TLS) handshake. If the HTTP destination must match the allowed hostname, use a firewall rule that pins the HTTP Host header.
Keep keys out of environment variables the code can read. Use HTTP header injection to attach them to matching outbound requests. Sandboxes persist by default. Their filesystem snapshots can outlive the sandbox, so set a retention policy for them.
Copy link to headingVercel Connect and OIDC keep provider keys out of agent code
Agents that call Slack or GitHub need provider credentials. Vercel Connect gives agents short-lived access to supported providers without putting provider secrets in the project's environment variables. It also supports compatible OAuth MCP servers. Depending on the connector, you can make requests as an app, a user, or a federated identity. Request the narrowest scopes the provider supports. Each connector's Observability tab records token requests, authorizations, and revocations.
Connect uses Vercel's OpenID Connect (OIDC) tokens to authenticate callers. OIDC tokens for preview and production functions expire after two hours. For external trust policies, validate the issuer and audience, and restrict the sub claim to the intended project and environment.
Copy link to headingAI Gateway centralizes model access, budgets, and retention controls
If each agent uses separate provider keys, you have to track spend, logs, and retention terms across providers. AI Gateway gives you one endpoint for models from multiple providers. Vercel deployments can authenticate with OIDC instead of an API key. Request logs include status, provider, token usage, cost, and routing attempts. AI Gateway does not retain prompts or responses, and its tools can group requests by client session.
AI Gateway budgets can apply to a team, project, API key, or member. These are soft caps. Once spend reaches an applicable limit, new requests return HTTP 402. Provider charges for bring-your-own-key (BYOK) don't count toward the budget. The BYOK-without-fallback fee does.
Eligible teams can enable zero data retention (ZDR) per request or team-wide. With ZDR enabled, the gateway uses only eligible routes, including fallbacks. It rejects the request if none are available. Short-lived provider prompt caching can still apply. See how a secure AI gateway applies data retention rules when routing across providers.
Copy link to headingWAF and BotID protect agent endpoints from abuse
Use Vercel WAF custom rules and rate limits to block abusive requests before they trigger inference costs. Both are available on all plans. The OWASP core ruleset is available on Enterprise and on Pro Priority projects.
Vercel BotID pairs an invisible client-side challenge with a server-side checkBotId() verdict. To protect a route in production, declare the route and method in the client protect list, then use the verdict to decide whether to call the model. A legitimate session can still carry untrusted content, so enforce tool permissions separately.
Copy link to headingShip secure agents on Vercel
Assume an agent will sometimes follow an injected instruction. Run untrusted code in a sandbox where it can't read secrets, give the agent credentials that expire, and restrict network access to the destinations the task needs. Choose controls based on what the agent can access and change.
Use these Vercel features alongside your application's authorization and tool-call logging:
Vercel Sandbox: Runs generated code in a microVM with a
deny-allor allowlist policy and firewall-injected credentials.Vercel Connect and OIDC: Vercel Connect brokers runtime tokens, and OIDC lets you scope trust policies to the expected
subclaim.AI Gateway: Applies budgets to in-scope requests and restricts model routing when you enable ZDR.
WAF and BotID: Rate-limit agent routes and screen inbound requests before the model call.
Vercel Drains: Forward tool-call events from your application's runtime logs to an external destination.
Explore the eve Software Factory template. The implementer writes and tests code in a sandbox. An unattended run stops at a draft pull request. A person approves it, marks it as ready, and performs the merge.
Copy link to headingFrequently asked questions about agentic AI security
Copy link to headingHow do you secure MCP servers and tool connectors?
Securing an MCP server starts with token handling. The MCP security guidance prohibits token passthrough. The server must check that it is the intended recipient of the token and use a separate credential for downstream calls. Install servers from trusted sources, pin reviewed tool definitions where possible, and treat tool inputs as untrusted. For example, the Connect release announcement shows how to give an AI SDK agent read-only Linear access on behalf of a specific user.
Copy link to headingWhich frameworks cover agentic AI risks?
OWASP's Top 10 lists for LLM and agentic applications, plus its MCP Top 10, help teams identify threats. Its Securing Agentic Applications guide explains how to put controls in place. NIST's AI Risk Management Framework helps teams organize governance and document risk decisions.
Copy link to headingCan prompt injection be fully prevented?
No general-purpose mitigation guarantees protection against prompt injection. Adaptive attacks have bypassed published defenses. Research designs that separate the processing of untrusted content from the planner with access to privileged tools may reduce exposure, but can also limit which tasks the agent can finish.
Copy link to headingHow do you test an AI agent for prompt injection?
Test the full agent and its tools in an isolated environment with synthetic data and test accounts. Check that the application blocks and logs actions outside the user's request, such as attempts to read test secrets or send synthetic data to unauthorized destinations. The Generative AI Profile from NIST places red-teaming under the Measure function.