Here’s a pattern I see constantly. A workload runs under one IAM role. That role has to be broad enough for everything the workload might do. Then the workload hands its credentials to something it trusts less: an AI agent, a sub-agent, a plugin or a per-tenant worker. Suddenly that component can do everything the parent role can do.
Until now, the honest answers were “create more roles and chain AssumeRole calls” or “use session policies on AssumeRole and accept the plumbing.” On 20 November 2026 AWS added a cleaner option: GetScopedCredentials, a new AWS STS API that takes the temporary credentials you already have and returns a narrower copy.
What it does
You call GetScopedCredentials with your existing temporary credentials, whether they come from aws login, an EC2 instance profile, a Lambda execution role or similar. You pass one or both of:
- A scope-down policy: an inline policy describing the maximum permissions the new credentials can have.
- A shorter duration: anything up to the remaining lifetime of the calling session.
The effective permissions are the intersection of your current session and the scope-down policy, so they can only ever go down. Crucially, the new credentials keep the same identity: same role ARN, same role session name, same session tags. You aren’t minting a new principal. You’re putting a tighter fence around the existing one.
You can also call it again with the scoped credentials, up to three scope-down policies deep, each intersecting with the ones before. An orchestrating agent can therefore hand each sub-agent a narrower slice of its own access, and a sub-agent can never end up with more than its parent.
Use case 1: AI agents
This is the obvious one, and clearly the reason the API exists. An agent decides at runtime what to do, often based on prompts and tool output you don’t control. If its credentials are over-permissive, one bad decision (or one successful prompt injection) can go well beyond the task you set it.
Two approaches work:
- Allow-list: scope the agent down to exactly what the task needs, for example
s3:GetObjecton a single bucket for five minutes. - Deny-list guardrail: keep most of the session’s permissions but strip out the dangerous ones. Because a scope-down policy can’t grant anything, an
AllowwithNotActionis safe to use here:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"NotAction": [
"iam:*",
"organizations:*",
"account:*",
"sts:AssumeRole*",
"s3:DeleteBucket",
"ec2:TerminateInstances",
"rds:DeleteDBInstance",
"dynamodb:DeleteTable"
],
"Resource": "*"
}]
}
That’s a quick, readable guardrail. No IAM changes, no role escalation paths, no deleting the production database.
One important caveat: scoping the credentials only helps if the agent can’t reach the original ones. If the agent can read the instance metadata service or the parent process’s environment, it can simply use the broader credentials. Run agents in a sandbox or isolated environment where the scoped credentials are the only ones available.
Use case 2: multi-tenant applications
This is the one I think will get the most production use. Picture a SaaS app storing each tenant’s files under their own prefix in a shared S3 bucket, served by a single IAM role. The role can read every tenant’s data, so tenant isolation depends entirely on the application code getting it right every time.
With GetScopedCredentials, a trusted credential broker authenticates the request, works out the tenant, and scopes the credentials down to that tenant’s prefix before passing them to the worker. If the worker has a bug, or is exploited, S3 itself refuses access to other tenants’ data. Isolation moves from “we hope the code is right” to “IAM enforces it.”
Calling it
aws sts get-scoped-credentials \
--policy file://scope-down-policy.json \
--duration-seconds 300 \
--scoped-session-description report-status-job \
--region eu-west-2
The caller needs sts:GetScopedCredentials in its own policy. If you want to scope down recursively, every earlier scope-down policy must also allow that action. Note that at launch the inline policy is limited to 2,048 characters, so be concise or use wildcards carefully.
If you don’t want to write the policy by hand, AWS’s open-source IAM Policy Autopilot can analyse the SDK calls in your code and generate a starting policy, including as an MCP server for your coding assistant. Treat its output as a draft: it uses wildcards where it can’t infer specific resources, and you should tighten those before relying on it.
Auditing and governance
Every call is logged in CloudTrail, including the scope-down policy, the duration and the optional session description. Later API calls made with the scoped credentials show the scoped session’s access key ID, which you can trace back to its parent. That’s a meaningful improvement for incident response: you can tell which agent or task did something, not just which role.
For platform teams, the controls you’d expect are there:
- Control
sts:GetScopedCredentialsin identity policies, permission boundaries and SCPs. - Cap lifetimes with the
sts:DurationSecondscondition key. - Restrict who can call it and from where with
aws:PrincipalArn,aws:PrincipalTagandaws:SourceVpce.
It’s available in all commercial, GovCloud and China Regions, with a dedicated quota of 200 requests per second per account per Region. Most services accept scoped credentials, but check the unsupported services list before you build on it.
Where I’d use it first
- Any agent framework you’re running against AWS. Make scope-down the default wrapper before credentials reach an agent or tool.
- CI/CD pipelines. Give each stage only what it needs (plan versus apply, build versus deploy) without a separate role for each stage.
- Multi-tenant data paths, where IAM-enforced tenant isolation is a big improvement on application-only checks.
- Break-glass and support tooling, issuing short-lived, narrowly scoped credentials for a specific investigation.
It isn’t a replacement for well-designed roles, and it’s only as good as the isolation around whoever holds the original credentials. But as a building block for least privilege at runtime, it fills a real gap. In an estate of 100+ accounts, avoiding yet another wave of narrowly scoped roles is a win in itself.
Sources: AWS Security Blog: Scope down permissions of existing sessions using AWS STS GetScopedCredentials, AWS STS API reference.