Enumerate Secrets in AWS

Tips and tricks for discovering secrets in AWS

Secrets Enumeration

Plaintext or hard-coded secrets can be found in many resources throughout AWS if there is poor hygiene in the management of secrets.


CloudFormation

  • CloudFormation is an AWS infrastructure-as-code solution written in JSON or YAML

# provides details of the stacks including parameter key/values
aws --region us-east-1 cloudformation describe-stacks

# view the source code for a specific stack
aws --region us-east-1 cloudformation get-template --stack-name execution | jq -r '.TemplateBody'

EC2 Instances

User-data

  • Secrets can end up hard-coded in EC2 user-data and can easily be discovered either with the action ec2:DescribeInstanceAttributeor by querying the IMDS service

AWS CLI

IMDSv1

IMDSv2

  • Version 2 of IMDS requires obtaining a token first


EC2 Launch Templates

  • EC2 Launch Templates allow for defining consistent configurations (Security Groups, IMDS, Instance types, User Data, etc.) for any EC2 that uses the template

  • So User Data can also be found in the templates


EBS Snapshots

  • EBS Snapshots are backups of EC2 instances and may have secrets and credentials stored on them

  • See also EBS Snapshots


Lambda

Environment Variables

  • Environment variables are commonly used for storing data used by the lambda function

Functions

  • The code of the function may also contain information


RDS Snapshots

  • RDS Snapshots are backups of RDS instances and may contain valuable data

  • See also RDS Snapshots


Secrets Manager


SSM

Documents

  • SSM Documents allow you to run automations and commands on EC2s and may contain sensitive data

  • See also SSM Documents

Parameters

  • You can reference Systems Manager parameters in your scripts, commands, SSM documents, and configuration and automation workflows


Terraform State

  • While not an AWS resource, Terraform State files are commonly stored in AWS S3 buckets

  • If the data is not encrypted and/or you have access to decrypt the data, Terraform State files often contain secrets, credentials, and information about the cloud environment

Last updated

Was this helpful?