AWS Security Blog

Securely exposing Amazon Bedrock AgentCore Runtime

Amazon Bedrock AgentCore Runtime delivers a secure serverless environment to deploy AI agents and tools at scale. When you start talking to your agent, the runtime launches a dedicated isolated session that runs in its own dedicated microVM with a completely sandboxed CPU, memory, and filesystem allocation. This provides strict data governance, helps to prevent cross-tenant data leakage, and preserves context while isolating stateful reasoning from external sessions.

To govern access control across these environments, Amazon Bedrock AgentCore Identity provisions distinct workload identities to let your agents run. By federating directly with an OpenID Connect identity provider like Amazon Cognito, Okta, or others, the users can only see and interact with agents they’re authorized to use.

But securing the runtime alone doesn’t protect the ingress path perimeter. When you expose your agent to users through a web or mobile application, the AWS Shared Responsibility Model dictates that you should provide a dedicated access layer that enforces tight control over the origin and intent of every request before any traffic reaches the runtime.

The access layer acts as a trusted bridge to authenticate each incoming request, enforce authorization rules, preserve user identity through the request lifecycle, and securely channel all user traffic into the isolated runtime.

This post walks through two architectures for securing access to AgentCore Runtime and provides guidance to help you decide which architecture best fits your organization.

Why propagating identity is important

In an agentic workflow, downstream data access should remain tied to the invoking user’s identity, and each segment in the execution chain is permissioned only for the immediate next hop. Using a single static credential, even one linked to the original requester, grants every immediate component identical, broad access. This directly violates the principle of least privilege, because the ingress gateway, the proxy, and the agent’s tool execution context each require only enough permission to reach the next component.

Recent real-world incidents have demonstrated that agentic workloads can bypass internal prompt guardrails, escape the software sandboxes, and abuse static credentials to move across applications and layers. In a multi-chain agentic architecture, scoping each hop as tightly as possible is key to preventing these exploits.

However, long-running, unattended execution poses a fundamental identity challenge for extended agentic workloads. If an agent runs a complex task that takes hours, the user’s interactive session will expire before the workload ends, making their short-lived OAuth 2.0 access token invalid mid-execution. Refreshing the tokens won’t solve this problem and storing a long-lived, user-scoped credential inside the agent’s runtime environment might reintroduce exactly the broad, standing credential attack surface that the zero-trust architectures are intentionally designed to mitigate.

To mitigate this, identity propagation acts as a critical bridge between authentication at the perimeter and authorization at the data layer. The agent must operate within the invoking user’s authorization scope. Every session receives a short-lived, user-scoped token that provides only the permissions granted to that specific user and authorization is enforced at each hop. If any single segment is compromised, then the exposure is contained in that hop scope. This security model also strengthens a continuous verification process where the tokens are validated at every hop from the ingress endpoint through AgentCore to the downstream resource, so no segment operates with unverified or elevated privileges.

Protecting AgentCore Runtime: What does it need?

We explained in the previous section why identity must follow the user through every hop. However, identity propagation alone isn’t enough to secure the ingress path; it must be integrated within a broader set of ingress controls that together protect the path into the runtime.

AgentCore Runtime provides infrastructure isolation, per session microVMs, per session tool registration, and enforces the application of Amazon Bedrock Guardrails. These features and resources protect the execution environment. However, they don’t control who reaches the runtime, how they’re authenticated, or whether their identity is preserved through the chain. That responsibility falls on the ingress control layer that you build. Securing this path requires a defense-in-depth architecture that binds every request to the user’s identity before it ever reaches the agent’s reasoning loop.

To protect and control data access, any architecture exposing AgentCore Runtime to users must satisfy the following requirements:

  • Authentication: Continuously verify the identity of every requester at the perimeter by validating tokens against the identity provider’s public keys.
  • Authorization: Determine what the authenticated subject is allowed and authorized to do, which actors they can invoke, which scopes they hold and which operations they can perform.
  • Per-hop least privilege: Make sure each component in the chain holds only enough permission to call the next hop, eliminating broad-scope credentials. Each hop must exchange the inbound token for a down-scoped, short-lived credential valid only for the immediate downstream call.
  • Identity propagation: Preserve the user’s identity through the full execution chain, so the agent operates within the user’s authorization scope. For long running or unattended workloads where the user’s session closes mid-flight, the ingress must seamlessly transition the active user token into an encrypted, short lived session context key from AgentCore Runtime. This allows the microVM to securely assert a restricted, cryptographic snapshot of the user’s identity even when the user is completely offline.
  • Edge security: Inspect and filter traffic before it reaches the application logic, by applying the needed WAF rules, bot control, IP-based rate limiting, and so on.
  • Network perimeter: Restrict runtime access to a single secure, controlled network path. Traffic arriving from any unexpected origin must be rejected regardless of the token’s validity.
  • Content protection: Enforce the Guardrails on both incoming prompts for injection attacks and outgoing tool arguments for malicious payload before execution.
  • Audit and logging: Log every authentication outcome, the authorization decision on the tool invocations, and any security event to an externalized system for compliance and incident response.

These security requirements are mandatory baselines to expose any agentic workloads to users. Any missing requirement might create a potential attack vector. By applying this full set of guardrails, you help contain the impact of a potential malicious exploit to a single user, a single session and a single execution hop.

In the next section, we provide two architecture patterns that implement this propagation differently:

  • The first architecture validates the user’s token independently at each layer while preserving it for the runtime to verify directly.
  • The second architecture exchanges the user’s token at the gateway boundary for scoped machine credentials, attesting the user’s identity through verified claims. This pattern is uniquely suited for handling the session context keys required by asynchronous, unattended workloads.

Both approaches achieve the same result: the agent acts as the user rather than with elevated privileges.

The AgentCore Gateway patterns

Each of the following patterns is presented the same way: the layered controls a request passes through before reaching the agent, followed by how user identity is carried to the runtime. As you explore, please note where each pattern places the trust boundary as that difference is what drives the trade-offs summarized at the end.

Pattern A: Expose through API Gateway

We expose AgentCore Runtime through Amazon API Gateway, which acts as a dedicated ingress point that terminates each client connection. Before any request reaches the agent, it must pass through layered security controls:

  • A Lambda authorizer: An AWS Lambda authorizer validates the Amazon Cognito-issued JSON Web Token (JWT) by verifying the signature, issuer claim and token expiration, to confirm the requester’s identity.
  • AgentCore Identity: Independently, AgentCore Identity performs a second validation inherent to the Lambda authorizer through its OAuth 2.0 inbound authentication flow. This helps to confirm the user’s identity before the request reaches the runtime to be processed.

Because the client-provided session ID is treated as untrusted input, the Lambda authorizer creates a composite session ID by appending the user identifier to the client-provided session ID. Even if two different users submit the same session ID, they resolve to unique composite IDs at the AgentCore Runtime level, preventing any cross-user session leakage.

To prevent denial of service attempts, we suggest using Amazon DynamoDB as a lightweight session counter. While the AWS WAF rate-based rules attached to the API Gateway stage protect against IP-level volumetric abuse, they evaluate requests before authentication. The Lambda authorizer checks and increments a per-user counter in DynamoDB after validating the user’s identity, helping prevent a single authenticated user from exhausting agent capacity, even if they connect from multiple IP addresses. This design scales cleanly by using a composite session ID. The Lambda Authorizer combines the user identifier and the client session ID, routing each user’s counter to a distinct partition. This naturally distributes write traffic and reduces the risk of hot keys.

Each session can sustain roughly 1,000 counter updates per second before reaching DynamoDB’s per-partition write limit, which is far beyond what any legitimate session would ever generate. That same limit is exactly what makes the counter an effective throttle. Meanwhile, total capacity across all users scales horizontally, growing with the number of active sessions. For high-volume production deployments, on-demand capacity mode absorbs sudden spikes automatically, and CloudWatch Contributor Insights lets you confirm traffic stays evenly distributed.

After the Lambda authorizer approves the request, as shown in the Figure 1:

  1. API Gateway forwarding: Passes the approved request to Lambda proxy that runs within an isolated environment with no internet egress.
  2. VPC endpoint routing: The proxy Lambda function forwards the request to AgentCore Runtime through an Amazon Virtual Private Cloud (Amazon VPC) endpoint, making sure that all traffic remains strictly within the private network.
  3. Token preservation and identity propagation: The proxy Lambda function forwards the user’s token unchanged in the authorization header; this maintains the original user identity throughout the entire flow of AgentCore Runtime.

API Gateway forwards the request to a Lambda proxy running on a private VPC with no internet egress. The role of this Lambda proxy is to relay the request to AgentCore Runtime through a VPC endpoint, so that all communication remains within the private network. The Lambda proxy forwards the user’s token (unchanged) in the Authorization header, which preserves the user’s identity all the way to AgentCore Runtime.

Figure 1: Pattern A architecture for exposing AgentCore Runtime through Amazon API Gateway

Figure 1: Pattern A architecture for exposing AgentCore Runtime through Amazon API Gateway

This VPC endpoint enforces a strict network perimeter using two independent controls:

  • Security groups: The VPC endpoint security group restricts ingress solely to the proxy Lambda function on port 443, so no other compute in the account can reach the endpoint.
  • Resource-based policy: The runtime resource-based policy is configured with principal "*" and a condition that allows invocations only when the request carries aws:SourceVpc and aws:SourceVpce values matching this stack’s VPC and endpoint. Authentication happens at the AgentCore Identity level, so there is no AWS Identity and Access Management (IAM) principal to match, and the network path is the only meaningful gate and condition that remains. AgentCore Runtime rejects requests sent directly from outside the VPC with an AccessDeniedException, even with a valid JWT.

Beyond the network boundary, Amazon Bedrock Guardrails evaluates each model’s invocation for prompt injection attacks, helping catch malicious inputs even after an invocation has passed identity and network verification. This adds content protection as a defensive layer independent of identity and network controls.

Your stack logs and tracks every authorization outcome along this path as structured JSON to Amazon CloudWatch, with an INVALID_JWT alarm. The full walkthrough and a deployable AWS Cloud Development Kit (AWS CDK) sample are linked at the end of this post.

Before production deployment, we recommend configuring an AWS WAF Web ACL at the API Gateway stage to inspect requests before they reach the Lambda authorizer. You should include AWSManagedRulesCommonRuleSet and AWSManagedRulesKnownBadInputsRuleSet for generic OWASP Top 10 protections and known exploit patterns, AWSManagedRulesSQLiRuleSet to catch injection signatures, a per-IP rate-based rule ahead of the DynamoDB throttle counters, and custom rules to reject oversized requests or malformed session IDs early. For a step-by-step integration guide including two deployment patterns for placing AWS WAF in front of the AgentCore Runtime, see Securing Amazon Bedrock AgentCore Runtime with AWS WAF.

This first pattern satisfies the ingress security requirements discussed earlier. It achieves defense in depth by applying the authentication at two independent layers, enforcing authorization through session binding and controlling traffic through per-user throttling. The architecture maintains per-hop least privilege from the API Gateway through the AgentCore Runtime while preserving end-user identity propagation by passing the user’s token through unchanged. The edge filtering is managed with AWS WAF and the network perimeter is enforced by VPC endpoint controls. The design includes the application of Amazon Bedrock Guardrails for content security with a tamper-proof audit trail in Amazon CloudWatch. The deployable CDK sample for pattern A is available on GitHub.

Pattern B: Expose through AgentCore Gateway

With Pattern B, you expose AgentCore Runtime through Amazon Bedrock AgentCore Gateway, a managed service purpose-built for agentic traffic that combines ingress authentication, token exchange and Runtime routing without requiring a proxy Lambda function or custom VPC networking.

Before any request reaches the agent, it passes the following layered security controls:

  • Inbound authentication: A custom JWT inbound authorizer is configured on AgentCore Gateway that validates the Amazon Cognito JWT by verifying its signature, issuer, and expiration before any logic runs.
  • Identity extraction, session binding and guardrails: A REQUEST interceptor for Lambda, invoked directly by AgentCore Gateway, extracts the verified user identity claims from the validated token for downstream injection. For asynchronous or unattended workloads, this interceptor securely binds these claims into an encrypted, short lived session context key. This helps ensure that even if the user’s interactive session expires hours later, a secure snapshot of their identity remains intact. It mirrors the role of the Lambda authorizer in Pattern A, enforcing the same session-binding and throttling logic.
  • Perimeter authorization (AgentCore Policy): AgentCore Gateway uses a deterministic Cedar-based policy engine to evaluate each request against defined policies before allowing tool access. It also enforces Amazon Bedrock Guardrails through AgentCore Policy for screening prompt injection and content violations at the gateway level, before the request reaches the agent. This declarative enforcement is an advantage over the API Gateway pattern where guardrails must be invoked programmatically from within the agent code.

After the authorization succeeds, the gateway manages the outbound call to AgentCore Runtime by using a strict workload isolation mechanism as shown in Figure 2:

  1. Token exchange: The gateway requests a machine-to-machine (M2M) token from AgentCore Identity using a dedicated Amazon Cognito M2M app client and attaches it to the request.
  2. Workload verification: The AgentCore Runtime validates this token against the allowedWorkloadConfiguration parameter, confirming the request originated from the gateway.
  3. On-behalf-of access: The runtime unpacks the session context key, allowlists the injected user identity passed by the interceptor and forwards it directly to the agent to enable secure, context-aware execution on behalf of the user, even during completely unattended background execution loops.
Figure 2: Pattern B architecture for exposing AgentCore runtime through AgentCore Gateway

Figure 2: Pattern B architecture for exposing AgentCore runtime through AgentCore Gateway

If a client attempts to bypass the gateway by sending a valid user token directly to the runtime, the request is automatically rejected because it lacks the required workload identity.

For more operational efficiency, AgentCore Gateway integrates AWS WAF directly at the single gateway access point, protecting the entire ingress path in one place, without the need to manage separate authorizers, proxy Lambda functions or VPC endpoints.

While API Gateway also supports AWS WAF, the AgentCore Gateway pattern simplifies management by consolidating all ingress controls behind a single component.

The AgentCore Gateway also supports native rate limiting, removing the need for custom DynamoDB-based throttle tables, for your production environments. The interceptor writes a structured audit trail to CloudWatch, with an INVALID_JWT alarm to flag spikes in authentication failures.

Before production deployment, we strongly recommend that you enable AWS WAF on the AgentCore gateway with the same rule sets described in the API Gateway pattern, including the OWASP protections, SQL injection, and custom rules for oversized or malformed requests.

To summarize, this second architecture satisfies the ingress security requirements defined earlier. It achieves defense in depth by applying a managed CUSTOM_JWT authorizer directly at the entry point, enforcing authorization through interceptor-based session binding and using rate limiting to control traffic. This pattern maintains per-hop least privileges from AgentCore Gateway through to the runtime by automating M2M token exchange, while propagating user identity for on-behalf-of execution. The edge security is managed by AWS WAF, coming directly with the gateway’s single-entry point, and secure workload isolation strictly enforces the perimeter. Finally, this design applies declarative Amazon Bedrock Guardrails for early content safety, and a tamper-proof audit trail and alarms in CloudWatch. The complete CDK sample for Pattern B is available on GitHub.

Choosing your AgentCore Runtime patterns

As explained earlier, securing access to AgentCore Runtime can be achieved through two different patterns: The AgentCore Gateway pattern or the Amazon API Gateway pattern. The right choice depends on your existing AWS infrastructure, workload constraints, and operational preferences.

Choose the Amazon API Gateway pattern if:

  • You have existing API infrastructure: Your team already runs an established Amazon API Gateway and AWS WAF deployment
  • You need a single entry point: You prefer to fold agentic traffic into your existing pipelines rather than introducing a separate entry point to operate and secure.
  • Your security model is VPC centric: Your security and compliance teams rely on VPCs and security groups as their primary network control layer
  • Your agent sessions are short-lived: While API Gateway has increased its integration timeout beyond 29 seconds, long running agentic workloads with streaming tool calls might still exceed it. This isn’t a concern if your sessions are brief.

Choose the AgentCore Gateway pattern if:

  • You’re building a new gateway: Your organization has no existing API Gateway
  • You have long run workloads: Your agents use streaming or long running tool calls that require strict API timeouts
  • You need low operational overhead: You prefer a fully managed perimeter over manually wired infrastructure
  • You require advanced AI routing: You want built-in capabilities to convert APIs and Lambda functions into Model Context Protocol (MCP) tools, handle Agent to Agent (A2A) traffic and route inference across different model providers.

The following table summarizes the key elements that help you make the right architectural decision:

Consideration API Gateway (Pattern A) AgentCore Gateway (Pattern B)
Suited to Teams already standardized on API Gateway Teams starting fresh who want less infrastructure to operate.
Perimeter control Runtime resource policy with aws:SourceVpc and VPC endpoint security group Runtime workload lock (allowedWorkloadConfiguration).
Components to operate API Gateway, Lambda authorizer, Amazon VPC, VPC endpoints, proxy Lambda function AgentCore Gateway and Lambda REQUEST interceptor.
User identity to agent User JWT forwarded unchanged (no SigV4) Interceptor-injected verified headers (OAuth outbound M2M token).
AWS WAF Attach directly to the API stage Attach directly to the gateway.
Request timeout Inherits the API Gateway integration timeout Not subject to this limitation.
Public endpoint Can be fully private (API Gateway PRIVATE endpoint type) Supports AWS PrivateLink ingress and VPC Lattice egress, but keeps a public endpoint active. Access relies on the JWT authorizer and resource policy rather than removing the endpoint

Conclusion

By securing access to the AgentCore Runtime with a defense in depth, an agent can be both highly usable and secure. The two patterns in this post complete the shared responsibility model for you: they authenticate every request against the identity provider, authorize it at each step and propagate the user’s identity end-to-end from the edge through the token exchange into the isolated microVM (AgentCore Runtime) and down to the agent’s tool calls (AgentCore Gateway). Each step only holds a short-lived credential for the next one, so the agent always works within the user’s permissions rather than with broad, long-term access. If one step is ever compromised, the design limits the impact to that single step, session and user. Whether the runtime is behind API Gateway with a VPC endpoint or in front of it with AgentCore Gateway, the design verifies each request at each step.

To get started, clone the Pattern A sample or the Pattern B sample, deploy it in your account, and test it against your requirements. Both samples are provided as a starting point, not a production-ready deployment. We recommend working with your security and legal teams to adapt to the controls before going live. From there, you can extend either pattern for multi-tenant use, add observability hooks, or tighten controls for your specific compliance requirements.

If you have questions about this post, contact AWS Support or start a new thread on AWS re:Post.


Merriem-SMACHE

Meriem SMACHE

Meriem is a Security Specialist Solutions Architect at AWS, supporting customers in the design and deployment of resilient cloud and AI solutions, from generative AI workloads to fully autonomous agentic systems, that meet their regulatory requirements and security needs.

Christian Kamwangala

Christian Kamwangala

Christian is a Senior AI/ML and Generative AI Specialist Solutions Architect at AWS, based in Paris, France. He partners with enterprise customers to architect, optimize, and deploy production-grade AI solutions using the comprehensive AWS ML stack. Christian specializes in inference optimization techniques that balance performance, cost, and latency requirements for large-scale deployments. Christian enjoys exploring nature and spending time with family and friends.

Lior Perez

Lior Perez

Lior is a Principal AI & Machine Learning Solutions Architect at Amazon Web Services, based in Toulouse, France. He helps customers speed up their digital transformation with AI. He wrote the AWS Prescriptive Guidance Governing and Architecting the Diversity of Agentic AI at Scale, which helps enterprises design and govern AI agents. He makes complex ideas simple and practical. His background in manufacturing and meteorology gives him a different way of looking at business challenges.

Charline Boulie

Charline Boulie

Charline is a Senior Solutions Architect at AWS. She helps French FinTech startups and scale-ups build and scale secure, generative AI-powered workloads, focusing on agentic AI, application development and security. She brings 15 years of software and cloud architecture experience from Thales Avionics and AWS Professional Services, and champions women in tech through mentoring and student outreach.