AWS security incidents
My AWS access key leaked: what do I do now?
If an AWS access key leaked, deactivate it now: in the IAM console, open the user, then Security credentials, and choose Make inactive on the key. That contains the damage and, unlike deleting the key, can be undone. Then revoke the sessions it opened, find everything it created in CloudTrail, remove it in every Region, and rotate to a new key.
Two things catch people out. Deactivating doesn't end temporary sessions the key already started. And AWS may have attached one of its 4 quarantine policies, such as AWSCompromisedKeyQuarantineV3, to the user: it blocks new launches but leaves running resources billing. CloudTrail's event history only covers the last 90 days.
The response, step by step
- Deactivate the key. Console: IAM, Users, the user, Security credentials, Make inactive. CLI:
aws iam update-access-key --user-name <user> --access-key-id <key-id> --status Inactive. - Revoke sessions. Look up
AssumeRole,GetSessionTokenandGetFederationTokenevents for the key in CloudTrail. For each role it assumed, open the role in IAM and choose Revoke active sessions. For tokens fromGetSessionTokenorGetFederationToken, attach an SCP or inline policy that denies everything for tokens issued before a set time, using theaws:TokenIssueTimecondition. - Find what it did. In CloudTrail, look for new IAM users or access keys, new roles or policy changes, EC2 launches, S3 downloads or new buckets, new Lambda functions, security group changes, and CloudTrail logging turned off.
- Remove what you didn't create. Terminate unauthorized EC2 instances in every enabled Region, and delete unauthorized IAM users, keys, roles, policies and Lambda functions. Check an unknown S3 bucket's contents before you delete it.
- Rotate. Create a new key and store the secret safely; AWS shows it only once. Update every place the old key lived: config files, environment variables, CI/CD secrets,
~/.aws/credentials, containers and third-party tools. Watch logs for 24 to 48 hours, then delete the old key. - Detach the quarantine policy last, once the old key is deleted and nothing unauthorized is still running.
- Harden the account. Turn on MFA for IAM users and the root user, remove
*actions from IAM policies, turn on GuardDuty, and make sure the root user has no access keys.
For a full history, aws cloudtrail lookup-events returns the last 90 days; older activity is in CloudTrail Lake or your trail's S3 bucket. To get AWS involved, open a case in the AWS Support Center under Account and billing, then Security, and say when you found the leak, which keys, what you've done, and whether there were unauthorized charges.
What AWS's quarantine policy blocks
When AWS finds an exposed key, it may attach an AWS managed policy to that user that denies certain actions. AWS has four versions; check which one is attached under the user's Permissions policies in IAM.
| Policy | Created | What it denies the user |
|---|---|---|
| AWSCompromisedKeyQuarantine | August 11, 2020 | Creating IAM users, roles and access keys, attaching policies, launching or starting EC2 instances, creating Lambda functions, Lightsail, new Organizations accounts |
| AWSCompromisedKeyQuarantineV2 | April 21, 2021, last edited October 2, 2024 | Adds S3 reads, deletes and bucket policy changes, Bedrock model calls, new SageMaker processing jobs and ECS services, Reserved Instance and Savings Plans purchases, and temporary credentials through GetSessionToken |
| AWSCompromisedKeyQuarantineV3 | August 21, 2024, last edited March 16, 2026 | Adds KMS key deletion and grant changes, S3 encryption changes, CloudWatch Logs writes and leaving the organization |
| AWSCompromisedKeyQuarantineV4 | November 6, 2026 | Adds invoking Lambda functions, sending through SES and SNS, sts:AssumeRole, stopping CloudTrail, deleting backups and RDS snapshots, reading secrets and SSM parameters, and Auto Scaling changes |
- It doesn't stop what's already running. AWS describes V3 as limiting fraud-related charges "while not impacting the existing resources". Instances or functions launched with the key keep running and billing until you remove them.
- It only covers the exposed user. IAM users, keys and roles the attacker created with it are separate identities, so find and delete them.
- It can break your own app. From V2 on it denies
s3:GetObject, and V4 also denieslambda:InvokeFunction,sts:AssumeRoleandsecretsmanager:GetSecretValuefor that user. Move the app to a new key. - Leave it on until you're done. AWS says removing it too early can affect your eligibility for account concessions related to the incident.
Check what it cost
AWS's own advice is to review the billing dashboard for unexpected cost spikes, use Cost Explorer for charges and usage, and compare this month's usage with last month's in every Region, including ones you never use. Put any unauthorized charges in your support case. The wider first-hour checklist for any provider is in what to do in the first hour after a key leaks.
Where Costbrake fits
Costbrake reads AWS spend with a read-only key. Billed dollars come from Cost Explorer every 4 hours and run up to 24 hours behind. With the CloudWatch permission it also estimates Lambda, Bedrock, NAT gateway and GPU instance spend every 5 minutes on Pro and Team, and every minute during a spike, in up to 8 Regions that already have spend. A GPU fleet in a Region with no earlier spend, or plain CPU instances anywhere, only show up once Cost Explorer has them.
Its AWS brakes run only after an admin confirms. Turn off an IAM access key marks the key Inactive without deleting it, for keys of up to 20 IAM users, and like any deactivation it doesn't end sessions the key already opened. Stop an EC2 instance covers the 6 Regions with the most spend over the last 7 days and skips Spot and Auto Scaling instances; their EBS volumes keep billing. Costbrake can't revoke sessions, delete what an attacker created or talk to AWS for you. Plans are on the pricing page and setup on the AWS integration page; AWS's own guardrails are in how to cap AWS spending and AWS Cost Anomaly Detection.
Questions and answers
Does deactivating a leaked AWS access key stop the attacker?
Not completely. It blocks the key itself, but temporary credentials it already got through AssumeRole, GetSessionToken or GetFederationToken stay valid until they expire. Revoke active sessions on each role it assumed, and deny older tokens with a policy on aws:TokenIssueTime.
Should I remove the AWSCompromisedKeyQuarantine policy from my IAM user?
Not until you've finished. AWS says not to remove it until every other remediation step is done, and removing it early can affect your eligibility for account concessions. Detach it after the old key is deleted and nothing unauthorized is running.
Why does my app get AccessDenied after AWS quarantined my key?
The quarantine policy denies a list of actions for that IAM user. From V2 on that includes s3:GetObject, and V4 adds actions like lambda:InvokeFunction and sts:AssumeRole. Give the app a new key, then delete the exposed one once everything works.
Does the quarantine policy stop EC2 instances the attacker launched?
No. It blocks new launches by that user but doesn't touch existing resources, which keep running and billing. Terminate unauthorized instances yourself in every enabled Region, including Regions you never use.
Will AWS refund charges from a leaked access key?
AWS doesn't promise one. Its guidance mentions eligibility for account concessions related to the incident, and says keeping the quarantine policy until you finish protects it. Open a case in the AWS Support Center under Account and billing and include any unauthorized charges.
Sources
- AWS re:Post: Responding to an exposed AWS access key
- AWS re:Post: Unauthorized activity in my AWS account
- AWS re:Post: Manage IAM access keys securely
- AWS IAM: Manage access keys for IAM users
- AWS managed policy: AWSCompromisedKeyQuarantine
- AWS managed policy: AWSCompromisedKeyQuarantineV2
- AWS managed policy: AWSCompromisedKeyQuarantineV3
- AWS managed policy: AWSCompromisedKeyQuarantineV4
Updated