Skip to main content

Common Misconfiguration

AWS credentials hardcoded in source code expose your entire AWS infrastructure to unauthorized access.

Vulnerable Example

Secure Example

Detection Patterns

  • AWS Access Key ID: (AKIA|ASIA)[0-9A-Z]{16}
  • AWS Secret Access Key: [A-Za-z0-9/+=]{40}
  • AWS Session Token Prefix: FwoGZXIvYXdzE[0-9a-zA-Z/+=]+

Prevention Best Practices

  1. Use IAM Roles: Always prefer IAM roles for applications running on EC2, ECS, EKS, and Lambda.
  2. Use Secrets Manager: Store database credentials, API keys, and other secrets in AWS Secrets Manager or Parameter Store.
  3. Use Temporary Credentials: For local development or CI/CD, use AWS STS to generate temporary, short-lived credentials.
  4. Least Privilege: Ensure IAM roles and users have the absolute minimum permissions necessary (e.g., read-only access to a specific S3 bucket).
  5. Enable MFA: Require Multi-Factor Authentication for all human users.
  6. Rotate Credentials: Regularly rotate all long-lived access keys.