Incident response
My AWS account is compromised: what to do, step by step
If your AWS account is compromised: deactivate the exposed access key, block the temporary sessions already issued, secure the root user, then delete what the attacker created in every Region and open an "Account and billing" case with AWS. This procedure covers the three most common situations: keys pushed to GitHub, cryptocurrency mining and a bill that explodes.
In short: the first hour
- Cut access: exposed key deactivated,
AWSDenyAllpolicy attached to the affected user, root password changed and MFA enabled. Deleting the key is not enough: temporary sessions obtained with it stay valid for up to 36 hours. - Measure: the CloudTrail event history keeps 90 days of actions, Region by Region; Cost Explorer shows, day by day, where the money goes.
- Clean up in every Region: the identities and keys the attacker created first, then whatever relaunches machines (Auto Scaling, Spot), then the machines.
- Tell AWS: an "Account and billing" case, free on every support plan, to report the incident and request a billing adjustment.
- Check everything else: the attacker came in through one door; nothing says it was the only one.
The signs that should alert you
A compromised account rarely shows a visible break-in. The signals are indirect, often received by email or on the bill:
| Signal | What it means | Where to see it |
|---|---|---|
| Email from AWS or a support case opened in your name | AWS found one of your keys in public, often on GitHub, and restricted the user | Root mailbox, Support Center, AWS Health (AWS_RISK_CREDENTIALS_EXPOSED) |
| GitHub secret scanning alert | An AWS key was pushed to a repository | Repository Security tab, email from GitHub |
| Bill or forecast rising sharply | Someone else is consuming at your expense: compute, AI models, emails | Cost Explorer by day, AWS Budgets, Cost Anomaly Detection |
| GPU or very large instances, in Regions you do not use | Cryptocurrency mining, the most frequent scenario | EC2 console Region by Region, Cost Explorer by Region |
GuardDuty CryptoCurrency or UnauthorizedAccess:IAMUser findings | Mining, credentials used outside AWS or from a malicious address | GuardDuty console, if the service was enabled beforehand |
| Users, keys or roles nobody recognizes | Persistence: the attacker keeps a way back in | IAM console, credential report |
| CloudTrail stopped, GuardDuty disabled | The attacker is covering their tracks | CloudTrail history: StopLogging, DeleteTrail, DeleteDetector |
| Amazon Bedrock or Amazon SES usage spike | Resale of access to AI models (LLMjacking) or spam sending | Cost Explorer, CloudWatch metrics, SES console |
| Root sign-in impossible, account email address changed | Account takeover | AWS support form available without signing in |
Step 1: cut access, within the first hour
Act with an identity other than the compromised one: a clean administrator, or the root user if there is no other. Do not close the account: you would lose access to the logs without erasing the bill.
- Write everything down, starting now: detection time, credentials involved, every action taken. This timeline will serve the support case, the insurer and any notifications.
- Secure the root user: a new long password, MFA (a hardware key preferably), deletion of any root access key. Check the account email address and contacts: an attacker changes them to keep control. Temporary sessions opened with the root user cannot be restricted, but they expire after one hour at most.
- Deactivate the exposed key rather than deleting it right away: an inactive key no longer works, and its ID stays visible for the investigation. Delete it once the investigation is over.
- Block temporary sessions: a deactivated or deleted key does not revoke the temporary credentials already obtained with it (
GetSessionToken,GetFederationToken), valid for up to 36 hours. TheAWSDenyAllmanaged policy attached to the user blocks them, because their permissions are evaluated again on every call. - Revoke the sessions of the roles the attacker may have assumed: the role's "Revoke active sessions" button in the IAM console, or the policy below. For IAM Identity Center, revoke the user's sessions in Identity Center.
- Do not remove the quarantine policy
AWSCompromisedKeyQuarantineV3if AWS attached it: follow the instructions in the support case. It only denies a list of actions (launching instances, creating users or keys, invoking Bedrock models…) and does not replace the steps above. - Change the secrets the key could read: database passwords, API tokens stored in Secrets Manager or Parameter Store. The quarantine does not prevent reading them.
# 1. Deactivate the exposed key (reversible; delete it after the investigation)
aws iam update-access-key --user-name ci-deploy \
--access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive
# 2. Deny everything to the user, already issued temporary sessions included
aws iam attach-user-policy --user-name ci-deploy \
--policy-arn arn:aws:iam::aws:policy/AWSDenyAll
# 3. Its other access keys
aws iam list-access-keys --user-name ci-deploy
# 4. Role: deny every session issued before now (UTC time)
aws iam put-role-policy --role-name app-role --policy-name AWSRevokeOlderSessions \
--policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Deny","Action":"*","Resource":"*","Condition":{"DateLessThan":{"aws:TokenIssueTime":"2026-11-14T10:00:00Z"}}}]}'Step 2: measure what the attacker did
The CloudTrail event history keeps 90 days of management events, with no setup and no charge, Region by Region. Actions on global services such as IAM are recorded in us-east-1.
- The key's actions: search by key ID, then by user name. Actions made with temporary credentials carry another key, prefixed ASIA.
- Identity creations:
CreateUser,CreateAccessKey,CreateLoginProfile,AttachUserPolicy,CreateRole,UpdateAssumeRolePolicy. This is persistence, to handle before anything else. - Resource launches:
RunInstances,RequestSpotInstances,CreateAutoScalingGroup,CreateFunction, and quota increase requests (RequestServiceQuotaIncrease), made to launch more machines. - Erased tracks:
StopLogging,DeleteTrail,DeleteDetector, and changes to the account contacts. - The data: S3 object reads do not appear in the history. They are data events, recorded only by a trail configured for them. Without such a trail, assume the data the key could read may have been copied.
- The money: Cost Explorer, by day, grouped by Region then by usage type, shows where and since when. Costs appear with a delay of up to 24 hours.
# The key's actions, in every enabled Region (last 90 days)
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=AKIAIOSFODNN7EXAMPLE \
--query 'Events[].[EventTime,EventName]' --output text
done
# Same search by user (covers temporary sessions)
aws cloudtrail lookup-events --region us-east-1 \
--lookup-attributes AttributeKey=Username,AttributeValue=ci-deploy \
--query 'Events[].[EventTime,EventName]' --output text
# Identity and key creations (IAM: us-east-1)
for e in CreateUser CreateAccessKey CreateLoginProfile CreateRole; do
aws cloudtrail lookup-events --region us-east-1 \
--lookup-attributes AttributeKey=EventName,AttributeValue=$e \
--query 'Events[].[EventTime,Username,EventName]' --output text
done
# Cost by day and by Region (Cost Explorer API: USD 0.01 per request)
aws ce get-cost-and-usage --time-period Start=2026-11-01,End=2026-11-15 \
--granularity DAILY --metrics UnblendedCost \
--group-by Type=DIMENSION,Key=REGIONStep 3: delete what the attacker created, in every Region
Attackers launch their machines in the Regions nobody looks at. Go through every enabled Region, in this order:
- Persistence first: IAM users, access keys, console passwords, roles whose trust policy names an unknown account, added identity providers, EC2 key pairs. As long as one of these doors stays open, the cleanup will have to be done again.
- Whatever relaunches machines: Auto Scaling groups, Spot requests and fleets, EC2 fleets, launch templates, ECS services. If you terminate the instances first, they recreate them.
- The machines: EC2 instances (often GPU families p and g, or .24xlarge sizes and up), Lambda functions, Fargate tasks, Lightsail, SageMaker, AWS Batch. The attacker sometimes enables termination protection: disable it before terminating.
- Other paid usage: added Amazon SES identities, access to Amazon Bedrock models, Reserved Instance or Savings Plans purchases you did not make.
- The Regions themselves: an opt-in Region enabled during the incident (
EnableRegionevent) is suspicious. - Evidence before deletion: record the ID, Region, AMI and user data of the attacker's instances; they often contain the mining pool address. An instance of yours that was compromised is handled differently: snapshot its volumes, isolate it in a security group with no rules, then analyze it.
# Enabled Regions (an opt-in Region enabled by the attacker shows up here)
aws account list-regions --region-opt-status-contains ENABLED ENABLED_BY_DEFAULT \
--query 'Regions[].RegionName' --output text
# Running instances, Region by Region
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
echo "== $r"
aws ec2 describe-instances --region "$r" \
--filters Name=instance-state-name,Values=pending,running \
--query 'Reservations[].Instances[].[InstanceId,InstanceType,LaunchTime,KeyName]' \
--output text
done
# What relaunches instances: delete it first
aws autoscaling describe-auto-scaling-groups --region us-east-1 \
--query 'AutoScalingGroups[].[AutoScalingGroupName,DesiredCapacity,CreatedTime]' --output table
aws ec2 describe-spot-instance-requests --region us-east-1 \
--filters Name=state,Values=open,active \
--query 'SpotInstanceRequests[].[SpotInstanceRequestId,LaunchSpecification.InstanceType]' --output table
# Lift the protection set by the attacker, then terminate
aws ec2 modify-instance-attribute --region us-east-1 \
--instance-id i-0123456789abcdef0 --no-disable-api-termination
aws ec2 terminate-instances --region us-east-1 --instance-ids i-0123456789abcdef0
# IAM users and creation date
aws iam list-users --query 'Users[].[UserName,CreateDate]' --output tableStep 4: open a case with AWS
Open a case in the Support Center, "Account and billing" category: it is free, Basic plan included. If AWS already opened a case, reply in that one.
- Describe the timeline, the credentials involved and what is already done: keys deactivated, root secured, resources deleted.
- List the fraudulent resources you deleted, with their Region: AWS checks the usage on its side.
- Request a billing adjustment for the unauthorized usage. AWS grants it at its discretion, once the account is secured: it is neither automatic nor guaranteed, and may be partial.
- If the root email address was changed and you can no longer sign in, use the AWS support form available without signing in.
For an ongoing incident on a critical environment, AWS Security Incident Response (a paid AWS service) or an incident response provider (in France, PRIS-qualified by ANSSI) brings an investigation team.
Step 5: report the incident if the law requires it
A compromised account can trigger notification duties, with short deadlines:
- GDPR: a personal data breach that presents a risk is notified to the supervisory authority (the CNIL in France) within 72 hours of becoming aware of it (Article 33), and to the people concerned if the risk is high (Article 34).
- NIS 2: for essential and important entities, early warning to the CSIRT within 24 hours, notification within 72 hours, final report within one month (Article 23 of the directive). For the state of transposition in your country, check with the national authority (ANSSI in France).
- DORA: a financial entity notifies a major ICT-related incident to its competent authority (ACPR or AMF in France), within 4 hours of classifying it as major and no later than 24 hours after detecting it.
- Insurance and complaint: notify your cyber insurer within the deadline in your policy and file a complaint. In France, small businesses find help and providers on cybermalveillance.gouv.fr.
These deadlines are reference points: have your obligations confirmed by your DPO or legal counsel.
Keys pushed to GitHub: what changes
- The key is compromised from the push: bots crawl public repositories continuously and test the keys they find within minutes. Making the repository private or deleting the commit is not enough: the history, forks and copies may already have been collected.
- AWS often reacts before you do: GitHub reports to AWS the keys found in public repositories; AWS attaches the quarantine policy to the user, sends an email and opens a support case. A key published elsewhere (shared private repository, public container image, infected workstation) is reported by no one.
- Rotate first, clean up second: deactivate the key, then rewrite the repository history (git filter-repo) so it no longer triggers alerts.
- Replace the key with… no key: an IAM role assumed through OIDC for GitHub Actions, IAM Identity Center and
aws sso loginfor developers, the instance, task or function role for an application running on AWS. - Block the next leak: GitHub push protection, a pre-commit hook (gitleaks, git-secrets), a search for keys in your other repositories and images.
Cryptocurrency mining: recognize it and stop it
It is the most common use of a stolen key: launch as much compute as possible, in as many Regions as possible, until someone notices.
- The signs: GPU or very large instances launched within minutes in several Regions, EC2 quota increase requests, CPUs at 100% around the clock, traffic to mining pools.
- GuardDuty detects it if it was on:
CryptoCurrency:EC2/BitcoinTool.B!DNSorImpact:EC2/BitcoinDomainRequest.Reputationfindings on instances,UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWSif an instance's credentials are used outside AWS. - Mining can come from an application flaw, without a stolen key: a vulnerable application exposed to the internet. The instance is then yours: isolate it, keep a snapshot, rebuild it from a clean image and fix the flaw before putting it back online. The CVE watch helps spot those vulnerable versions.
- Stopping it: follow step 3, starting with whatever relaunches machines.
A bill that explodes: find the cause
A sudden rise that matches no project is not an optimization topic: treat it as an incident until proven otherwise.
- By Region: a cost in a Region where you deployed nothing is the clearest sign.
- By usage type:
BoxUsagefollowed by an instance type for compute, model tokens for Amazon Bedrock, sends for Amazon SES,DataTransfer-Outfor a massive data outflow. - By day: the date of the first spike marks the start of the incident and narrows the CloudTrail search.
- For next time: an AWS Budgets budget with an alert on the forecast amount, and AWS Cost Anomaly Detection, free, which flags a drift service by service.
For a slow, explained rise, the right read is how to reduce your AWS bill.
After the incident: close the other doors
- No more long-term access keys, neither for humans nor for CI: federation, roles, OIDC.
- MFA on the root user and on every console access; root without access keys, kept for the rare tasks that require it.
- A multi-Region CloudTrail trail to a protected S3 bucket, to keep more than 90 days and be able to investigate next time.
- GuardDuty enabled in every Region, including the ones you do not use: that is where the attacker will go.
- With AWS Organizations, an SCP that denies unused Regions (
aws:RequestedRegioncondition) and the instance families you do not need. - Cost alerts sent to a shared list, not to a single mailbox.
The full list is in the 40-point AWS security checklist, and the reference controls in the CIS AWS v5.0 guide.
Why audit the account after the incident
The attacker came in through one door; nothing says it was the only one. Once the incident is contained, the Silamir AWS security audit checks the rest of the account with read-only access, in 30–60 minutes, across 10 domains:
- every IAM user and its access keys, with their age and last use, the root user's MFA and keys;
- GuardDuty, CloudTrail, AWS Config and Security Hub Region by Region, and the gaps against the FSBP and CIS v5.0 standards;
- access opened to other accounts or to the public (IAM Access Analyzer), SCPs, security groups open to the internet, IMDSv2;
- plaintext secrets, in Lambda function environment variables or unencrypted SSM parameters;
- the inventory of resources in each selected Region: select them all at launch to find whatever escaped the cleanup;
- the attack scenarios still possible and a prioritized remediation plan (P0, P1, P2), with the commands to run.
What the audit does not do: it cuts no access, deletes nothing and does not reconstruct the attack from the CloudTrail history. It is not incident response: it comes after containment, for USD 299 billed by AWS, and runs again after the fixes to measure progress.
Compromised AWS account: frequently asked questions
Should you close a hacked AWS account?
No, not in a hurry. Closing it does not erase the charges already incurred, and you lose access to the logs needed for the investigation and for the billing adjustment request. Secure, clean up, open a case with AWS, then decide.
Does AWS refund charges caused by a hack?
Sometimes, partly or fully, but nothing is guaranteed. AWS reviews each adjustment request after the account has been secured and the fraudulent resources deleted. Open an "Account and billing" case with the timeline and the list of deleted resources.
Is deleting the exposed access key enough?
No. Temporary credentials obtained with the key (GetSessionToken, GetFederationToken) stay valid for up to 36 hours, and the attacker may have created other users, keys or roles. Attach the AWSDenyAll policy to the user, then search CloudTrail for everything that was created.
What is the AWSCompromisedKeyQuarantineV3 policy?
A managed policy AWS attaches to an IAM user whose key was found in public. It denies a list of risky actions: launching instances, creating users or keys, invoking Bedrock models, getting temporary sessions. It does not deny everything: the key can still read secrets, for example. Do not remove it; follow the instructions in the support case.
How do you find out what the attacker did?
With the CloudTrail event history: 90 days of management events, free, searchable Region by Region, with no prior setup. S3 object reads are not in it: they are recorded only if a trail captures data events. Beyond 90 days, only a trail to S3 keeps the record.
When should you run an audit after an incident?
After containment: the attacker's access cut, fraudulent resources deleted. Select every Region at launch. The audit is read-only and disrupts nothing; run it again after the fixes to show the gaps are closed.
Where does your AWS account stand?
Ten questions, three minutes, no access to your account: a security score, a FinOps score and the article to read for each of your three weakest points. Your answers stay in your browser.
Ready to audit your AWS account?
Subscribe on AWS Marketplace, deploy the read-only role and get your reports within the hour.