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
runtimeSessionIdand must never let a caller supply someone else's. - Gateway authorisation can be switched off.
AUTHENTICATE_ONLYandNONEinbound modes make no authorisation decision, andJWT_PASSTHROUGHforwards 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.
| Service | Inbound options | Outbound identity | Main identity risk |
|---|---|---|---|
| Runtime | IAM SigV4 or JWT bearer token (one method per runtime) | Execution role via MMDS; AgentCore Identity for OAuth and API keys | Over-broad execution role readable by any code in the microVM |
| Gateway | CUSTOM_JWT, IAM (bedrock-agentcore:InvokeGateway), AUTHENTICATE_ONLY, NONE | GATEWAY_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 |
| Memory | IAM on memory APIs | Service-managed or customer managed KMS key | Cross-user leakage through namespaces; long retention |
| Code Interpreter | IAM on *CodeInterpreter* actions | Execution role for custom code interpreters | Generated code using the role or the network |
| Browser | IAM on browser actions | Execution role for custom browsers | Agent browsing untrusted pages with live sessions |
- JWT over user ID headers: AWS recommends
GetWorkloadAccessTokenForJWT, which validates issuer, signature and expiry, for production;GetWorkloadAccessTokenForUserIdis for development or architectures where identity is established upstream. Denybedrock-agentcore:GetWorkloadAccessTokenForUserIdandbedrock-agentcore:InvokeAgentRuntimeForUserwhere JWTs are always available. - Derive the user ID: if you use the
X-Amzn-Bedrock-AgentCore-Runtime-User-Idheader, 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 capability | Example actions or keys | Control |
|---|---|---|
| Create or change a gateway's authoriser | Gateway create and update; condition key bedrock-agentcore:GatewayAuthorizerType | SCP or permission boundary that denies creating NONE gateways except in approved accounts |
| Invoke a runtime on behalf of a user | bedrock-agentcore:InvokeAgentRuntimeForUser | Explicit deny for all but trusted backend principals |
| Run commands or a shell in a session | InvokeAgentRuntimeCommand, InvokeAgentRuntimeCommandShell | Restrict to operators; log and alarm |
| Create credential providers | CreateOauth2CredentialProvider, CreateApiKeyCredentialProvider | Platform team only; review the scopes behind each client |
| Change memory retention | UpdateMemoryRecordExpirySpecification | Change-controlled; aligned with retention policy |
| Pass execution roles | iam:PassRole for runtime, code interpreter and browser roles | Limit 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-arnfor 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
InvokeAgentRuntimeand 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:SourceAccountandaws:SourceArnconditions to the execution role trust policy forbedrock-agentcore.amazonaws.comto prevent confused deputy use, with the full runtime ARN where known. - Input type: AWS warns that a non-string
prompt, in particular atoolUseblock, can trigger tool execution without model evaluation. Validate the payload with a schema and striptoolUseblocks from user-supplied messages.
Gateway targets and credential providers
| Target type | Outbound options AWS supports | Recommended pattern |
|---|---|---|
| Lambda function | Gateway service role only | Dedicated gateway role scoped to named functions |
| MCP server | None, service role, OAuth (client credentials, authorisation code, token exchange), API key | Token exchange for user-delegated calls; client credentials per server otherwise |
| OpenAPI schema | None, service role, OAuth (all three grants), API key | OAuth with narrow scopes; API key only where the API offers nothing else |
| Smithy schema | Service role, OAuth client credentials | Service role scoped to the AWS APIs described |
| API Gateway stage | None, service role, API key | Service role with IAM auth on the stage |
| AgentCore Runtime (HTTP) | Service role, caller IAM credentials, OAuth client credentials, token passthrough | Caller 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:GetResourceOauth2TokenorGetResourceApiKeyscoped to the specific credential ARN, andsecretsmanager:GetSecretValuescoped 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,
allowedWorkloadConfigurationon 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 unlessrecordExpiryDurationDays(minimum 31) is set. Use namespaces built from{actorId}and{sessionId}, setactorIdfrom 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
| Source | What to capture | Detections worth building |
|---|---|---|
| CloudTrail | InvokeAgentRuntime, InvokeAgentRuntimeCommand, InvokeAgentRuntimeCommandShell, control plane changes to gateways, credential providers and memory | Gateway created or switched to NONE; new credential provider; shell sessions outside operator roles |
| CloudTrail (gateway JWT) | The JWT sub claim is logged | Use GUID or pairwise subjects to keep PII out of logs |
| CloudWatch Logs | Request IDs and input commands in the agent's log group | Metric filters for unexpected commands; correlate request IDs with CloudTrail caller identity |
| Execution role activity | CloudTrail events made with runtime, code interpreter and browser role sessions | Role used for APIs it never used before; calls from outside expected VPC endpoints (T1078.004) |
| VPC Flow Logs | Runtime ENI traffic in private subnets | Egress to unexpected destinations from agent subnets |
| Browser recordings | Replays in S3 | Review 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
NONEorAUTHENTICATE_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
- Accounts and guardrails first: run AgentCore in dedicated workload accounts; use SCPs to deny
NONEgateways and user-id delegation outside approved accounts, and VPC condition keysbedrock-agentcore:subnetsandbedrock-agentcore:securityGroupsto require approved networks. - Least-privilege execution roles: replace CLI-generated roles, scope
Resourceto specific ARNs, add confused deputy conditions, and validate with IAM Access Analyzer. SetrequireMMDSV2: trueinmetadataConfigurationon any runtime that predates the requirement. - Private networking: deploy runtimes in private subnets with a NAT route where internet access is needed, PrivateLink endpoints for
com.amazonaws.region.bedrock-agentcoreandbedrock-agentcore-control, ECR, S3 and CloudWatch Logs endpoints for container agents, and tight security groups and endpoint policies. - 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.
- 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.
- Containers and code: run as non-root, rebuild images from current base images, validate the prompt payload, restrict localhost access from agent tools.
- Memory and data: set event and record expiry to your retention policy, use customer managed KMS keys where required, scope namespaces by authenticated actor.
- 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_ONLYorNONEchosen 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
runtimeSessionIdor 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
| Area | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 |
|---|---|---|
| Execution roles, gateway roles | AC-6 Least Privilege, AC-3 Access Enforcement | PR.AA-05 |
| Agent identities, credential providers | IA-9 Service Identification and Authentication, IA-5 Authenticator Management | PR.AA-01 |
| Private networking, gateway enforcement | SC-7 Boundary Protection, AC-4 Information Flow Enforcement | PR.AA-05 |
| Memory encryption | SC-12 Cryptographic Key Establishment and Management | - |
| CloudTrail, CloudWatch, Flow Logs | AU-2 Event Logging, AU-12 Audit Record Generation, SI-4 System Monitoring | DE.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
NONEgateways 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
- AWS: Security best practices for AgentCore Runtime
- AWS: AgentCore Runtime sessions
- AWS: AgentCore Gateway inbound authorization
- AWS: AgentCore Gateway outbound authorization
- AWS: AgentCore Identity terminology
- AWS: Create an AgentCore Memory store
- AWS: AgentCore Code Interpreter
- AWS: AgentCore Browser
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