Skip to content

AWS STS GetScopedCredentials, introduced on November 20, derives credentials with narrower permissions or a shorter lifetime from temporary credentials you already hold. This post covers scope down policies, the CLI call, CloudTrail and the limits, plus Baseten's four trust boundaries.

Published

On November 20 the AWS Security Blog introduced GetScopedCredentials, a new API in AWS STS. AWS STS is the service that issues temporary security credentials, and this API takes temporary credentials you already hold and returns a set with narrower permissions, a shorter lifetime, or both.

  • Each agent, sub-agent or process can get its own credentials. The identity stays that of the calling session, and only the permissions and the lifetime shrink.
  • The resulting permissions are the intersection of the calling session's effective permissions and the scope down policy. They can never grow.
  • On the same day Baseten described how it protects more than 100 clusters with a threat model of four trust boundaries.

Image: devs7udio, how GetScopedCredentials computes permissions

The AWS post states the problem this way. When you pass credentials to an agent, the agent can use any permission those credentials carry. An agent decides which actions to take at runtime, often based on prompts or tool output. If the credentials are too permissive, an agent that makes a mistake can act outside the task you gave it.

The post covers two uses in detail.

  • Limiting what an agent can do. Before you pass credentials on, you keep only what the task requires, such as read access to a single S3 bucket. You can also do the opposite and keep most permissions while removing actions the agent should never perform, such as deleting resources. An orchestrating agent can do the same for each sub-agent it starts, and because scoping down only narrows permissions, a sub-agent never has more access than the agent that started it.
  • Scoping down on runtime context. Here the right permissions for a task are known only after a request arrives.

The example for the second use is a multi-tenant application. It stores each tenant's files under a separate prefix in one S3 bucket and serves every tenant with a single IAM role. The role can access every prefix, but each request should reach only the files of the tenant who sent it, and the application learns which tenant that is only after it authenticates the request. At that point a trusted credential broker inside the application takes the tenant details from the authenticated session and calls GetScopedCredentials with a scope down policy that allows only that tenant's prefix. The worker that handles the request receives only the scoped-down credentials. Amazon S3 then denies that worker access to other tenants' prefixes, even though the original role covers all of them.

You call the API with the temporary credentials you already use. The AWS post lists credentials from aws login, an Amazon EC2 instance profile and an AWS Lambda function as examples. Each call passes a scope down policy, a shorter duration, or both.

Temporary credentialsaws login, EC2 instance profile, Lambda
GetScopedCredentials callscope down policy, duration
Scoped-down credentialssame identity, fewer permissions, shorter lifetime
Agent or workerreceives only the scoped-down set
  • Temporary credentials → GetScopedCredentials call
  • GetScopedCredentials call → Scoped-down credentials
  • Scoped-down credentials → Agent or worker
Source: drawn from the AWS Security Blog post and the GetScopedCredentials API reference.

Three rules apply.

  • Permissions are an intersection. A scope down policy is an inline policy that describes the maximum permissions for the new credentials. The result is the overlap between the calling session's effective permissions and that policy, so permissions can only be reduced.
  • The lifetime cannot exceed what is left. If the requested duration is longer than the calling session's remaining lifetime, the request is rejected. If you omit the duration, the new credentials inherit the calling session's expiration time.
  • The identity does not change. Scoped-down credentials keep the calling session's ARN, role session name and session tags.

The API reference adds the calling requirements. GetScopedCredentials can be called only with temporary credentials. To scope down IAM user credentials you first call GetSessionToken to get temporary credentials, and root credentials cannot call it at all. The API is not available on the AWS STS global endpoint.

The AWS post shows two ways to write the policy. The first lists only the actions and resources the task needs. With the policy below, the new credentials can only read objects from a single S3 bucket.

Source codejson
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
  }]
}

With this approach you have to include every dependent action as well. The post uses Amazon Athena as the example. If the task queries data in Amazon S3 through Athena, the policy must also allow s3:GetObject on that data, because Athena reads it with your credentials.

The second way combines Allow with NotAction to remove only a few sensitive actions. A scope down policy can only reduce permissions, so this statement grants nothing extra. The new credentials keep the calling session's permissions except the listed actions, which is a quick way to block actions without listing everything a task needs. The policy below blocks identity and account management, assuming other roles, and deleting a few critical resources.

Source codejson
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "NotAction": [
      "iam:*",
      "organizations:*",
      "account:*",
      "sts:AssumeRole*",
      "s3:DeleteBucket",
      "ec2:TerminateInstances",
      "rds:DeleteDBInstance",
      "dynamodb:DeleteTable"
    ],
    "Resource": "*"
  }]
}

The post also shows how to draft a policy with a tool. IAM Policy Autopilot is an open source tool from AWS that analyzes the AWS SDK calls in your code and identifies the permissions it needs to run. It runs from the command line or as an MCP server in an AI coding assistant. The output is a draft, though. In the post's own example the tool could not infer specific resources from the code and returned wildcards such as table/* and key/*, and AWS tells you to replace them with the actions and resources the task should actually access.

You call the API with the latest AWS CLI or an AWS SDK. The calling session needs permission for the sts:GetScopedCredentials action. The command below is from the AWS post. It passes the policy together with a duration of 300 seconds and a description.

Source codebash
aws sts get-scoped-credentials \
  --policy '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::amzn-s3-demo-bucket/*"}]}' \
  --duration-seconds 300 \
  --scoped-session-description report-status-job \
  --region us-west-2

The response contains the new temporary credentials and a SessionInfo element. The ARN in SessionInfo matches the ARN of the calling session. ScopedPoliciesCount shows how many scope down policies apply to the session, and it does not increase when a call only shortens the duration.

There is a record as well. Every GetScopedCredentials call is logged in AWS CloudTrail, and the text passed in --scoped-session-description appears in the event. According to the API reference the description can be up to 256 characters. Later calls made with the scoped-down credentials show that session's access key ID in userIdentity.accessKeyId, which lets you trace back to its immediate parent session.

You can call GetScopedCredentials again with scoped-down credentials to narrow them further. Each new policy intersects with all earlier ones. For the repeat call to succeed, every earlier scope down policy must allow the sts:GetScopedCredentials action.

데이터 표
Scope down policy length2,048 charactersAt launch, one inline policy
Scope down policies per sessionUp to 3 layersCalls that only shorten the duration do not count
Duration1 second to 129,600 seconds (36 hours)No longer than the calling session's remaining lifetime
Request quota200 requests per secondAt launch, per account in each Region
Description256 charactersRecorded in the CloudTrail event
RegionsCommercial Regions, AWS GovCloud (US) Regions, China RegionsNot on the STS global endpoint

Source: the AWS Security Blog post and the GetScopedCredentials API reference

Access control works as it does for other actions. You can allow or deny sts:GetScopedCredentials in all relevant policy types. The sts:DurationSeconds condition key limits the lifetime of scoped-down credentials, and global condition keys such as aws:PrincipalArn, aws:PrincipalTag and aws:SourceVpce restrict who can call the API and from where.

The AWS post says scoped-down credentials work with most AWS services. Check the AWS documentation for the service you plan to use before you adopt the API.

Baseten provides inference infrastructure for AI models. In a post published on November 20 it explained how it holds one security standard across more than 100 clusters on more than 20 clouds. Those figures are Baseten's own. Hyperscalers hand over managed clusters with years of hardened defaults, the post says, while newer GPU clouds often arrive with public addresses and open ports. So Baseten evaluates every cluster and adds the controls it needs before the cluster serves traffic.

The starting point is a threat model with four trust boundaries.

Image: devs7udio, the four trust boundaries in the Baseten post

데이터 표
InfrastructureThe Baseten platform from a provider's hardware, network and defaultsA compromised provider, or a cluster that arrives exposed
Operating partnersBaseten from any third party that operates a layer of the stackA compromised partner, or stolen partner credentials
WorkloadsOne customer's code from other tenants and from the nodeMalicious or compromised customer code, or a compromised image
Internal accessBaseten engineers from production clustersMisused or stolen engineer access

Source: Baseten, How we secure 100+ clusters across 20+ clouds

Of the controls listed under each boundary, these are the ones that concern the scope of a credential.

  • Customer builds run in microVMs. A build runs arbitrary customer code with broad permissions, so each build gets its own kernel.
  • Network policy separates tenants. Customer secrets are encrypted and segregated by organization, and they are never put into images or code.
  • The deploy key a cluster uses to pull its configuration is per cluster and read-only. It cannot change what any cluster runs.
  • Each cluster has its own certificate authority. A token signed in one cluster is not valid in another.
  • Distribution credentials rotate within an hour.
  • Access logs leave the cluster, so someone with access to a cluster cannot erase the record of how they used it.
  • Customer data is wiped before machines go back to a provider.

Baseten assumes any boundary can fail and limits each credential to one cluster at most. The post ends with a checklist for auditing your own clusters or evaluating an infrastructure provider. Two of its items, least-privileged credentials and no standing administrative access to production clusters, carry the word "ideally", so they read as goals and not as a state already reached. The post does not name the microVM technology or give a specific patch cadence.

Interpretation: the two posts came out on the same day and deal with very different scales, yet they do the same thing. They reduce how far a single credential can reach. AWS does it per task, and Baseten does it per cluster. For a solo developer who lets an agent work in an AWS account, the AWS API is the part that is useful right away, because today the agent often runs with the full permissions of the developer's own session.

Interpretation: starting with the easy step is the practical order.

  • First block deletion and IAM changes with a NotAction policy. It works even when you do not know everything the agent does.
  • Use an allow-list policy for tasks that repeat. Give them a lifetime only as long as the task needs, such as 300 seconds.
  • Put the task name in the description. It makes it easier to find in CloudTrail which task did what.
  • Run the agent where it cannot read the parent credentials. AWS also tells you to run agents in isolated or sandbox environments. If broader credentials sit in a profile on the same machine, scoping down achieves nothing.

What a small team can take from the Baseten post is not the whole checklist but one question. If this key leaks, how far does it reach? Answering it for each key shows which ones should become read-only and which should live for a shorter time.

The limits at launch are 2,048 characters per policy and three layers. A design with several levels of sub-agents has to fit within three layers.