Exposed AWS credentials: revoke the keys before anything else
Revoking and rotating leaked AWS access keys, then removing the file, cuts off access to your cloud account and your bill
The threat
The scanner requested a path like /.aws/credentials (or /credentials, /aws.txt) and got back aws_access_key_id and aws_secret_access_key lines. That pair is a live long-term key for an AWS account or IAM user. Unlike a password, it needs no second factor: whoever holds it can call the AWS API directly, as that identity.
What they can do depends on the keyβs permissions, and leaked keys are found fast, because bots scan constantly for AKIA... strings. Common outcomes are spinning up expensive compute for crypto mining on your bill, reading S3 buckets, or reaching whatever the key is scoped to. This is time-sensitive in a way most findings are not, so the order of the steps below matters.
The exact fix
Step 1, contain: revoke first, investigate second. In the AWS console, under IAM and the userβs Security credentials tab:
- Deactivate, then delete the exposed access key. Deactivating stops it working immediately, and you do not need to identify misuse before you do it.
- Create a fresh key for the legitimate app and update wherever it is used.
- Review AWS CloudTrail for calls from that key you do not recognize (new IAM users, EC2 launches, S3 reads). If the key was broadly scoped, treat this as an incident.
- Better still, stop using a static key. An IAM role (an instance profile, or OIDC for CI) means there is no long-lived secret to leak next time.
Step 2, stop serving the file.
- Remove the credentials file from the web root.
- Never deploy it: add
.aws/,credentials, and*.pemto.gitignore, and keep home-directory dotfiles out of your build. - Provide credentials through the environment or an instance role, not a file the web server can read.
- Block the path as a backstop.
nginx:
location ~ /\.aws {
deny all;
return 404;
}
Apache:
RedirectMatch 404 "/\.aws"
Rotate even if CloudTrail looks clean. No logged misuse is not proof the key was never copied. For a key that was publicly reachable, the only safe assumption is that it is burned.
Verify it
curl -s https://yourdomain.com/.aws/credentials
Use the exact path from your report. You want a 404. Seeing aws_access_key_id = in the response means the file is still served, and the key needs rotating either way.
Proof
The ApeCyber scanner flags this passively, from the outside, with a single GET, touching nothing and never using the key. apecyber.com holds no cloud keys in its served output: its deploy runs on Netlify with secrets kept in the platform, not in a file. At β40 this is the heaviest single hit on a posture score, and it clears once the keys are revoked and the file is gone.