Checklist
Leaked AWS access key? What to do right now
Short answer. Treat the key as copied. An AKIA key is a long-term IAM user key: create a replacement, deactivate the old one, then delete it. An ASIA key is a temporary STS credential: revoke the session, not a row in the access-key list. Then read CloudTrail for that key ID. Rewriting git history does not un-leak it.
Updated 28 Nov 2026
This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.
An AWS access key is a credential for the account. Deleting the line from a file does not deactivate it. This page is the first sitting after a leak. It is a checklist, not a statement that the account is fine.
The same shape for other credentials is Leaked a GitHub token?, Leaked OpenAI API key?, Leaked Anthropic key?, and Leaked Stripe secret key?.
Which key it is
Amazon GuardDuty's credential remediation page splits the prefix:
- AKIA is a long-term access key for an IAM user or the account root user. You can deactivate and delete it in IAM.
- ASIA is a temporary credential from AWS Security Token Service. It expires on its own. You cannot manage it as a row on an IAM user's access-key list. IAM roles always use this kind of credential. A user can receive one too.
The secret access key is shown only when the long-term key is created. IAM's administrator page says you cannot retrieve it later. Each IAM user can have two access keys.
If AWS attached a quarantine policy, do the cleanup as a different administrator or as the root user. AWSCompromisedKeyQuarantineV3 denies the quarantined identity iam:UpdateAccessKey, iam:DeleteAccessKey, and cloudtrail:LookupEvents, among other actions. Those calls fail while you are signed in as that user.
Deactivate the long-term key, then delete it
AWS's unauthorized activity article, for a key listed in an AWS notice, says to create the replacement first, deactivate the original, confirm the application still works, and only then delete the original. Do not leave the leaked key active while you rewrite git history.
In the IAM console at console.aws.amazon.com/iam:
1. Find the user. IAM's administrator page says you can paste the access key ID into the IAM search box. 2. On Security credentials, choose Create access key only if this user still needs a long-term key. The console asks you to review alternatives first. Download the new secret once. Put it in the host's environment, not in the repo. On Vercel, a changed environment variable applies only to a new deployment. Vercel's environment variables page says the running deployment keeps the value it was built with. Redeploy after you save. 3. On the old key, Actions, then Deactivate. A deactivated key cannot sign API calls. You can turn it back on if the new key was wrong and production broke. That is why AWS says not to delete in the same minute you deactivate. 4. When the app works on the new key, Actions, then Delete. Type the access key ID to confirm. Deletion cannot be undone.
The same steps from a shell, using the parameters on UpdateAccessKey and DeleteAccessKey:
aws iam update-access-key \
--user-name THE_USER \
--access-key-id AKIAEXAMPLE \
--status Inactive
aws iam delete-access-key \
--user-name THE_USER \
--access-key-id AKIAEXAMPLEIf the leaked key is a root user key, AWS's unauthorized-activity article says to delete root access keys you do not need. Do that from the root account's security credentials, not from an IAM user page.
Temporary credentials
An ASIA key is already short-lived. GuardDuty says you cannot view or manage it in the console. AWS's unauthorized-activity article points you at revoking IAM role temporary credentials when that is what leaked. Update the role or the trust policy so new sessions are not issued the same way, and check CloudTrail for AssumeRole around the time of the leak. Deactivating an AKIA key does not, by itself, end an ASIA session that was already issued.
What the key did
In CloudTrail, open Event history. AWS's unusual activity article says to set the lookup attribute to AWS access key and paste the key ID. That view covers the last 90 days. Read the event names. Creation of access keys, users, roles, policies, and temporary credentials is what the unauthorized-activity article tells you to look for.
Event history is for the Region you are viewing. Repeat it in Regions where you run workloads. Charges that do not show in one Region's events can still show in billing. The unauthorized-activity article says to use a cost and usage report and Cost Explorer for unexpected services and account charges. Look for EC2, Lambda, and other resources you did not create, then delete those after you have the CloudTrail record of who launched them.
Also open IAM and look for users, access keys, and roles you did not create. Deactivate users you did not create. Change passwords for users you did.
If AWS already quarantined the key
AWS publishes managed deny policies it attaches when a key was exposed:
- AWSCompromisedKeyQuarantine says AWS applied it because credentials were compromised or exposed, and tells you not to remove it. Follow the email.
- AWSCompromisedKeyQuarantineV2 is the policy the unauthorized-activity article tells you to look for on the user's Permissions tab.
- AWSCompromisedKeyQuarantineV3 says the same thing in newer wording: do not remove it, and follow the support case AWS opened. It denies actions that start compute, create IAM users and keys, and look up CloudTrail events, while leaving existing resources in place.
Reply on the AWS Health notice or the support case with what you deactivated and deleted. Do not detach the policy to "get the account working" and then keep using the leaked key.
Git history does not un-leak it
GitHub's removing sensitive data page says to revoke or rotate first. After the key is dead, rewriting history with git-filter-repo may not be worth it. A force-push does not erase clones, forks, or commits still fetchable by SHA. A teammate who pushes the old history puts the key back.
GitHub's supported patterns include an AWS access key ID paired with the secret, an AWS API key ID, and an AWS session token, with push protection on those rows. Pair detection means the ID and the secret have to be in the same file. An ID alone in one file and the secret in another does not raise that pair alert. Secret scanning runs on public repositories. Push protection for your user blocks supported secrets on pushes to public repositories and is on by default. The token side of a GitHub leak is Leaked a GitHub token?.
Prefer a role next time
IAM's best practices and Security Hub's IAM user exposure page say to use roles or federation for temporary credentials instead of long-term IAM user keys. When a long-term key is unavoidable, Security Hub's remediation text says to rotate it every 90 days, and to replace broad policies with the actions that job needs. An IAM user can hold only two keys, which is the overlap while you rotate.
Do not put AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY in a NEXT_PUBLIC_ or VITE_ name. Those prefixes ship in the browser bundle. The passes are API keys in the frontend and how to keep API keys out of AI-generated code. Keep .env out of git. For GitHub Actions, prefer an IAM role the workflow assumes over a stored AKIA key. AWS documents OIDC identity providers for that pattern.
Then run a free passive check on the public URL. It can see a key that shipped in a script. It does not read your AWS account or CloudTrail. The worksheets are the checklist pack and the pre-launch checklist.
FAQ
I deleted the key from GitHub. Is the AWS key dead?
No. Deactivate it in IAM, confirm the app runs on a new key, then delete the old one. An ASIA key is not that row. It expires, and you still revoke the role session if it was assumed from a leaked long-term key. Removing the line from the repo is the cleanup after the key is inactive.
What is AWSCompromisedKeyQuarantine?
It is an AWS managed deny policy. The policy pages say AWS attaches it when an IAM user's credentials were compromised or exposed publicly. V2 and V3 are later versions of the same idea. Do not detach it. Follow the email or the support case. V3 also denies CloudTrail lookups and access-key deletion for the identity it is attached to, so use a different administrator for those steps.
Will GitHub secret scanning catch an AWS key?
It lists AWS access key IDs, secret access keys, and session tokens, with push protection. Pair matching requires the ID and the secret in the same file. A public repository is scanned. A private one is not automatic. Push protection for your user blocks a push of supported secrets to a public repository. A key that is already in history still has to be deactivated.
Can the key live in a frontend env var?
No. NEXT_PUBLIC_ and VITE_ values are in the bundle anyone can download. Call AWS from a server role. The browser should not receive AKIA or the secret access key.
Sources
Checked 28 Nov 2026.
- AWS, manage IAM user access keys
- AWS, UpdateAccessKey
- AWS, DeleteAccessKey
- AWS, what to do about unauthorized activity
- AWS, unusual resource activity
- AWS, remediating potentially compromised credentials
- AWS, IAM best practices
- AWS, IAM user exposure remediation
- AWS, OIDC identity providers
- AWS managed policy, AWSCompromisedKeyQuarantine
- AWS managed policy, AWSCompromisedKeyQuarantineV2
- AWS managed policy, AWSCompromisedKeyQuarantineV3
- AWS, what is Cost Explorer
- GitHub, supported secret scanning patterns
- GitHub, secret scanning detection scope
- GitHub, remediating a leaked secret
- GitHub, removing sensitive data from a repository
- Vercel, environment variables
Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.
Newsletter
A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.