Skip to main content
MediumSecretsOWASP A07:2021CWE-798

How to fix: AWS Access Key ID in source

AKIA* keys are not secrets by themselves but pair with secret keys.

Why it matters

An exposed AWS Access Key ID is a partial credential. It is harmless without the matching secret key. However, its exposure signals that secret keys may also be present in the same codebase, and the Key ID is needed to rotate or audit usage even after compromise.

AKIA* keys are not secrets by themselves but pair with secret keys.

How to fix it

  1. 1Search the same codebase for the matching SecretAccessKey (40-char base64 string)
  2. 2Rotate both keys via IAM if both are present or if exposure is uncertain
  3. 3Move to IAM Roles and short-lived STS tokens to eliminate long-lived key pairs entirely

Code examples

Detect co-located secret key

bash
# Search for the matching secret key near the Access Key ID
# AWS Secret Access Keys are 40-char base64 strings
grep -rE '[A-Za-z0-9/+=]{40}' --include='*.js' --include='*.ts' --include='*.env' .

# If found, rotate immediately:
aws iam create-access-key --user-name YOUR_USER
aws iam update-access-key --access-key-id AKIA... --status Inactive --user-name YOUR_USER

Use IAM Roles instead of key pairs

TypeScript
// On AWS compute (EC2, Lambda, ECS, EKS): use IAM roles
// The SDK picks up credentials automatically: no key pair needed
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';

const db = new DynamoDBClient({ region: 'us-east-1' });
// No credentials config: relies on the attached IAM role

References

Detected automatically by VulnRadar. The check id is secret-aws-access-key-id, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is AWS Access Key ID in source?
VulnRadar rates this medium 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-access-key-id, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does AWS Access Key ID 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.

Propose a checkHow a check is built

Scan your own site for aws access key id in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: AWS Access Key ID in source | VulnRadar