1. Resources
  2. Identity Threats
  3. AWS

AWS STS GetFederationToken and GetSessionToken Persistence

Also known as: GetFederationToken persistence, Federated user session, STS session token persistence, Temporary credentials that survive key deletion

An attacker with an IAM user's access key mints STS temporary credentials that stay valid for up to 36 hours, even after the stolen key is deactivated or deleted.

Platform
AWS
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
Medium
Privileges required: Any authenticated identity
The long-term access key of an IAM user (or root). GetSessionToken needs no permission; GetFederationToken needs sts:GetFederationToken, often granted by a wildcard.
What the attacker gains
Temporary credentials with the user's permissions that outlive the stolen key by up to 36 hours, and a console session without the user's password or MFA device.

How it works

AWS STS has two operations that return temporary credentials without any role and therefore without any trust policy: GetSessionToken and GetFederationToken. Both are called with the long-term access key of an IAM user (or of the root user), and both return an access key ID that starts with ASIA, a secret key and a session token.

The attack rests on one property: the session is independent of the key that requested it. Temporary credentials are valid until their own expiry and cannot be revoked as such. Deactivating, rotating or deleting the access key that minted them doesn't end them. An attacker who expects a stolen key to be found mints a session first, and keeps working after the responder has "fixed" the key.

The two operations differ in what the session can do:

GetSessionToken GetFederationToken
Permission needed None. AWS states that policies can't control it sts:GetFederationToken
Duration 15 minutes to 36 hours, default 12 hours; 1 hour for root The same
Permissions of the session The same as the IAM user Intersection of the user's policies and the session policy passed in the call; none if no policy is passed
IAM API Blocked unless MFA was supplied in the request Blocked over the CLI and API; allowed in a console session
STS API AssumeRole and GetCallerIdentity among the few allowed GetCallerIdentity among the few allowed; no AssumeRole
Identity in later calls The IAM user arn:aws:sts::<account>:federated-user/<name>

GetFederationToken credentials can also be exchanged at the AWS sign-in federation endpoint for a console URL. That gives an interactive session with no console password and no MFA device of the user involved, and in the console the session can use IAM.

Because no role is involved, a review that only looks at roles and trust policies misses this path. There is also no durable object to find afterwards: the persistence mechanism is the credential itself.

Prerequisites

  • A valid long-term access key (AKIA...) of an IAM user, or of the root user. See AWS access key theft. Role credentials can't be used.
  • For GetFederationToken: an identity policy that allows sts:GetFederationToken. Administrator policies and sts:* include it.
  • For the IAM API through GetSessionToken: the user's MFA serial number and a current code. Without them, the session still reaches every other service the user can use.
  • The attacker must act before the key is contained. After that, only sessions that already exist keep working.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Confirm the identity and mint a session

aws sts get-caller-identity

# Same permissions as the user, 36 hours
aws sts get-session-token --duration-seconds 129600

# With MFA, so the session may also call IAM
aws sts get-session-token \
    --duration-seconds 129600 \
    --serial-number arn:aws:iam::111122223333:mfa/alice \
    --token-code 123456

2. Mint a federated user session

A session policy is needed, or the session has no permissions. A managed policy ARN keeps the session as wide as the user's own policies allow:

aws sts get-federation-token \
    --name backup-broker \
    --policy-arns arn=arn:aws:iam::aws:policy/AdministratorAccess \
    --duration-seconds 129600

The response contains Credentials and a FederatedUser ARN such as arn:aws:sts::111122223333:federated-user/backup-broker. The name is the attacker's choice, between 2 and 32 characters.

3. Use the session

export AWS_ACCESS_KEY_ID=ASIAEXAMPLEKEYID
export AWS_SECRET_ACCESS_KEY=EXAMPLESECRETKEY
export AWS_SESSION_TOKEN=EXAMPLESESSIONTOKEN
aws sts get-caller-identity

These credentials keep working when the original AKIA key is set to inactive or deleted.

4. Turn the federation token into a console session

Send the three values as a JSON string to the federation endpoint. Don't add SessionDuration: AWS documents that the request fails when it is used with GetFederationToken credentials.

SESSION='{"sessionId":"ASIAEXAMPLEKEYID","sessionKey":"EXAMPLESECRETKEY","sessionToken":"EXAMPLESESSIONTOKEN"}'

curl -s -G https://signin.aws.amazon.com/federation \
    --data-urlencode "Action=getSigninToken" \
    --data-urlencode "Session=$SESSION"

The endpoint returns a JSON document with one element, SigninToken. Build the sign-in URL with it and open it in a browser within 15 minutes:

https://signin.aws.amazon.com/federation?Action=login&Issuer=example.com&Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F&SigninToken=<SigninToken>

In the console the federated user can open IAM and create users, access keys, roles or login profiles, limited only by the IAM user's own policies and the session policy. That is how a 36-hour session becomes lasting access, for example through access key creation.

5. Renew while the key lives

As long as the long-term key works, the attacker can mint new sessions with later expiry times. Each call resets the 36-hour clock.

Impact

Access that survives the first containment step. The usual response to a leaked key is to deactivate it, and that leaves every session minted from it untouched for up to 36 hours. During that window the attacker has the user's permissions over the API, and through the console step they can make changes in IAM that outlast the session. With root user credentials the session lasts one hour at most, but it carries root permissions.

The technique also weakens MFA as a control: a GetSessionToken session minted with one valid code satisfies aws:MultiFactorAuthPresent conditions for the rest of its lifetime.

OPSEC and artifacts

  • One event at issuance, none for the key's death. GetSessionToken and GetFederationToken are written to CloudTrail under sts.amazonaws.com with the IAM user in userIdentity and the stolen key in userIdentity.accessKeyId. requestParameters shows durationSeconds, and for a federation token the name and the session policies. Unlike AssumeRole, both are logged as write events.
  • Operators choose the session name and a normal duration. A federated user named like a real broker and the default 12 hours draws less attention than --duration-seconds 129600. The name still appears in responseElements.federatedUser.arn and in later events.
  • Later calls don't look alike. Calls made with GetSessionToken credentials are recorded as the IAM user, with an ASIA access key ID and sessionContext.attributes.creationDate. Calls made with a federation token have userIdentity.type of FederatedUser, and sessionContext.sessionIssuer names the IAM user behind it. A hunt keyed only on role sessions misses both.
  • The console step adds two events. GetSigninToken under signin.amazonaws.com, then ConsoleLogin. A console sign-in for an IAM user that has no console password is hard to explain.
  • Activity after DeleteAccessKey or UpdateAccessKey. Events from the same user identity, signed with an ASIA key, after the long-term key was removed are the clearest artifact of this technique.
  • STS records land in the Region of the endpoint that served the call. Requests to the global endpoint are logged in us-east-1.

Detection

  • Issuance by the wrong identity. GetFederationToken is built for identity brokers. A person's or a workload's access key calling it is the key signal. The federation token and console session rules cover it on GetFederationToken, together with GetSigninToken and ConsoleLogin by a federated user.
  • Long durations. requestParameters.durationSeconds near 129600, or an administrator policy as the session policy.
  • GetSessionToken without a reason. It is normal for users who work with MFA-protected API access. From a service user's key, or from a new source address, it isn't.
  • Use after containment. Any event for the user after DeleteAccessKey or a key set to inactive with UpdateAccessKey.
-- Athena, CloudTrail table: sessions minted from long-term keys, with requested duration
SELECT
    eventtime,
    eventname,
    useridentity.arn AS issuing_user,
    useridentity.accesskeyid AS long_term_key,
    sourceipaddress,
    useragent,
    json_extract_scalar(requestparameters, '$.durationSeconds') AS duration_seconds,
    json_extract_scalar(requestparameters, '$.name') AS federated_name,
    errorcode
FROM cloudtrail_logs
WHERE eventsource = 'sts.amazonaws.com'
  AND eventname IN ('GetSessionToken', 'GetFederationToken')
  AND eventtime >= '2026-11-01T00:00:00Z'
ORDER BY eventtime

Every IAM user can produce GetSessionToken rows, so narrow the result to the identities under review, and build an allow list of the brokers that legitimately call GetFederationToken.

Mitigation

  • Remove long-term keys. The technique needs an IAM user's access key. Workloads on roles and people on IAM Identity Center leave nothing to start from. See IAM user versus role and the risk of long-lived secrets.
  • Deny sts:GetFederationToken with a service control policy, with an exception for a named broker if one exists. GetSessionToken can't be denied by policy, so it has to be handled in response.
  • Delete root access keys, so nobody can mint a session as root.
  • Treat a stolen key as a stolen session. In the incident runbook, the first step is a deny on the IAM user for credentials issued before now. The condition key is only present on requests signed with temporary credentials, so it doesn't affect the user's long-term key:
{
  "Version": "2012-10-17",
  "Statement": {
    "Effect": "Deny",
    "Action": "*",
    "Resource": "*",
    "Condition": {
      "DateLessThan": { "aws:TokenIssueTime": "2026-11-29T12:00:00Z" }
    }
  }
}
aws iam put-user-policy \
    --user-name alice \
    --policy-name RevokeOlderSessions \
    --policy-document file://revoke-older-sessions.json
  • Then deactivate the key, replace it for the workload that owned it, and keep the deny in place for 36 hours. While the key still works, the attacker can mint a new session with a later issue time, so the order matters and both steps are needed. Deleting the IAM user also makes its temporary credentials fail.
  • Require MFA for sensitive actions with aws:MultiFactorAuthPresent, so a GetSessionToken session minted from a bare key can't call them.
  • Collect management events from every Region in an organization trail, so STS and sign-in events are not missed.

Detection rules for this attack

Log events to collect

FAQ

Does deleting a stolen access key end the sessions created with it?

No. AWS states that rotating the credentials of an IAM user does not invalidate temporary credentials obtained with them. A GetFederationToken or GetSessionToken session works until its own expiry, up to 36 hours. A deny policy on the user, conditioned on aws:TokenIssueTime, is what stops it.

What is the difference between GetSessionToken and GetFederationToken for an attacker?

GetSessionToken needs no permission and returns the user's own permissions, but its credentials can't call IAM unless MFA was supplied. GetFederationToken needs an explicit permission and a session policy, can't call IAM over the API at all, but can open a console session where that limit doesn't apply.

Can a role session call these operations?

No. Both must be called with the long-term credentials of an IAM user or the root user. Credentials from AssumeRole can't call GetFederationToken or GetSessionToken, so the technique starts from a stolen access key, not from a compromised workload role.

How long can such a session last?

From 15 minutes to 36 hours for an IAM user, with a default of 12 hours. Sessions requested with root user credentials are limited to one hour.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.