Join our Newsletter — 33% off our NHI Course
Home› Guides› AWS Bedrock AgentCore Security Guide: Runtime, Gateway, Memory…
Guide AI Platforms

AWS Bedrock AgentCore Security Guide: Runtime, Gateway, Memory and Tools

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 13 min read
On this page

Amazon Bedrock AgentCore hands an agent a microVM, a gateway full of tools, persistent memory, a code sandbox and a browser, and each of those is a place where an execution role, a token or a missing authorisation check can turn one prompt into account-wide access. The Amazon Bedrock Security Guide covers Bedrock as a whole, including model access, API keys and an introduction to AgentCore Identity; this guide goes one level down into the AgentCore services themselves: Runtime, Gateway, Memory, Code Interpreter and Browser. It sets out the authorisation choices AWS documents for each, the settings that matter, what to log and the mistakes AWS itself warns about. It is for AWS platform engineers, cloud security teams and IAM owners deploying agents on AgentCore. Details are from the AWS AgentCore Developer Guide checked 27 October 2026; AgentCore changes quickly, so confirm against the current pages.

This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.

Key takeaways

  • Every microVM can read its execution role. AWS states that any code in a Runtime microVM can obtain the execution role credentials from the metadata endpoint (MMDS), so the role, not the agent's instructions, is the real permission boundary. AWS states that from 30 June 2026 runtimes without MMDSv2 return a ValidationException.
  • AgentCore does not map users to sessions. Session isolation is per microVM, but your backend must decide which user owns which runtimeSessionId and must never let a caller supply someone else's.
  • Gateway authorisation can be switched off. AUTHENTICATE_ONLY and NONE inbound modes make no authorisation decision, and JWT_PASSTHROUGH forwards the caller's token unchanged; AWS recommends a policy engine and on-behalf-of token exchange for production.
  • A gateway role is shared by all its IAM targets. Its permissions cap what any authorised caller can do, so separate gateways by sensitivity.
  • Memory and session storage persist by design. Raw memory events can be kept up to 365 days, long-term records may never expire, and session storage survives stop and resume; set expiry and encryption deliberately.

How identity and access work in AgentCore

AgentCore has two kinds of identity question: who may call the agent or tool (inbound), and with what credential the agent or gateway calls something else (outbound). AgentCore Identity manages agent identities as workload identities in an agent identity directory, keeps outbound OAuth tokens and API keys in a token vault, and issues agent access tokens: AWS-signed tokens that carry both the workload identity and the user identity so downstream services can decide on both. AWS states that the token vault only releases a credential to the agent and user combination that obtained it.

ServiceInbound optionsOutbound identityMain identity risk
RuntimeIAM SigV4 or JWT bearer token (one method per runtime)Execution role via MMDS; AgentCore Identity for OAuth and API keysOver-broad execution role readable by any code in the microVM
GatewayCUSTOM_JWT, IAM (bedrock-agentcore:InvokeGateway), AUTHENTICATE_ONLY, NONEGATEWAY_IAM_ROLE, OAuth client credentials, authorisation code, token exchange, API key, caller IAM credentials, token passthrough (by target type)No authorisation at the gateway; one shared service role across targets
MemoryIAM on memory APIsService-managed or customer managed KMS keyCross-user leakage through namespaces; long retention
Code InterpreterIAM on *CodeInterpreter* actionsExecution role for custom code interpretersGenerated code using the role or the network
BrowserIAM on browser actionsExecution role for custom browsersAgent browsing untrusted pages with live sessions
  • JWT over user ID headers: AWS recommends GetWorkloadAccessTokenForJWT, which validates issuer, signature and expiry, for production; GetWorkloadAccessTokenForUserId is for development or architectures where identity is established upstream. Deny bedrock-agentcore:GetWorkloadAccessTokenForUserId and bedrock-agentcore:InvokeAgentRuntimeForUser where JWTs are always available.
  • Derive the user ID: if you use the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header, set it from the authenticated principal, never from a client-supplied value.
  • Delegated versus autonomous: use the authorisation code grant (3LO) when the agent acts for a specific user, client credentials (2LO) when it acts on its own, and keep the two credential sets separate.

For how AgentCore Identity compares with Microsoft Entra Agent ID and Google's agent identity, see Cloud Agent Identity Services Compared (Entra, AgentCore, Google).

Admin roles and privileged access

AgentCore has no separate administrator console role: administration is IAM permissions on bedrock-agentcore (data plane) and bedrock-agentcore-control (control plane) actions. The privileged actions to restrict are the ones that change who can call what, or what an agent can reach.

Privileged capabilityExample actions or keysControl
Create or change a gateway's authoriserGateway create and update; condition key bedrock-agentcore:GatewayAuthorizerTypeSCP or permission boundary that denies creating NONE gateways except in approved accounts
Invoke a runtime on behalf of a userbedrock-agentcore:InvokeAgentRuntimeForUserExplicit deny for all but trusted backend principals
Run commands or a shell in a sessionInvokeAgentRuntimeCommand, InvokeAgentRuntimeCommandShellRestrict to operators; log and alarm
Create credential providersCreateOauth2CredentialProvider, CreateApiKeyCredentialProviderPlatform team only; review the scopes behind each client
Change memory retentionUpdateMemoryRecordExpirySpecificationChange-controlled; aligned with retention policy
Pass execution rolesiam:PassRole for runtime, code interpreter and browser rolesLimit to named roles; require the role to have no more privilege than its invokers
  • Review CLI-created roles: AWS notes that the role the AgentCore CLI creates permits model invocation for all foundation models and inference profiles in the account. Run agentcore build, review the generated CDK output, and pass your own least-privilege role with --role-arn for production.
  • No escalation through the agent: AWS advises that the execution role should have equal or fewer privileges than the principals who can invoke the runtime. Otherwise invoking the agent is a privilege escalation path (ATT&CK T1078.004 Cloud Accounts covers the abuse of the resulting credentials).
  • Hierarchical resource policies: for InvokeAgentRuntime and the command APIs, both the runtime and the agent endpoint policies must allow the call, and an explicit deny always wins. Use this for cross-account access rather than broad identity policies.

See the AWS IAM Policies and Roles Guide and the AWS Organizations and SCPs Guide.

Integrations, API tokens and service accounts

Runtime execution roles and sessions

  • Isolation: each session runs in a dedicated microVM with isolated CPU, memory and filesystem; after completion the microVM is terminated and memory sanitised. Defaults: idle timeout (idleRuntimeSessionTimeout) 15 minutes, maximum lifetime (maxLifetime) 8 hours per microVM.
  • Session IDs: the application supplies the runtimeSessionId (at least 33 characters). Use unguessable values such as UUIDs, one per user or conversation, enforce a per-user session quota, and bind sessions to users in your backend.
  • Persistent filesystem: if session storage is configured, data at the mount path survives stop and resume, and filesystem permissions inside the session always succeed because the agent is the only user. Do not store credentials there.
  • Trust policy: add aws:SourceAccount and aws:SourceArn conditions to the execution role trust policy for bedrock-agentcore.amazonaws.com to prevent confused deputy use, with the full runtime ARN where known.
  • Input type: AWS warns that a non-string prompt, in particular a toolUse block, can trigger tool execution without model evaluation. Validate the payload with a schema and strip toolUse blocks from user-supplied messages.

Gateway targets and credential providers

Target typeOutbound options AWS supportsRecommended pattern
Lambda functionGateway service role onlyDedicated gateway role scoped to named functions
MCP serverNone, service role, OAuth (client credentials, authorisation code, token exchange), API keyToken exchange for user-delegated calls; client credentials per server otherwise
OpenAPI schemaNone, service role, OAuth (all three grants), API keyOAuth with narrow scopes; API key only where the API offers nothing else
Smithy schemaService role, OAuth client credentialsService role scoped to the AWS APIs described
API Gateway stageNone, service role, API keyService role with IAM auth on the stage
AgentCore Runtime (HTTP)Service role, caller IAM credentials, OAuth client credentials, token passthroughCaller IAM credentials or client credentials; avoid passthrough
  • Token exchange: AWS describes the on-behalf-of grant as exchanging the inbound user token for a scoped downstream token that carries both user and agent identity. This is the attributable alternative to token passthrough. See the OAuth Token Exchange and Delegation Guide.
  • Custom gateway roles: grant only bedrock-agentcore:GetWorkloadAccessToken, bedrock-agentcore:GetResourceOauth2Token or GetResourceApiKey scoped to the specific credential ARN, and secretsmanager:GetSecretValue scoped to the specific secret ARN.
  • Force traffic through the gateway: for SigV4 runtimes, a resource-based policy that allows only the gateway's execution role; for JWT runtimes, allowedWorkloadConfiguration on the authoriser. Otherwise callers can bypass the gateway's policy engine and interceptors.

Memory, Code Interpreter and Browser

  • Memory: short-term events expire per eventExpiryDuration (CLI accepts 3 to 365 days, default 30; changes apply only to new events). Long-term strategies (SEMANTIC, SUMMARIZATION, USER_PREFERENCE, EPISODIC) keep records without expiry unless recordExpiryDurationDays (minimum 31) is set. Use namespaces built from {actorId} and {sessionId}, set actorId from the authenticated user, and choose a customer managed KMS key where policy requires it. See the AI Agent Memory Security Guide.
  • Code Interpreter: code runs in an isolated sandbox environment (Python, JavaScript, TypeScript), default execution 15 minutes, extendable to 8 hours; inline files up to 100 MB and S3 files up to 5 GB. Custom code interpreters take a network setting (Sandbox or Public) and an execution role that defines what AWS resources the code can reach. Prefer Sandbox and a role scoped to one S3 prefix. See the AI Agent Sandboxing and Code Execution Guide.
  • Browser: isolated, ephemeral sessions, default 15 minutes and maximum 8 hours; Live View lets a person watch and take over; session recording (custom browsers only) stores DOM changes, actions, console logs and network events in your S3 bucket. Recordings can contain whatever the agent saw, so protect that bucket as sensitive. See the Browser and Computer-Use Agent Guide.

Logging and detection

SourceWhat to captureDetections worth building
CloudTrailInvokeAgentRuntime, InvokeAgentRuntimeCommand, InvokeAgentRuntimeCommandShell, control plane changes to gateways, credential providers and memoryGateway created or switched to NONE; new credential provider; shell sessions outside operator roles
CloudTrail (gateway JWT)The JWT sub claim is loggedUse GUID or pairwise subjects to keep PII out of logs
CloudWatch LogsRequest IDs and input commands in the agent's log groupMetric filters for unexpected commands; correlate request IDs with CloudTrail caller identity
Execution role activityCloudTrail events made with runtime, code interpreter and browser role sessionsRole used for APIs it never used before; calls from outside expected VPC endpoints (T1078.004)
VPC Flow LogsRuntime ENI traffic in private subnetsEgress to unexpected destinations from agent subnets
Browser recordingsReplays in S3Review on incidents involving web content
  • Log delegation: AWS advises logging the relationship between the IAM principal and the user ID value whenever user-id delegation is used, so actions can be attributed to the person behind them.
  • Metrics: runtimes using a reviewed least-privilege role rather than the CLI default; gateways with authoriser NONE or AUTHENTICATE_ONLY (target zero in production); targets using token passthrough; runtimes with MMDSv2 required; memory stores without long-term record expiry; time to revoke a credential provider.

See the AI Agent Observability and Incident Response Guide.

Hardening baseline

  1. Accounts and guardrails first: run AgentCore in dedicated workload accounts; use SCPs to deny NONE gateways and user-id delegation outside approved accounts, and VPC condition keys bedrock-agentcore:subnets and bedrock-agentcore:securityGroups to require approved networks.
  2. Least-privilege execution roles: replace CLI-generated roles, scope Resource to specific ARNs, add confused deputy conditions, and validate with IAM Access Analyzer. Set requireMMDSV2: true in metadataConfiguration on any runtime that predates the requirement.
  3. Private networking: deploy runtimes in private subnets with a NAT route where internet access is needed, PrivateLink endpoints for com.amazonaws.region.bedrock-agentcore and bedrock-agentcore-control, ECR, S3 and CloudWatch Logs endpoints for container agents, and tight security groups and endpoint policies.
  4. Front runtimes with a gateway: JWT inbound authorisation with discovery URL, allowed audiences, clients and scopes all set; policy engine rules per caller and target; interceptors for inspection; direct invocation blocked.
  5. Credentials in the vault: all third-party OAuth clients and API keys in AgentCore Identity credential providers, none in code or environment variables; token exchange for user-delegated calls.
  6. Containers and code: run as non-root, rebuild images from current base images, validate the prompt payload, restrict localhost access from agent tools.
  7. Memory and data: set event and record expiry to your retention policy, use customer managed KMS keys where required, scope namespaces by authenticated actor.
  8. Test before enforcing: pilot new gateway policies and role reductions in a non-production account, replay representative agent traffic, and keep the previous policy version of each role so you can roll back by restoring it.

Common misconfigurations

  • CLI default role in production: the generated role allows invocation of every foundation model in the account, and any code in the microVM can use it.
  • Instance metadata treated as safe: agents that can run code or reach localhost can read execution role credentials. Scope roles as if the agent will read them.
  • Gateway authorisation offloaded and forgotten: AUTHENTICATE_ONLY or NONE chosen during testing, with no policy engine, interceptor or target-side check added before go-live.
  • Token passthrough in production: the same token is accepted by both gateway and target, so a token stolen from one works on the other and logs cannot separate agent from user.
  • One gateway for everything: a single gateway service role spanning low- and high-sensitivity targets gives every authorised caller the union of their permissions.
  • Client-supplied session or user IDs: a backend that passes through a caller's runtimeSessionId or user ID header lets one user land in another's session.
  • Memory kept forever: long-term strategies without record expiry accumulate personal data and any poisoned "facts" indefinitely. See the AI Agent Memory Poisoning Guide.

Framework mapping

AreaNIST SP 800-53 Rev. 5NIST CSF 2.0
Execution roles, gateway rolesAC-6 Least Privilege, AC-3 Access EnforcementPR.AA-05
Agent identities, credential providersIA-9 Service Identification and Authentication, IA-5 Authenticator ManagementPR.AA-01
Private networking, gateway enforcementSC-7 Boundary Protection, AC-4 Information Flow EnforcementPR.AA-05
Memory encryptionSC-12 Cryptographic Key Establishment and Management-
CloudTrail, CloudWatch, Flow LogsAU-2 Event Logging, AU-12 Audit Record Generation, SI-4 System MonitoringDE.CM-03

Practitioner checklist

  • Replace CLI-generated execution roles with least-privilege roles that hold no more than their invokers.
  • Require MMDSv2 on every runtime and assume code in the microVM can read the role.
  • Bind sessions to users in your backend with unguessable session IDs and per-user quotas.
  • Use JWT inbound authorisation with all claims checks set, and deny user-id delegation actions where not needed.
  • Deny NONE gateways by policy and add a policy engine to every production gateway.
  • Use token exchange instead of token passthrough, and separate gateways by target sensitivity.
  • Store every third-party credential in AgentCore Identity credential providers, scoped per target.
  • Set memory event and record expiry, namespaces by authenticated actor, and KMS keys as policy requires.
  • Run Code Interpreter in Sandbox mode with a narrow role; protect browser recording buckets.
  • Log CloudTrail, CloudWatch command logs and Flow Logs, and alert on authoriser changes and new credential providers.

Standards and references

Related NHI Mgmt Group resources: Amazon Bedrock Security Guide · Cloud Agent Identity Services Compared (Entra, AgentCore, Google) · AWS IAM Policies and Roles Guide · MCP Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.