Back to Playbooks
CriticalVerifiedOfficial Docs

AWS — Access Key

AWS IAM access keys grant programmatic access to AWS services. Exposure can lead to full infrastructure compromise.

Verified Jan 15, 2025Category: Cloud Infrastructure

Immediate Action Required

Deleting a leaked credential from a repository does not invalidate it. Assume it has already been copied. Follow the revocation steps below immediately, then investigate for unauthorized access.

What Is This Credential?

AWS IAM access keys grant programmatic access to AWS services. Exposure can lead to full infrastructure compromise.

Permissions Granted

  • Full AWS API access scoped to IAM user permissions
  • Potential access to S3, EC2, RDS, Lambda, and all attached policies

Exposure & Blast Radius

  • Unauthorized resource provisioning (EC2, RDS, Lambda)
  • Data exfiltration from S3 buckets
  • Credential escalation via IAM manipulation
  • Significant unexpected billing charges
  • Deletion or modification of infrastructure

Immediate Response Steps

1

Identify the exposed key

Note the Access Key ID (starts with AKIA or ASIA). Check git history, CI logs, and environment files.

bash
git log --all -p | grep -i 'AKIA\|ASIA'
2

Deactivate the key immediately

Go to IAM → Users → Security credentials → Deactivate the key. Do not delete yet — deactivation is reversible if needed for investigation.

3

Check CloudTrail for unauthorized activity

Review CloudTrail logs for API calls made with the exposed key in the past 90 days.

4

Create a replacement key

Generate a new access key and update all services, CI/CD pipelines, and environment variables.

5

Delete the old key

Once all services are updated and verified, permanently delete the deactivated key.

6

Review and tighten IAM permissions

Apply least-privilege policies to the new key. Remove any permissions not strictly required.

Revocation vs Rotation

Revocation

Deactivate the key in IAM console or via CLI: `aws iam update-access-key --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive --user-name <username>`. Deactivation is immediate.

Rotation

Create a new key via IAM console or `aws iam create-access-key --user-name <username>`. Update all consumers before deleting the old key.

Grace Period & Session Persistence

Grace Period

None. Deactivation is immediate — the key stops working the moment it is set to Inactive.

Session Persistence

Temporary credentials (STS AssumeRole sessions) derived from the key remain valid until their own expiry (up to 12 hours). Revoke active sessions by attaching a DenyAll policy to the user.

Investigation Checklist

  • Review CloudTrail in all regions for API calls using the exposed key ID
  • Check for new IAM users, roles, or policies created
  • Look for unusual EC2 instance launches (especially GPU instances for crypto mining)
  • Review S3 access logs for unexpected GetObject or PutObject calls
  • Check AWS Cost Explorer for billing anomalies
  • Look for new STS AssumeRole calls that may have created derived sessions
  • Review VPC flow logs for unexpected outbound traffic

Recovery Steps

  • Update all environment variables and secrets managers with the new key
  • Rotate secrets in CI/CD systems (GitHub Actions, CircleCI, etc.)
  • Remove the exposed key from any git history using git-filter-repo
  • Enable AWS GuardDuty if not already active
  • Enable MFA on the IAM user
  • Consider using IAM roles instead of long-lived access keys

Prevention

  • Use IAM roles instead of access keys wherever possible
  • Enable AWS Secrets Manager or Parameter Store for key storage
  • Enable git-secrets or truffleHog pre-commit hooks
  • Enable GitHub secret scanning on all repositories
  • Set up AWS Config rules to detect public S3 buckets
  • Apply least-privilege IAM policies
  • Rotate access keys every 90 days

Sources & Evidence

Always verify critical instructions with official provider documentation before taking action. Provider behavior may change without notice.

Found an issue with this playbook?

If these instructions are incorrect, outdated, or missing important information, please report it so we can improve the playbook.

Report an Issue on GitHub