# 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

| 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_` 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.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)
- [AWS re:Post: Unauthorized activity in AWS accounts](https://repost.aws/knowledge-center/potential-account-compromise)
- [AWS CloudTrail: Event history](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)

## Related

- [Fix AWS 'SignatureDoesNotMatch' (signature we calculated…)](/errors/aws-signature-does-not-match)
- [Fix: .env file exposed](/fix/env-file-exposed)
- [Fix: .git folder exposed](/fix/git-folder-exposed)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
