Skip to content

My AWS key leaked. What do I do?

Short answer

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

WhenDoHow
0–2 minDeactivateIAM → Users → Security credentials → make the access key Inactive.
2–5 minInspectCloudTrail → Event history, filtered by the access key ID. Look for CreateUser, CreateAccessKey, RunInstances or policy changes.
5–8 minClean upDelete unknown users, keys, roles and instances. Check all regions and Billing.
8–10 minReplaceCreate 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_ or EXPO_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 .env or .git paths.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

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

Related

Read as Markdown · Scan methodology