AWS STS GetScopedCredentials: Least-Privilege Credentials for AI Agents (How-To)

AWS STS GetScopedCredentials: Least-Privilege Credentials for AI Agents (How-To)

AWS STS GetScopedCredentials: Least-Privilege Credentials for AI Agents (How-To)

Most AI agent deployments on AWS share one quiet flaw: every sub-agent runs with the orchestrator’s full role. The retrieval agent that only needs to read one S3 prefix can also delete objects, query DynamoDB and assume other roles, because it inherited the same keys. On November 19, 2026, AWS shipped AWS STS GetScopedCredentials, an API that takes temporary credentials you already hold and returns a narrower, optionally shorter-lived copy of them. The identity stays the same; only the permissions and lifetime shrink. That matters now because agent frameworks fan out work to sub-agents and tools faster than teams can design a role per tool, and a prompt-injected sub-agent can only abuse what its credentials allow. This how-to walks through the verified API contract, a step-by-step setup, and the attribution and revocation details that the announcement does not spell out.

What this covers: the request and response fields, an eight-step implementation for an orchestrator and its sub-agents, a CloudTrail audit query, the gotchas around KMS caching and resource policies, and when to pick this over AssumeRole session policies or Amazon Bedrock AgentCore Identity.

Context and Background

AWS Security Token Service (STS) has offered short-term credentials for over a decade. The workhorse is AssumeRole, which swaps one identity for another and returns keys that expire. Teams that wanted narrower keys had two older tools. They could pass a session policy to AssumeRole or GetFederationToken, or they could create more roles. Both work, and both strain under agent-shaped workloads.

Session policies are attached at assume time. If the orchestrator wants different scopes for five sub-agents, it must re-assume a role five times. That re-assumption is role chaining, and AWS caps a chained role session at one hour. Each call also needs sts:AssumeRole permission on the target role and a trust policy that allows it. Creating a role per tool is cleaner on paper but turns into dozens of near-duplicate roles, each with its own trust policy to review. If you need a refresher on how identity policies, permissions boundaries, SCPs and session policies combine, our guide to AWS IAM policy evaluation logic, SCPs and permission boundaries covers the full decision path.

GetScopedCredentials removes the role hop. According to the AWS What’s New announcement, it narrows the permissions, the session duration, or both, of temporary credentials the caller already holds. The new credentials keep the caller’s original identity, and they can never exceed the caller’s own permissions. Access to the API is controlled with IAM, every call is logged in AWS CloudTrail, and the API is available in all commercial Regions, AWS GovCloud (US), the AWS European Sovereign Cloud (Germany) and the China Regions. AWS pitches it explicitly for agents, sub-agents and workloads.

The agent angle is not marketing garnish. An LLM-driven sub-agent is a workload whose behaviour is partly decided by untrusted input: retrieved documents, tool outputs, user prompts. You cannot fully predict which API calls it will try. The only robust control is to bound what its credentials permit, so that a successful prompt injection hits an AccessDenied rather than a destructive call. That is classic least privilege, applied at a finer grain and a faster cadence than IAM roles were designed for. It complements, rather than replaces, the delegated-authorization patterns we covered in AI agent identity and delegated authorization with OAuth token exchange.

How AWS STS GetScopedCredentials Works

AWS STS GetScopedCredentials takes the temporary credentials of the calling session and returns new credentials for the same session principal with fewer permissions, a shorter lifetime, or both. Effective permissions are the intersection of the caller’s permissions and the scope-down policy you pass. It never assumes another role and never grants anything new.

AWS STS GetScopedCredentials architecture: an orchestrator agent session calls STS to mint three scoped credential sets for retrieval, lookup and diagnostics sub-agents, all logged in CloudTrail

Figure 1: One orchestrator session fans out into three scoped credential sets, each with its own narrow policy and short lifetime, all traceable in CloudTrail.

Figure 1 shows the target shape. A human or pipeline starts an orchestrator in an assumed-role session, ideally with a SourceIdentity that names the person or job. The orchestrator calls STS once per sub-agent. Each call carries a small scope-down policy and a duration, and returns keys that only work for that sub-agent’s task. The sub-agents never see the orchestrator’s keys. CloudTrail records each GetScopedCredentials call, plus the API calls the sub-agents then make with their scoped keys.

The request contract is small, and that is a feature

The GetScopedCredentials API reference lists four optional request parameters. At least one of Policy or DurationSeconds must be present, otherwise there is nothing to narrow.

Parameter Type Constraint What it does
Policy String 1 to 2,048 characters Inline IAM policy JSON used as a scope-down; result is the intersection with the caller’s permissions
DurationSeconds Integer 1 to 129,600 (36 hours) Lifetime of the scoped credentials; if omitted they inherit the caller’s expiration
ScopedSessionDescription String 2 to 256 characters Free-text description that is logged to CloudTrail
MinimumSessionTokenSize Integer 0 to 4,096 bytes Pads the session token to at least this size; 0 or unset leaves it unchanged

Three details deserve attention. First, the 36-hour ceiling on DurationSeconds is a field limit, not a promise. The API cannot extend a session, so a request longer than the caller’s remaining lifetime fails with InsufficientSessionLifetime. In practice your ceiling is whatever time is left on the orchestrator session. Second, the 2,048-character limit applies to the plaintext policy, but AWS also compresses policies into a packed binary format with its own limit, and exceeding that returns PackedPolicyTooLarge. Third, MinimumSessionTokenSize exists so you can test that downstream systems, such as a credential cache with a fixed column width, survive larger tokens before they appear in production. The response warns not to assume any maximum token size.

The response returns the usual Credentials object (access key ID, secret key, session token, expiration) plus fields that are specific to scoping. ScopedPoliciesCount tells you how many scope-down layers now sit on the session. SessionTokenSize and SessionTokenUtilization report the token’s size in bytes and as a percentage of the maximum allowed. SessionInfo returns a scoped session ID and ARN that match the calling session’s principal and session name, and SourceIdentity is carried forward unchanged.

Scope only narrows, and layers stack

The IAM User Guide page on controlling access to GetScopedCredentials defines effective permissions as the intersection of three things. Those are the calling session’s permissions, the scope-down policy in the current request, and every scope-down policy from earlier calls in a recursive chain. A scope-down policy can only remove access. If the orchestrator’s role cannot write to DynamoDB, no policy passed to GetScopedCredentials can make the sub-agent able to.

The recursive part is the most important design difference from session policies. A session that was itself created by GetScopedCredentials can call GetScopedCredentials again, adding another independent layer. Earlier restrictions are never removed. With AssumeRole, a new session policy replaces the previous one, because each assume creates a fresh session. The API reference caps the stack at three scope-down policy layers. A fourth call that includes a Policy is denied. This gives you a natural three-tier hierarchy: orchestrator to sub-agent, sub-agent to tool worker, tool worker to single task.

Layering means you can delegate without trusting the delegate’s policy author. A sub-agent framework can scope its own credentials further for a risky tool call, and even if that framework writes an over-broad policy, it still cannot exceed what the orchestrator granted one layer up. The intersection guarantees monotonic narrowing.

Identity is preserved, which cuts both ways

GetScopedCredentials does not create a new principal. The IAM guide states that the principal ARN, role session name, session tags (including transitive tag keys), source identity, and context keys such as aws:SourceIp and Trusted Identity Propagation context carry over unchanged. You cannot add or modify session tags, and you cannot set or change source identity, on a scoped call.

The upside is that existing attribute-based access control (ABAC) keeps working. If your S3 bucket policy conditions on aws:PrincipalTag/project, the scoped credentials still carry that tag. The orchestrator cannot forge a different project tag for a sub-agent, because tags are frozen. A human’s SourceIdentity set at the first AssumeRole follows every scoped credential, so you can always trace a sub-agent’s action back to the person or job that started the run.

The downside is attribution inside the run. Because the scoped session ARN matches the parent’s, a CloudTrail userIdentity.arn for a sub-agent call looks the same as one from the orchestrator. If you want to know which sub-agent made a call, you have to design for it. The tool AWS gives you is ScopedSessionDescription, which is logged to CloudTrail on the issuing call. Step 7 below shows how to use it, together with the issued access key ID, for correlation.

Duration rules escape the role-chaining cap

Role chaining caps a re-assumed role session at one hour. The IAM guide states that GetScopedCredentials does not have this cap. If an orchestrator holds a 12-hour session, it can hand a long-running batch sub-agent eight hours of scoped credentials without the one-hour wall. Without DurationSeconds, scoped credentials keep the caller’s remaining session time. With it, they can be shorter but not longer.

For least privilege, shorter is the point. A sub-agent that should finish a retrieval in two minutes does not need sixty. Matching credential lifetime to expected task time shrinks the window in which leaked keys are useful. You can also enforce a maximum centrally: the sts:DurationSeconds condition key works on this action, so an SCP can deny any GetScopedCredentials request above, say, 900 seconds.

How to Use GetScopedCredentials for AI Agents: Step by Step

The steps below build a working pattern for an orchestrator that spawns sub-agents. The policy JSON follows the documented IAM grammar. The SDK and CLI calls are illustrative: the operation name and parameters come from the API reference, but the Python method name and CLI subcommand follow standard AWS SDK naming conventions and were not checked against a released SDK changelog at the time of writing. Confirm them against your SDK version before relying on them.

  1. Allow sts:GetScopedCredentials for the orchestrator role only, and add an SCP duration guardrail.
  2. Start the orchestrator in an assumed-role session with a SourceIdentity.
  3. Write one scope-down policy template per sub-agent capability.
  4. Call GetScopedCredentials once per sub-agent with a policy, a duration and a description.
  5. Hand the scoped keys to the sub-agent process, never through the model context.
  6. Let sub-agents narrow further for risky tools, up to three layers.
  7. Audit with CloudTrail by correlating descriptions and access key IDs.
  8. Plan revocation at the parent-session level.

Step 1: Allow the call, and only where it belongs

The caller needs sts:GetScopedCredentials in its effective permissions. Standard implicit deny applies, so nothing can call it until you allow it. The minimal statement from the IAM guide looks like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowScopingOwnSession",
      "Effect": "Allow",
      "Action": "sts:GetScopedCredentials",
      "Resource": "*"
    }
  ]
}

Attach it to the orchestrator role. Whether sub-agents also get it is a design decision. If you want sub-agents to self-scope for risky tools (Step 6), their scoped policy must still include sts:GetScopedCredentials; if you leave it out, the chain stops at one layer. That is a useful lever: omit the action from leaf-level policies so a worker cannot mint anything.

Next, put a ceiling on lifetime across the organization. The IAM guide documents sts:DurationSeconds as a condition key for this action. This SCP denies any request asking for more than 15 minutes:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "CapScopedCredentialLifetime",
      "Effect": "Deny",
      "Action": "sts:GetScopedCredentials",
      "Resource": "*",
      "Condition": {
        "NumericGreaterThan": { "sts:DurationSeconds": "900" }
      }
    }
  ]
}

One subtlety: if a caller omits DurationSeconds, the scoped credentials inherit the parent’s remaining lifetime. Whether a NumericGreaterThan condition evaluates when the key is absent depends on standard IAM condition semantics, under which a missing key generally makes the condition not match. If you need to force every call to declare a duration, add a second deny statement using the Null condition operator on sts:DurationSeconds. Test both statements with the IAM policy simulator or a sandbox account before rolling them out.

Step 2: Start the orchestrator with a traceable identity

GetScopedCredentials only works with temporary credentials, such as an assumed role or a federated session. IAM user and root credentials are rejected. If a legacy job runs as an IAM user, the API reference tells you to call GetSessionToken first and then scope those credentials.

The better pattern is an orchestrator role assumed per run, with SourceIdentity set to the human or pipeline that started it. Because source identity is carried forward and cannot be changed by scoped calls, every downstream sub-agent action inherits it. Set session tags at this step too, for example run_id and tenant. Tags are frozen after this point, so this is your only chance to stamp ABAC attributes on the whole tree.

Size the orchestrator session to the longest expected run. Sub-agents cannot receive credentials that outlive their parent, and the role’s maximum session duration bounds the parent. If the orchestrator session is one hour and a sub-agent asks for 90 minutes, STS returns InsufficientSessionLifetime.

One more constraint: the API is not available on the STS global endpoint. Configure your SDK to use the regional endpoint, for example sts.us-east-1.amazonaws.com, which is also the sample endpoint in the API reference. Most current SDKs default to regional STS endpoints, but older configurations may still pin the global one.

Step 3: Write one policy template per capability

Design scope-down policies around capabilities, not around individual agents. A “read the knowledge base” template, a “query the orders table” template and a “read application logs” template can be reused across many runs. Parameterize them with the resource ARNs for the current tenant or run.

Here is an allow-list template for a retrieval sub-agent. It permits listing and reading under one prefix and nothing else:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListOnePrefix",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::kb-docs-prod",
      "Condition": { "StringLike": { "s3:prefix": ["tenant-42/*"] } }
    },
    {
      "Sid": "ReadOnePrefix",
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::kb-docs-prod/tenant-42/*"
    }
  ]
}

Allow-lists are the default for untrusted sub-agents. For a trusted worker that needs most of the parent’s power, the IAM guide documents a deny-list pattern: an Allow statement with NotAction. The effective permissions become the caller’s permissions minus the excluded actions.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "EverythingExceptDestructive",
      "Effect": "Allow",
      "NotAction": [
        "ec2:TerminateInstances",
        "rds:DeleteDBInstance",
        "s3:DeleteObject",
        "sts:AssumeRole*"
      ],
      "Resource": "*"
    }
  ]
}

Note the sts:AssumeRole* exclusion. Without it, a scoped worker could assume another role and step outside the scope-down layer entirely, because a fresh AssumeRole session is not bound by the previous session’s scope. Always strip role-assumption actions from scoped policies unless a sub-agent genuinely needs cross-role access.

Keep templates small. The 2,048-character plaintext limit is tight once you add several resource ARNs and conditions. Prefer wildcards on well-structured prefixes over long ARN lists, and drop whitespace when you serialize the JSON.

Step 4: Mint scoped credentials per sub-agent

The orchestrator now calls the API once per sub-agent. The Python below is illustrative: it assumes boto3 exposes the operation as get_scoped_credentials, following the SDK’s usual snake-case convention. The parameter names match the API reference.

# Illustrative only: verify the method name against your boto3 version.
import json
import boto3

sts = boto3.client("sts", region_name="us-east-1")  # regional endpoint required

def scoped_creds_for(template: dict, seconds: int, label: str) -> dict:
    policy = json.dumps(template, separators=(",", ":"))  # compact JSON saves characters
    if len(policy) > 2048:
        raise ValueError(f"scope-down policy is {len(policy)} chars; limit is 2048")
    resp = sts.get_scoped_credentials(
        Policy=policy,
        DurationSeconds=seconds,
        ScopedSessionDescription=label,  # logged to CloudTrail
    )
    if resp.get("SessionTokenUtilization", 0) > 80:
        # Close to the packed-size ceiling; further layers may fail.
        print(f"warning: token utilization {resp['SessionTokenUtilization']}%")
    return resp["Credentials"]

retrieval = scoped_creds_for(
    RETRIEVAL_TEMPLATE, 600, "run-7f3a sub=retrieval tool=s3-read"
)

For quick testing from a shell, the CLI equivalent would follow the usual pattern. Again, treat the subcommand name as illustrative until you confirm it in aws sts help on your installed version:

# Illustrative: confirm the subcommand exists in your AWS CLI version.
aws sts get-scoped-credentials \
  --region us-east-1 \
  --duration-seconds 600 \
  --policy file://retrieval-scope.json \
  --scoped-session-description "run-7f3a sub=retrieval"

Handle the documented errors explicitly. InsufficientSessionLifetime means you asked for more time than the parent has left; retry with a shorter duration or refresh the parent session first. MalformedPolicyDocument is a bug in your template renderer. PackedPolicyTooLarge means the policy plus existing session policies and tags no longer fit in the token; shorten the policy or reduce tags at Step 2. InvalidSubjectCredentials means the calling session itself is no longer valid, often because it was revoked.

Sequence diagram of AWS STS GetScopedCredentials: orchestrator requests scoped credentials, STS logs the call, the sub-agent reads S3 under its prefix and is denied on delete

Figure 2: The issuing call, the hand-off and an enforced denial. The sub-agent’s DeleteObject attempt fails because the scope-down policy never allowed it.

Figure 2 traces one sub-agent’s life. The orchestrator requests credentials, STS logs the call with its description, and returns keys plus the layer count. The orchestrator passes those keys to the sub-agent’s process. The sub-agent can read objects under its prefix. When a poisoned document convinces it to delete something, S3 returns AccessDenied. The keys then expire on schedule.

Step 5: Hand credentials to the process, never to the model

The most common mistake in agent credential design is letting secrets flow through the LLM’s context window. Scoped keys pasted into a system prompt can be echoed into logs, tool outputs, or a reply to the user. Treat the model as untrusted with respect to secrets.

Instead, inject scoped credentials into the sub-agent’s runtime. Options include environment variables on a child process (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), a dedicated boto3 Session object created inside the tool executor, or an SDK credential_process helper that asks the orchestrator for fresh scoped keys. The tool code signs requests; the model only sees tool results.

Isolation matters too. If all sub-agents run as threads in one Python process with shared memory, a compromised tool can read another tool’s credentials object. Stronger separation comes from separate processes, containers, or microVMs. Our comparison of sandboxing AI agent code execution covers those isolation trade-offs in depth.

Refresh is the other runtime concern. Scoped credentials expire; a long-running sub-agent will need new ones. Let the orchestrator own refresh, and have it re-mint from its own session rather than letting the sub-agent re-scope itself repeatedly. That keeps the layer count low and the policy authorship in one place.

Step 6: Narrow again for risky tools

Recursion is where the API earns its place in agent stacks. A sub-agent that holds layer-one credentials can call GetScopedCredentials again to drop to a single action for one dangerous tool call. For example, a coding sub-agent with read access to a repository bucket might mint a 60-second credential limited to s3:PutObject on one key before writing an artifact.

AWS STS GetScopedCredentials policy layering: role policies and session policy form the orchestrator session, then up to three scope-down layers narrow access, and a fourth Policy layer is denied

Figure 3: Effective permissions are an intersection at every layer. Three scope-down layers are allowed; a fourth call with a Policy is denied.

Figure 3 shows the stacking. The orchestrator session already reflects the role’s identity policies, any permissions boundary, SCPs and any session policy passed at assume time. Each scope-down layer intersects with everything above it. After three layers, a further call that includes a Policy is denied. The API reference says the fourth Policy attempt is denied; whether a fourth call that only shortens DurationSeconds succeeds is not stated, so do not design around it.

Use the layer budget deliberately. A practical allocation is: layer 1 for the orchestrator-to-sub-agent split, layer 2 for a sub-agent’s per-tool narrowing, and layer 3 held in reserve for one-shot actions. Monitor ScopedPoliciesCount in responses so your code knows how many layers remain.

Step 7: Audit sub-agents with CloudTrail

The announcement promises that every GetScopedCredentials call is logged in CloudTrail. The IAM guide adds specifics. The event’s sessionContext.attributes include a creationDate, mapped from aws:TokenIssueTime, which shows when the parent session was created, while eventTime shows when the scoped call happened. The response portion includes scopedSessionId, sessionTokenUtilization, sessionTokenSize and scopedPoliciesCount. The request’s ScopedSessionDescription is logged as well.

That gives you two levels of CloudTrail agent auditing. The first is issuance: who minted scoped credentials, when, for how long, with what description, and how deep the layer stack was. The second is usage: the API calls made with those credentials, which appear under the same session ARN as the parent.

To separate sub-agents in the usage events, correlate on the access key ID. Each GetScopedCredentials call returns a new access key ID, and CloudTrail records userIdentity.accessKeyId on every downstream API event. Whether the issuing event’s responseElements includes the new access key ID, as AssumeRole events do, is not stated on the pages reviewed for this article. Check one event in your own trail. If it is present, a join on access key ID maps every downstream call to the description of the sub-agent that received it.

The query below is illustrative CloudTrail Lake SQL. Column names follow the CloudTrail Lake event schema, but adjust the paths to what your event data store actually shows:

-- Illustrative: verify field paths against your own GetScopedCredentials events.
SELECT
  eventTime,
  userIdentity.arn                          AS session_arn,
  userIdentity.sessionContext.sourceIdentity AS started_by,
  element_at(requestParameters, 'scopedSessionDescription') AS sub_agent,
  element_at(requestParameters, 'durationSeconds')          AS ttl_seconds,
  element_at(responseElements, 'scopedPoliciesCount')       AS layers
FROM <event_data_store_id>
WHERE eventSource = 'sts.amazonaws.com'
  AND eventName   = 'GetScopedCredentials'
  AND eventTime   > '2026-11-30 00:00:00'
ORDER BY eventTime DESC;

Two alerting rules are worth building on top. Alert when layers reaches 3, because something is using the full stack and the next scoping attempt will fail. Alert on repeated AccessDenied errors from the same access key ID in a short window, because a scoped sub-agent hammering denied actions is a strong prompt-injection signal. Remember that S3 object-level calls only appear if you enable data events for the bucket, which carries its own CloudTrail cost.

Make the description machine-parseable. A string like run-7f3a sub=retrieval tool=s3-read is easy to split in queries. Keep personal data out of it, since it lands in logs that many people can read.

Step 8: Plan revocation at the parent level

Revocation is where scoped credentials behave least like separate identities. The IAM guide states that scoped credentials inherit the aws:TokenIssueTime of the parent session, including through recursive calls. When you revoke sessions in the IAM console, AWS attaches the AWSRevokeOlderSessions inline policy to the role, which denies sessions issued before a timestamp. Because scoped credentials share the parent’s issue time, they die with the parent.

The flip side is documented too: you cannot revoke scoped credentials separately from their parent session using aws:TokenIssueTime. If one sub-agent misbehaves, the clean IAM-native kill switch takes out the whole run. Plan for that. Options include keeping runs short so a full revoke costs little, giving the orchestrator its own kill path that stops issuing and refreshing for one sub-agent, and relying on short DurationSeconds so a leaked scoped key expires quickly on its own. If you need incident steps for leaked keys more broadly, see our playbook on detecting and responding to leaked cloud credentials.

There may be ways to deny one scoped key via other condition keys, such as a deny on a specific aws:userid or access key pattern, but AWS does not document a per-scoped-credential revocation pattern on the pages reviewed. Treat any such approach as experimental until AWS documents it.

Session Policy vs Scoped Credentials vs AgentCore Identity

GetScopedCredentials is one of three AWS tools for agent credentials, and they solve different problems. AssumeRole session policies scope a new identity at the moment of assumption. GetScopedCredentials scopes the identity you already have, repeatedly and cheaply. Amazon Bedrock AgentCore Identity manages agent identities and outbound credentials for non-AWS systems.

Question AssumeRole + session policy GetScopedCredentials AgentCore Identity
Changes the principal? Yes, to the target role No, identity preserved Gives each agent its own workload identity
Needs a trust policy? Yes, on every target role No Configured per agent identity
Repeated narrowing Each assume replaces the session policy Layers stack, up to 3 Not its purpose
Lifetime limit Role max; 1 hour when chained Parent’s remaining time; no chaining cap Depends on token type and provider
Session tags and source identity Can be set at assume time Frozen, inherited Not applicable to STS tags
Cross-account access Yes No, same principal Not its purpose
Non-AWS APIs (OAuth, API keys) No No Yes, via token vault and OAuth flows
Per-credential revocation Per session, by issue time Only with the parent Varies by credential type

The AgentCore Identity feature overview describes a central directory that gives each agent a unique ARN, a token vault that stores OAuth 2.0 tokens, OAuth client credentials and API keys encrypted with AWS KMS, and support for both the client credentials grant and the authorization code grant. It ships built-in providers for services like GitHub, Slack and Salesforce. That is a different job. An agent that calls Jira on a user’s behalf needs an OAuth token, not an AWS access key. An agent that reads S3 needs scoped AWS credentials. Many real systems need both.

Decision flow for agent credentials on AWS: choose AssumeRole for a different role or account, AgentCore Identity for non-AWS OAuth APIs, GetSessionToken then GetScopedCredentials for IAM users, and GetScopedCredentials for per-sub-agent narrowing

Figure 4: A decision path for picking the right AWS credential mechanism for an agent or sub-agent.

Figure 4 turns the matrix into a decision path. If the agent needs a different role or another account, use AssumeRole and attach a session policy there. If it calls non-AWS APIs that speak OAuth, use AgentCore Identity or an equivalent token broker. If it holds long-term IAM user keys, convert them with GetSessionToken first. If it already has temporary credentials and needs narrower ones for sub-agents, GetScopedCredentials is the native fit.

The combination pattern is common. An orchestrator assumes a tenant-specific role with a session policy that sets the outer boundary. It then uses GetScopedCredentials to split that boundary across sub-agents. Separately, AgentCore Identity supplies the GitHub or Slack tokens that some sub-agents need. Each mechanism covers one layer, and none needs to be stretched beyond its design.

Trade-offs, Gotchas, and What Goes Wrong

Cached KMS data keys can outlive a scope-down. The IAM guide warns that some services cache AWS KMS data keys without session-specific context. A scope-down that removes kms:Decrypt may not block access to data the session recently read. If your threat model depends on cutting off encrypted data, test it against the specific service rather than trusting the policy alone.

Some services may reject scoped credentials. The IAM guide lists Amazon MemoryDB, AWS Quick, Amazon CloudSearch, Amazon Neptune Database engine versions earlier than 1.2.0.0, and certain Amazon OpenSearch Service versions as cases where scoped credentials may be denied. Check this list before scoping a sub-agent that touches those services.

Same-account resource policies stop granting on their own. With ordinary AssumeRole credentials, a resource-based policy that names the principal can grant same-account access even without an identity policy. With scoped credentials, both the identity-based policy and the scope-down policy must allow the action. Buckets or queues whose access relied on Principal "*" or on naming the session principal directly may suddenly return AccessDenied. This is safer, but it breaks working setups.

Scoping is not intent validation. A scope-down limits which actions succeed, not why they happen. A sub-agent with s3:GetObject on a prefix can still be tricked into reading every object there and leaking the content through its output. Pair credential scoping with output filtering and data-classification rules.

Revocation is coarse. As covered in Step 8, you cannot cut one sub-agent off with aws:TokenIssueTime without cutting off its siblings. Short lifetimes are your main defence.

Token size grows with layers. Session policies and session tags count toward the packed size. Heavy ABAC tagging at Step 2 plus three verbose layers can hit PackedPolicyTooLarge. Watch SessionTokenUtilization and keep an eye on any system that stores tokens in fixed-width fields.

Regional endpoint only, temporary credentials only. Calls to the global STS endpoint fail, and so do calls with IAM user or root keys. Both show up as confusing errors in older automation.

Anti-pattern: one giant deny-list. NotAction scoping is convenient, but every new AWS service action you forgot to list is allowed by default. Reserve deny-lists for trusted workers; give LLM-driven sub-agents allow-lists.

Practical Recommendations

Start with one orchestrator role per agent application, assumed per run with a SourceIdentity and the session tags you need for ABAC. That single decision fixes attribution for everything below it. Then write a small library of capability templates, each an allow-list under a few hundred characters, and mint scoped credentials per sub-agent with durations that match the task rather than the parent.

Keep secrets out of the model context. The sub-agent’s tool executor should hold the credentials; the LLM should only see results. Run sub-agents in separate processes or sandboxes when they handle untrusted content. Reserve recursive scoping for genuinely risky tool calls, and track ScopedPoliciesCount so you never surprise yourself at the third layer.

Treat audit as part of the design, not an afterthought. A structured ScopedSessionDescription and a verified access-key correlation turn CloudTrail into a per-sub-agent activity log. Finally, decide your revocation story before an incident: short runs and short credentials, plus an orchestrator that can stop refreshing a single sub-agent.

  • [ ] Allow sts:GetScopedCredentials on the orchestrator role; omit it from leaf policies.
  • [ ] Add an SCP capping sts:DurationSeconds, and test missing-key behaviour.
  • [ ] Set SourceIdentity and session tags at the first AssumeRole.
  • [ ] Use regional STS endpoints everywhere the API is called.
  • [ ] Write allow-list templates per capability; strip sts:AssumeRole* from all of them.
  • [ ] Inject credentials into processes, never into prompts.
  • [ ] Log a parseable ScopedSessionDescription; verify access-key correlation in your trail.
  • [ ] Check the unsupported-services list and KMS caching behaviour for your stack.
  • [ ] Alert on layer count 3 and on bursts of AccessDenied per access key.

Frequently Asked Questions

What is AWS STS GetScopedCredentials?

GetScopedCredentials is an AWS Security Token Service API, announced on November 19, 2026, that takes temporary credentials the caller already holds and returns new credentials with fewer permissions, a shorter lifetime, or both. The new credentials keep the caller’s identity, session tags and source identity. They can never exceed the caller’s permissions, because the effective permissions are the intersection of the caller’s permissions and the scope-down policy. AWS positions it for AI agents, sub-agents and workloads that need narrower, task-specific credentials without assuming another role.

How is GetScopedCredentials different from an AssumeRole session policy?

An AssumeRole session policy scopes a new role session at the moment you assume it, and each new assume replaces the earlier session policy. GetScopedCredentials scopes the session you already have without changing identity or needing a trust policy. Its scope-down policies stack as independent layers, up to three, so earlier restrictions can never be removed. It also escapes the one-hour role-chaining cap: scoped credentials can last as long as the parent session’s remaining time. Use AssumeRole to change role or account, and GetScopedCredentials to subdivide.

Can I call GetScopedCredentials with IAM user access keys?

No. The API reference states the operation works only with temporary credentials, such as an assumed role or a federated session, and rejects IAM user and root credentials. If a job still uses an IAM user, call GetSessionToken first to obtain temporary credentials, then call GetScopedCredentials with those. The better long-term fix is moving the workload to an assumed role, ideally with a SourceIdentity, so attribution flows to every scoped credential the job later mints for its sub-agents.

How long can scoped credentials last?

The DurationSeconds field accepts 1 to 129,600 seconds, which is 36 hours, but the API can never extend a session. Scoped credentials cannot outlive the calling session, and a request longer than the remaining lifetime fails with InsufficientSessionLifetime. If you omit the field, the credentials inherit the caller’s expiration. Unlike role chaining, which caps a chained session at one hour, GetScopedCredentials has no one-hour cap. You can enforce a shorter organizational maximum with an SCP on the sts:DurationSeconds condition key.

Can I revoke one sub-agent’s scoped credentials without affecting others?

Not with the documented aws:TokenIssueTime revocation mechanism. Scoped credentials inherit the parent session’s token issue time, including through recursive calls, so revoking older sessions on the role revokes the parent and every scoped child together. AWS explicitly states you cannot revoke scoped credentials separately that way. In practice, rely on short DurationSeconds values, keep orchestrator runs short so a full revoke is cheap, and have the orchestrator stop refreshing credentials for a misbehaving sub-agent.

How do I tell which sub-agent made an API call in CloudTrail?

Scoped credentials share the parent’s session ARN, so userIdentity.arn alone will not distinguish sub-agents. Set a structured ScopedSessionDescription on each call, which CloudTrail logs on the issuing event, and correlate the new access key ID with userIdentity.accessKeyId on downstream events. Confirm in your own trail that the issuing event records the issued access key ID before relying on the join. SourceIdentity, inherited unchanged, links every call back to the human or pipeline that started the run.

Further Reading

By Riju — about

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *