{"question":"We're moving our AI agent off one shared API key so each customer's session uses that customer's own credentials, and we're looking at Amazon Bedrock AgentCore Identity's token vault. How does it keep one customer's tokens away from another customer's session, and where can that separation still break?","slug":"how-does-amazon-bedrock-agentcore-identity-keep-one-customers-credentials-away-from-another-customers-agent-session","url":"https://www.rightshold.com/answers/how-does-amazon-bedrock-agentcore-identity-keep-one-customers-credentials-away-from-another-customers-agent-session","short_answer":"By tying every credential lookup to a pair: the agent's workload identity and the end user it's working for. Your agent gets a workload access token that carries both, and the token vault only hands back credentials stored for that same agent-and-user pair, so tokens stored for customer A can't be read in customer B's session. The separation is only as good as the user identity you put in that token. If you exchange the customer's signed JWT (GetWorkloadAccessTokenForJWT), AgentCore checks the signature, issuer and expiry and uses the iss and sub claims. If you pass a plain user ID string (GetWorkloadAccessTokenForUserId), AWS says it treats the string as opaque and doesn't verify it, so whoever can call that API can name any customer. Two more gaps are yours to close: IAM decides which agents can use which credential providers, with no extra binding inside one account, and an OAuth consent link sent to the wrong person needs your own callback check.","checklist":["Get the workload access token from the customer's own identity provider JWT (GetWorkloadAccessTokenForJWT) wherever you have one; AWS recommends that path for production.","If you must use GetWorkloadAccessTokenForUserId, derive the user ID from the authenticated session on your side, never from a value the client or the model supplies.","Grant bedrock-agentcore:GetWorkloadAccessTokenForUserId only to the principals that need it, scoped to specific workload identity ARNs, and deny it outright for workloads that always have a JWT.","With more than one identity provider, prefix user IDs with the provider (cognito+user123, auth0+user123) so two customers with the same ID don't share a vault slot.","Scope each agent's IAM Resource block to the exact workload identity and credential provider ARNs it needs, not *.","Register an HTTPS callback in allowedResourceOauth2ReturnUrls and check that the user who finishes OAuth consent is the user who started it.","Use AWS CloudTrail to watch GetWorkloadAccessTokenForUserId calls for user IDs you don't expect."],"sections":[{"heading":"How the token vault separates one customer's credentials from another's","points":["AgentCore Identity stores OAuth 2.0 tokens, OAuth client credentials and API keys in a token vault, encrypted with a customer-managed or service-managed AWS KMS key. Agents don't read the vault directly. They present a workload access token, an AWS-signed opaque token that, per the developer guide, contains both the agent's identity and the identity of the end user it's working for, and that works only for AgentCore's own services.","The guide says tokens are scoped to the specific user-agent pair, so credentials stored under one user can't be reached by another, and that what a workload retrieves from a credential provider is scoped to the user in its workload access token. For an OAuth provider that needs the user's consent (3LO), nothing exists to retrieve for a customer until that customer has authorized.","When the agent runs on AgentCore Runtime or behind Gateway with inbound authentication, the service does the exchange itself: it validates the caller's OAuth token, takes the issuer and sub claims as the user, and passes the resulting workload access token to the agent code. Runtime- and Gateway-managed identities can't fetch workload access tokens directly, which keeps agent code from minting tokens for other users."]},{"heading":"Where per-customer separation still breaks","points":["The user ID path is the main one. GetWorkloadAccessTokenForUserId takes a caller-supplied string and issues a token for that user and agent. AWS's guide says plainly that the platform treats the string as opaque and doesn't check it against an authenticated user, so the binding depends on the calling workload sending the right ID and on IAM being scoped tightly. A bug or a prompt injection that changes the user ID your code sends changes whose credentials the agent gets.","The second is IAM. AWS notes that the role you assign an agent controls which credential providers it can call, and that the service doesn't enforce any other binding between workload identities and credential providers in the same account. A role with Resource * can reach every provider in the account. The guide's examples scope each grant to one workload identity and one provider ARN, or use separate workload identities for separate providers.","The third is OAuth consent. AgentCore generates an authorization URL for the customer to approve, and AWS warns that a user may forward that URL to someone else and so connect the wrong account. Its fix is session binding: register your own HTTPS callback, compare the user who started the request with the user now signed in, and only then complete it. The local agentcore dev tool doesn't host that callback, so it has to exist in your app for testing too."]},{"heading":"What to log so an auditor can check one customer's trail","points":["AWS's guide says all credential operations are logged and recommends using AWS CloudTrail to watch GetWorkloadAccessTokenForUserId calls and to record which authenticated principal sent which user ID. That pairing is what shows a reviewer that a session for one customer never asked for another's credentials.","Keep the customer ID, the workload identity and the credential provider on every record your own agent writes about a tool call, so one customer's export holds its own trail and nothing else. Vault access logs show which credential was fetched; they don't show what the agent did with it, so the action log on your side matters as much.","A shared API key can't produce that trail: every customer's calls look the same downstream. Moving each customer to its own OAuth grant or its own stored key, reached only through its own user-agent pair, is what makes per-customer revocation and per-customer evidence possible."]}],"checks":[],"ask_rightshold":{"start":"https://www.rightshold.com/start?ref=seo","mcp_endpoint":"https://www.rightshold.com/mcp","ask":"Give the agent working for one customer a Rightshold key that can only run license checks, labelled with that customer's account ID, and that stops working when this job's intent expires.","mcp_call":{"tool":"intent_key","arguments":{"intent_id":"<int_... from declare_intent, declared with operations [\"check_license\", \"check_rights_batch\"] and ttl_hours 8>","label":"customer <account id> session"}},"also":["Needs your account API key. intent_key issues a key bound to that one intent: requests outside its declared operations are refused, and once the intent expires or is revoked the key gets 403 intent_inactive. Issue one per customer session so no two customers share a key. The key is shown once.","It doesn't store or vend AWS, OAuth or third-party credentials, and it doesn't check what user ID your code passes to AgentCore. It only covers Rightshold calls."],"scope":"Rightshold isn't affiliated with Amazon Web Services. It doesn't run on or inspect AgentCore, IAM policies or token vaults. Behavior is as described in the Amazon Bedrock AgentCore developer guide pages on identity features, getting workload access tokens, scoping credential provider access, obtaining credentials and OAuth 2.0 authorization URL session binding, all read November 27, 2026; AWS updates these pages, so check the linked pages before relying on them."},"sources":[{"title":"Amazon Bedrock AgentCore Developer Guide: Get workload access token (incl. security controls for GetWorkloadAccessTokenForUserId)","url":"https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/get-workload-access-token.html"},{"title":"Amazon Bedrock AgentCore Developer Guide: Scope down access to credential providers by workload identity","url":"https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/scope-credential-provider-access.html"},{"title":"Amazon Bedrock AgentCore Developer Guide: OAuth 2.0 authorization URL session binding","url":"https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/oauth2-authorization-url-session-binding.html"},{"title":"Amazon Bedrock AgentCore Developer Guide: Features of AgentCore Identity (token vault)","url":"https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/key-features-and-benefits.html"},{"title":"Amazon Bedrock AgentCore Developer Guide: Obtain credentials","url":"https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/obtain-credentials.html"}],"related":[{"title":"Giving an AI agent a scoped, expiring credential instead of a long-lived API key","url":"https://www.rightshold.com/answers/how-to-give-an-ai-agent-a-scoped-expiring-credential-instead-of-a-long-lived-api-key"},{"title":"How to scope OAuth tokens per task for AI agents","url":"https://www.rightshold.com/answers/how-to-scope-oauth-tokens-per-task-for-ai-agents"},{"title":"OAuth token exchange so an MCP server never forwards user tokens","url":"https://www.rightshold.com/answers/how-to-do-oauth-token-exchange-so-an-mcp-server-never-forwards-user-tokens"},{"title":"Making an AI agent's audit log append-only so even an admin can't silently delete entries","url":"https://www.rightshold.com/answers/how-to-make-an-ai-agents-audit-log-append-only-so-even-an-admin-cant-silently-delete-entries"}],"computed_from":"Curated guidance; license verdicts computed from Rightshold's license profiles at render time. Not legal advice.","updated":"2026-11-27"}