Skip to content

Get notified

Get an email when a new major security incident drops. No spam, unsubscribe any time.

Only used for pwn.watch incident emails. Protected by Cloudflare Turnstile.

Triage & Response11 min read

AWS IAM Access Key & S3 Exposure Response Playbook: The First Hour (2026)

What to do in the first hour after an AWS access key leaks or an S3 bucket is exposed: deactivate the key, revoke the temporary STS sessions it already minted, scope the blast radius in CloudTrail, hunt for persistence, turn on S3 Block Public Access, and replace static keys with OIDC federation, with lessons from the Qubole role abuse and the Gitee credential scan.

// key takeaways

  • Deactivate first, delete later. An inactive key stops new API calls but stays available for CloudTrail correlation and can be re-enabled if you cut off the wrong one.
  • Deactivating a key does not invalidate temporary credentials it already obtained from STS. Add an explicit deny on sessions issued before the revocation time.
  • CloudTrail event history only covers 90 days of management events. S3 object reads are data events, and if no trail was logging them you cannot prove what was downloaded.
  • Valid credentials look like normal use. In the Qubole abuse every AssumeRole call carried a valid External ID and succeeded, and the attacker then read Secrets Manager, SSM parameters and S3 data.
  • The durable fix is fewer long-lived keys: OIDC federation for CI, IAM Identity Center for people, and roles for workloads.

How AWS keys and buckets end up exposed

Long-lived IAM user access keys (the ones that start with AKIA) leak the same way every other secret does: committed to a repository, printed in CI logs, baked into a container image, stored in a SaaS vendor's environment variables, or stolen from a developer laptop. Public code hosts are scanned constantly. In October 2026 a researcher scanned 7.25 million public Gitee repositories and found 26,400 unique credentials that still authenticated, led by 9,473 Alibaba Cloud AccessKey pairs. The same tooling works on AWS keys.

Vendors are the other path. Between October 14 and 26, 2026 an attacker used credentials from an AWS account associated with Qubole to assume the IAM roles customers had created to trust Qubole. Every request carried a valid External ID. Inside customer accounts the attacker read Lambda environment variables, Secrets Manager secrets and SSM parameters, tested the credentials it found with TruffleHog, and downloaded S3 data, in some cases whole buckets.

Storage exposure without any key leak is the third pattern. Microsoft AI researchers published an Azure Storage SAS token with full-control permissions on an entire storage account, exposing 38TB of internal data. The S3 equivalent is a bucket policy or ACL that grants access to everyone, or a presigned URL with far broader reach than intended.

Minutes 0 to 15: identify and deactivate

Confirm which principal owns the key before you change anything. aws iam get-access-key-last-used tells you the owning user, the last service and Region that used it, and when. Record that in the incident ticket, then set the key to Inactive. Do not delete it yet: deletion removes the key from IAM, while an inactive key keeps the investigation simple and is reversible if a production job turns out to depend on it.

If AWS or GitHub secret scanning found the key, AWS may already have attached an AWSCompromisedKeyQuarantine managed policy to the user and opened a support case. That policy denies a set of high-risk actions; it does not replace your response. Rotate the key for any legitimate consumer only after you know who the consumer is and where the new key will be stored, preferably as a role instead.

Identify the owner and deactivate the key
KEY=AKIAEXAMPLEKEYID0000

# Who owns it and when was it last used?
aws iam get-access-key-last-used --access-key-id "$KEY"

# Deactivate (reversible); delete only after the investigation
aws iam update-access-key --user-name ci-deploy --access-key-id "$KEY" --status Inactive

# List every key the user has; an attacker may have created a second one
aws iam list-access-keys --user-name ci-deploy

Minutes 15 to 30: revoke the sessions the key already created

With an access key an attacker can call sts:GetSessionToken or sts:AssumeRole and receive temporary credentials that are independent of the key. AWS documents that deactivating or deleting the access key does not invalidate those temporary credentials; they stay valid until they expire, which can be hours. The fix is an explicit deny that applies to any session issued before now.

For a role, the IAM console's Revoke active sessions action attaches an inline policy named AWSRevokeOlderSessions that denies all actions when aws:TokenIssueTime is earlier than the revocation time. For an IAM user, attach the same style of policy yourself. Then follow the trail one hop further: every role the compromised principal could assume needs the same treatment if CloudTrail shows it was assumed.

  • Attach a deny-all policy with a DateLessThan condition on aws:TokenIssueTime to the compromised user.
  • Revoke active sessions on every role the principal assumed during the exposure window.
  • Check for console access: list-login-profile and list-mfa-devices on the user, and remove anything unexpected.
  • Rotate any secret the principal could read (Secrets Manager, SSM SecureString, Lambda environment variables), not just the AWS key.
Deny every session issued before the revocation time
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RevokeOlderSessions",
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "DateLessThan": { "aws:TokenIssueTime": "2026-12-07T10:30:00Z" }
      }
    }
  ]
}

Minutes 30 to 60: scope the blast radius in CloudTrail

Start with CloudTrail event history, which you can filter by AccessKeyId across the last 90 days of management events in a Region. Run it in every Region the account uses, because attackers often launch compute in Regions nobody watches. Then pivot from the key to the session credentials it created (ASIA key IDs in the responses to GetSessionToken and AssumeRole) and search for those too.

Look for persistence first, then for data access. Persistence means new IAM users, new access keys, login profiles, attached or inline policies, changed role trust policies, new identity providers, and new Lambda functions or EC2 instances. Data access means reads from Secrets Manager and SSM Parameter Store, and S3 object access. S3 GetObject and PutObject are data events: they only exist if a trail or CloudTrail Lake event data store was configured to record them before the incident. If none was, say so in the report rather than guessing, and use S3 server access logs if they were enabled.

Indicators from real incidents help. In the Qubole case Wiz flagged role session names starting with quiam-, the TruffleHog user agent on GetCallerIdentity, and VPN and VPS source addresses. A sts:GetCallerIdentity call from an unfamiliar IP is often the first thing an attacker does with a fresh key.

  • Persistence: CreateUser, CreateAccessKey, CreateLoginProfile, AttachUserPolicy, PutUserPolicy, PutRolePolicy, UpdateAssumeRolePolicy, CreateOpenIDConnectProvider.
  • Compute abuse: RunInstances, CreateFunction, UpdateFunctionCode, and new Regions appearing in the event history.
  • Secret reads: GetSecretValue, GetParameter with decryption, GetFunctionConfiguration.
  • Storage: ListBuckets, GetBucketPolicy, PutBucketPolicy, PutBucketAcl, DeletePublicAccessBlock, and S3 data events where logged.
Search CloudTrail for the key across Regions
KEY=AKIAEXAMPLEKEYID0000
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
  echo "== $r"
  aws cloudtrail lookup-events --region "$r" \
    --lookup-attributes AttributeKey=AccessKeyId,AttributeValue="$KEY" \
    --query 'Events[].[EventTime,EventName,EventSource]' --output text
done

# Recent IAM changes anywhere in the account (IAM events are recorded in us-east-1)
for ev in CreateUser CreateAccessKey CreateLoginProfile AttachUserPolicy UpdateAssumeRolePolicy; do
  aws cloudtrail lookup-events --region us-east-1 \
    --lookup-attributes AttributeKey=EventName,AttributeValue=$ev \
    --query 'Events[].[EventTime,Username,EventName]' --output text
done

Close S3 exposure: Block Public Access and ownership controls

S3 Block Public Access has four settings (BlockPublicAcls, IgnorePublicAcls, BlockPublicPolicy, RestrictPublicBuckets) and can be set per bucket and for the whole account. The account-level setting overrides bucket-level choices, so enabling all four at the account level is the fastest way to stop public access across every bucket at once. Since April 2023 new buckets have Block Public Access enabled and ACLs disabled by default, but older buckets and accounts keep whatever they had.

Set Object Ownership to BucketOwnerEnforced to disable ACLs entirely, so access is decided only by policies. Use IAM Access Analyzer to list buckets shared outside your account or organization, and check bucket policies for Principal "*" without a restricting condition. If a bucket must serve public content, put CloudFront in front of it with origin access control instead of opening the bucket.

  • Enable all four Block Public Access settings at the account level, then document any bucket that genuinely needs an exception.
  • Set Object Ownership to BucketOwnerEnforced on every bucket.
  • Review Access Analyzer findings for S3, KMS keys and IAM roles shared externally.
  • Enable S3 data events for buckets holding sensitive data so the next investigation has evidence.
Turn on account-level Block Public Access and check bucket status
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)

aws s3control put-public-access-block --account-id "$ACCOUNT" \
  --public-access-block-configuration \
  BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

# Which buckets does S3 itself consider public?
for b in $(aws s3api list-buckets --query 'Buckets[].Name' --output text); do
  printf '%s ' "$b"
  aws s3api get-bucket-policy-status --bucket "$b" \
    --query 'PolicyStatus.IsPublic' --output text 2>/dev/null || echo 'no-policy'
done

# Disable ACLs on a bucket
aws s3api put-bucket-ownership-controls --bucket my-bucket \
  --ownership-controls 'Rules=[{ObjectOwnership=BucketOwnerEnforced}]'

Replace static keys with OIDC federation and roles

Most leaked AWS keys belong to automation: CI pipelines, deploy scripts and third-party integrations. GitHub Actions, GitLab CI and most CI systems can exchange a short-lived OIDC token for temporary AWS credentials through sts:AssumeRoleWithWebIdentity. Nothing long-lived is stored in the CI system, so there is nothing to leak from its secret store or logs.

The trust policy is where federation is won or lost. For GitHub Actions, pin the audience to sts.amazonaws.com and the sub claim to a specific repository and branch or environment. A wildcard on the organization or repository lets any workflow that can obtain a token assume the role. For people, use IAM Identity Center with MFA instead of IAM users. For workloads on AWS, use instance profiles, ECS task roles, Lambda execution roles or EKS Pod Identity.

For vendor roles that must stay, add conditions beyond External ID, such as the vendor's source IPs or VPC endpoints where they publish them, scope permissions to the buckets and actions the integration uses, and delete roles for integrations you no longer run.

IAM trust policy for GitHub Actions OIDC scoped to one repo and branch
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
          "token.actions.githubusercontent.com:sub": "repo:example-org/api:ref:refs/heads/main"
        }
      }
    }
  ]
}

// actionable engineering checklist

  • Key deactivated, not deleted

    update-access-key --status Inactive; record owner, last-used service and Region.

  • Older sessions denied

    aws:TokenIssueTime deny on the user and Revoke active sessions on every role it assumed.

  • Persistence removed

    No unexpected users, keys, login profiles, policies, trust policy changes or OIDC providers.

  • Every Region searched

    CloudTrail lookups per Region for the AKIA key and the ASIA session keys it minted.

  • Reachable secrets rotated

    Secrets Manager, SSM SecureString and Lambda environment variables the principal could read.

  • S3 locked down

    Account-level Block Public Access on, ACLs disabled, Access Analyzer findings reviewed.

  • Evidence for next time

    Multi-Region trail with S3 data events on sensitive buckets and log file validation enabled.

  • Static keys retired

    CI on OIDC federation, people on IAM Identity Center, unused vendor roles deleted.

// connected pwn.watch tools & live trackers

Frequently Asked Questions

Is deactivating a leaked AWS access key enough?
No. Temporary credentials the key already obtained through STS stay valid until they expire. Attach a deny policy on aws:TokenIssueTime, revoke sessions on roles it assumed, and check CloudTrail for new users, keys and policies the attacker may have created.
Should I delete the leaked key immediately?
Deactivate it immediately and delete it once the investigation is done. An inactive key cannot be used, keeps its last-used data visible, and can be re-enabled if a production job you did not know about breaks.
Can CloudTrail tell me which S3 objects were downloaded?
Only if a trail or CloudTrail Lake event data store was recording S3 data events for that bucket before the incident, or S3 server access logging was on. Event history only contains management events.
Does S3 Block Public Access break CloudFront or presigned URLs?
No. CloudFront with origin access control reaches the bucket as an authorized service principal, and presigned URLs are signed by a principal with access. Block Public Access only stops grants to everyone.

Get an email when a new major security incident drops. No spam, unsubscribe any time.