How to fix: AWS Secret Access Key in source
AWS secret access keys (40-char base64) must never be in client code or public buckets.
Why it matters
An exposed AWS Secret Access Key paired with an Access Key ID gives attackers full programmatic access to your AWS account at the permissions level of that IAM user: this can mean reading S3 buckets, spinning up EC2 instances, creating new IAM users, or incurring six-figure compute bills before you notice.
AWS secret access keys (40-char base64) must never be in client code or public buckets.
How to fix it
- 1Rotate the key in IAM immediately (deactivate old key, create new key)
- 2Check CloudTrail for API calls made with the compromised key
- 3Use IAM Roles and short-lived STS credentials instead of long-lived access keys
Code examples
Rotate compromised AWS credentials
# 1. Create a new key
aws iam create-access-key --user-name YOUR_USER
# 2. Update your environment/secrets manager with the new key
# 3. Deactivate the old key
aws iam update-access-key --access-key-id AKIA... --status Inactive --user-name YOUR_USER
# 4. Check CloudTrail for unauthorized usage
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIA...Use IAM Role (recommended, no long-lived keys)
// On EC2/Lambda/ECS, use the instance/task role: no keys needed
import { S3Client } from '@aws-sdk/client-s3';
// SDK automatically picks up the IAM role from the environment
const s3 = new S3Client({ region: 'us-east-1' });
// No accessKeyId or secretAccessKey: uses the attached roleReferences
Detected automatically by VulnRadar. The check id is secret-aws-secret-key, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is AWS Secret Access Key in source?
- VulnRadar rates this critical severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id secret-aws-secret-key, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does AWS Secret Access Key in source map to?
- It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.