Lambda
############################
# AWS Lambda Enumeration Cheat Sheet
############################
# 1. List Lambda Functions
aws lambda list-functions --region <region>
# Info: function names, runtimes, ARNs, last modified
# Goal: identify interesting runtimes, legacy code, targets
############################
# 2. Inspect Function Details
############################
# Get full configuration (IAM role, env vars, timeout, memory)
aws lambda get-function-configuration --function-name <function-name>
# Red flags:
# - Environment variables (secrets, API keys)
# - Overpowered IAM role
# - Long timeout / high memory (useful for abuse)
# Get deployment details + code download URL
aws lambda get-function --function-name <function-name>
# Goal: download and analyze source code (hardcoded creds, logic flaws)
############################
# 3. Check Invocation Permissions
############################
# Resource-based policy (who can invoke it)
aws lambda get-policy --function-name <function-name>
# Red flags:
# - "Principal": "*"
# - Cross-account permissions
# - Public access via Function URL
############################
# 4. Identify Triggers / Event Sources
############################
# Async triggers (SQS, DynamoDB, Kinesis)
aws lambda list-event-source-mappings --function-name <function-name>
# Function URL (HTTP endpoint)
aws lambda get-function-url-config --function-name <function-name>
# Red flag:
# - AuthType = NONE -> public HTTP endpoint
############################
# 5. Invoke Function (if allowed)
############################
aws lambda invoke \
--function-name <function-name> \
--payload '{"key":"value"}' \
output.json
# Goal:
# - Test input validation
# - Trigger privileged actions
# - Abuse backend permissions
############################
# 6. Enumerate Attached IAM Role
############################
# Get role name from get-function-configuration
aws iam get-role --role-name <role-name>
# Managed policies
aws iam list-attached-role-policies --role-name <role-name>
# Inline policies
aws iam list-role-policies --role-name <role-name>
# Red flags:
# - "*"
# - iam:PassRole
# - secretsmanager:GetSecretValue
# - s3:*, dynamodb:*, ec2:*
############################
# 7. Modify Function (Privilege Escalation / Persistence)
############################
# Update function code
aws lambda update-function-code \
--function-name <function-name> \
--zip-file fileb://payload.zip
# Update environment variables
aws lambda update-function-configuration \
--function-name <function-name> \
--environment "Variables={KEY=value}"
# Goal:
# - Persistence
# - Credential exfiltration
# - Lateral movement via IAM role
############################
# Lambda = IAM + Code + Triggers
# Always enumerate all three
############################
Last updated