Skip to content

Response, New York. Noah Park: Check Point Patches Actively Exploited Management Server Path Traversal. Detection, Dallas. Ava Okello: Report Finds Nearly Half of Deployed Detections Need Attention Before SOCs Can Trust Them.

SOCtember

Always First. Fast SOC News.

AWS Identity and Access Management User Guide page, Permissions for temporary security credentials.
Screenshot: AWS Identity and Access Management User Guide, Permissions for temporary security credentials, Amazon Web Services (fair use).

Response

Did You Know: Rotating a Leaked AWS Access Key Does Not Cancel the Temporary Credentials Already Issued With It

AWS says temporary security credentials stay valid until they expire and cannot be revoked once issued. An intruder who used a stolen access key to mint session credentials can keep working for up to 36 hours after the key is rotated, unless responders deny those sessions by policy.

Noah Park, ResponseNew York3 min read

NEW YORK - When an AWS access key turns up in a public repository or an attacker's tooling, the first move is usually to deactivate it and issue a new one. That shuts the door the key opened. It does not close every session the key was used to start. The IAM User Guide says that after AWS Security Token Service issues temporary security credentials, they are valid through the expiration period and cannot be revoked. An AWS Security Blog post on exposed keys makes the same point for incident response: rotating the credentials for the IAM user whose credentials were exposed will not invalidate any temporary credentials that were obtained using them.

AWS STS API reference describing GetSessionToken session duration, from 15 minutes up to 36 hours.
Screenshot: AWS Security Token Service API Reference, GetSessionToken, Session Duration, Amazon Web Services (fair use).

The window can be long. According to the STS API reference, credentials from GetSessionToken, called with an IAM user's long-term keys, last from 900 seconds (15 minutes) up to 129,600 seconds (36 hours), with a default of 12 hours. The IAM User Guide gives GetFederationToken the same 15-minute to 36-hour range and a 12-hour default. Role sessions from AssumeRole default to one hour and can run up to the role's maximum session duration setting, which can be set from 1 to 12 hours. Role chaining, where one role assumes another, is limited to one hour. AWS also notes that Amazon EC2 role credentials are not subject to the maximum session duration configured on the role.

AWS Security Blog section on invalidating temporary security credentials after a key exposure.
Screenshot: AWS Security Blog, What to Do If You Inadvertently Expose an AWS Access Key, Invalidating Temporary Security Credentials, Amazon Web Services (fair use).

What responders can change is permission. The IAM User Guide says the permissions attached to temporary credentials are evaluated each time they are used, so removing access after the fact has the effect of revoking them, though policy updates can take a few minutes to apply. For roles, the console's Revoke active sessions action attaches an inline policy named AWSRevokeOlderSessions that denies all actions to anyone who assumed the role before that moment, plus about 30 seconds to allow for propagation. Sessions started after that are not affected, and it requires the PutRolePolicy permission. AWS says the sessions of a service-linked role cannot be revoked, and roles created from IAM Identity Center permission sets have to be handled in IAM Identity Center instead.

AWS IAM User Guide steps for revoking active role sessions, which attach the AWSRevokeOlderSessions policy.
Screenshot: AWS Identity and Access Management User Guide, Revoke IAM role temporary security credentials, Amazon Web Services (fair use).

Sessions minted from an IAM user's own key need a policy on the user. The same guide shows a deny statement keyed on aws:TokenIssueTime that blocks every request signed with temporary credentials issued before a chosen time. AWS notes that this key is only present for requests signed with temporary credentials, so it does not affect the user's long-term keys. A deny on aws:userid with the user's unique ID also covers sessions created by GetSessionToken. The Security Blog adds that deleting the IAM user, where practical, makes authentication attempts with temporary credentials tied to that user fail. Two limits apply. AWS says the permissions of temporary credentials created by GetFederationToken or GetSessionToken while signed in as the root user cannot be changed, and a resource-based policy that allows the principal needs its own explicit deny.

AWS IAM User Guide example of denying temporary credential sessions with the aws:userid condition key.
Screenshot: AWS Identity and Access Management User Guide, Disabling permissions for temporary security credentials, aws:userid, Amazon Web Services (fair use).

For a SOC team, a key rotation is the start of containment, not the end. After deactivating a leaked key, attach a deny on aws:TokenIssueTime to the user, set to the current time, and run Revoke active sessions on every role the key could assume. Check resource-based policies on buckets, queues and keys for grants to that principal. Then watch for activity that continues after the rotation, which would point to a session the policy did not reach. A ticket that reads "key rotated" may describe an account an intruder can still use for up to a day and a half.

About the Author

Noah Park

Noah Park covers incident response and blue-team operations for SOCtember from New York.

Related stories

Response desk