AWS access key leaked: what to do right now
If an AWS access key leaked, create a second access key while the first is still active, move your apps to it, then deactivate the original and do not delete it in that step. If the key is already being used against you, deactivate it first and fix the apps after. Then review CloudTrail Event history, AWS's activity log, for access keys, policies, roles or temporary credentials that you did not create. Delete root user access keys you no longer need or did not create. The root user is the account's owner identity. Treat the leaked key as compromised from the moment it was exposed.
An AWS access key opens your cloud account to whoever holds it. IAM, short for Identity and Access Management, is the AWS service where users and their keys are managed, and the steps below happen there. For the general first-hour list that fits any provider, see leaked API key: what to do.
01What to do right now
| Step | What you do | Why |
|---|---|---|
| 1 | Create a second access key while the first is still active | Your apps keep running while you switch |
| 2 | Save the secret access key when it is shown | It cannot be viewed again |
| 3 | Update your applications to use the new key | The old key can then be switched off |
| 4 | Deactivate the original key, do not delete it yet | You can reactivate it for a while if an app breaks |
| 5 | Review CloudTrail Event history | Find keys, policies, roles or temporary credentials you did not create |
| 6 | Delete root user access keys you do not need or did not create | Removes keys nobody uses |
Speed matters when an AWS access key leaked. Automated scanners can locate publicly exposed secrets in minutes, and malicious actors can exploit them within hours. When an AWS access key leaked, the useful question is not who saw it but whether it still works, and the provider is the most reliable source on that. Revoking with the provider is the most important step.
02If the key is already being used
The table keeps the leaked key working while you switch your apps. That is right when nothing suggests abuse. If you can already see the key being used against you, skip steps 1 to 3 and deactivate the original first: choose Actions, then Deactivate. Anything that still sends that key will stop working until you give it a new one. That is the price of closing the door at once, and it is smaller than a growing bill. Create the second key afterwards and move your apps to it.
03Create a second key and move your apps
While the first access key is still active, create a second access key. In the IAM console, choose Users, then the user's name, then the Security credentials tab, and in the Access keys section choose Create access key. This is your only opportunity to save the secret access key, so copy it into your secrets store at once, and do not paste it into a chat or a ticket.
Update each application, script and CI setting that used the old key. If the leaked key sat in a .env file, a shared drive or a repository, the replacement must not go back to the same place. The where to store guide shows safer homes on a Mac. After the switch, the Last used information on the old key tells you whether something still uses it, so you can find the app you forgot before it fails. Write down every place you changed, so that you can tell later which app, script or teammate still held the old key. Keep the old key deactivated, not deleted, until the review is done.
04Deactivate the leaked key, do not delete it
Deactivate the original access key, and do not delete it during this step. Even if the Last used information shows the old key was never used, do not delete it immediately. Instead, choose Actions and then choose Deactivate.
Why keep a dead key? If an application turns out to need it, you can reactivate the original key temporarily to fix the problem. Delete it only after your apps work with the new key and you have finished the review below.
05Review CloudTrail for what you did not create
CloudTrail is AWS's activity log. Open the CloudTrail console, choose Event history in the navigation pane, and look through the events for unsanctioned activity. Read through the list for the creation of access keys, policies, roles or temporary security credentials. AWS lists the same steps on its page about a possibly compromised account. These are the traces of someone setting up a second way back in. Replacing the leaked key does not close a door the attacker opened with a key of their own, so check every item in that list, including the ones that look harmless at first glance.
Treat each item you do not recognize as a finding, and remove it. Do the review from a computer you trust, not from the machine that may have leaked the key. Ask whether any logs or audit trails show the secret being used. To review the charges and usage on your account, use AWS Cost Explorer. The full procedure is in the article on a potential account compromise.
06Root user access keys
The root user is the account's owner identity, and root user access keys are keys that belong to it. Delete the root user access keys that you no longer need or did not create. The steps for finding them are on the same AWS page.
07If the AWS access key leaked on GitHub
An AWS access key leaked through GitHub is a common route. When secret scanning detects a partner secret, GitHub notifies the provider so they can take action, such as revoking the credential. These partner secrets are not displayed in your repository alerts. A quiet repository does not mean a safe key. Some credentials also come as pairs: an alert is created only when both parts are in the same file.
Removing the secret from the codebase, pushing a new commit, or deleting and recreating the repository does not prevent the secret from being exploited. Revoke, then clean. The history steps are in API key exposed on GitHub and remove secrets from Git history.
08If the key left your Mac
Malware that targets developers goes straight for cloud keys. One macOS stealer, MacSync, targets SSH keys, AWS credentials, Kubernetes config and shell history. A backdoor delivered through fake job interviews searches the whole filesystem for credential and secret files. If you ran something you do not trust, rotate from a different computer and follow the infostealer check.
Coding agents can reach those files too. The advice for containers is not to mount host secrets such as ~/.ssh or cloud credential files into them, and to prefer repository-scoped or short-lived tokens. A stealer that takes cloud keys has to run on the Mac first; Artificial Immunity's free, open-source core watches program starts there and reports what it finds.
09Make the next AWS key less useful to a thief
For developer machines the advice is to use just-in-time and short-lived credentials, store secrets in vaults, and avoid long-lived tokens in environment files or local configuration. A key that expires on its own is a smaller prize. Add a hook that rejects commits containing keys: git-secrets, an AWS Labs tool, scans commits and rejects those matching prohibited patterns. On macOS, brew install git-secrets installs it, and you must install its hooks in every repository with git secrets --install.
10After an AWS access key leaked
Create a second key, move your apps, deactivate the original and keep it for now, then read CloudTrail. If the key is being abused, deactivate first. The first-hour checklist has the provider-neutral version, and the OpenAI page covers a different provider. If you are new to keys, what an API key is explains the basics.
FAQ
What do I do first if my AWS access key leaked?
Create a second access key while the first is still active, update your applications, then deactivate the original access key and do not delete it in that step. If the key is already being used against you, deactivate it first and fix the apps after.
Should I delete the leaked access key?
Not at once. Deactivate it first and read its Last used information. Even if Last used shows the key was never used, do not delete it immediately.
How do I see what an attacker did with the key?
Review CloudTrail Event history for unsanctioned activity, such as the creation of access keys, policies, roles or temporary security credentials.
Can I see my secret access key again?
No. The secret access key can be seen only once, when you create the key. Save it right away, in a safe place.
What about root user access keys?
The root user is the account's owner identity. Delete root user access keys that you no longer need or did not create.
Does GitHub tell AWS when a key is pushed?
For partner secrets, GitHub notifies the provider so they can take action, such as revoking the credential. Do not count on it: revoke the key yourself.
Related guides
Sources
- AWS IAM docs, updating access keys
- AWS re:Post, potential account compromise
- GitHub docs, remediating a leaked secret
- GitHub docs, about secret scanning
- GitHub docs, about secret scanning alerts
- git-secrets README
- Microsoft Defender Experts, hunting infostealers on macOS
- Microsoft Security blog, Contagious Interview
- Claude Code docs, devcontainer
- Cursor, extension security notice
- Artificial Immunity