My AWS key leaked. What do I do?
Deactivate the access key in IAM now, create a replacement only if something still needs one, then check CloudTrail for activity from that key, such as new IAM users, keys, roles or EC2 instances. AWS keys can run up large bills in minutes. If AWS has already opened a support case or applied a quarantine policy, follow it.
Last updated 2026-11-25 · Reviewed by ProofForge
Is it this key?
Format: Long-term access key IDs start with AKIA. Each comes with a 40-character secret access key.
Blast radius: Whatever the IAM user's policies allow. With admin rights that's the whole account: compute for crypto-mining, data in S3, and new backdoor users.
The first 10 minutes
| When | Do | How |
|---|---|---|
| 0–2 min | Deactivate | IAM → Users → Security credentials → make the access key Inactive. |
| 2–5 min | Inspect | CloudTrail → Event history, filtered by the access key ID. Look for CreateUser, CreateAccessKey, RunInstances or policy changes. |
| 5–8 min | Clean up | Delete unknown users, keys, roles and instances. Check all regions and Billing. |
| 8–10 min | Replace | Create a new key or, better, move to roles or short-lived credentials. Delete the leaked key. |
Stop the next leak
- Keep the key in a server-side env var. Never use a
VITE_,NEXT_PUBLIC_orEXPO_PUBLIC_variable or hard-code it in frontend code. - Call the provider from your backend or an edge function, and add
.env*to.gitignore. - Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
FAQ
Is deactivating enough?
It stops the key, but anything an attacker created (users, keys, instances) keeps working until you remove it.
Should I put AWS keys in a frontend app?
No. Use presigned URLs from your server or Cognito-issued temporary credentials.
Will AWS refund charges?
Contact AWS Support quickly. AWS's own guide covers compromised-account steps.
Sources
- AWS: Manage access keys for IAM users
- AWS re:Post: Unauthorized activity in AWS accounts
- AWS CloudTrail: Event history