Lambda
1) Get function with URL
aws lambda get-function --function-name arn:aws:lambda:REGION:AWS_ACCOUNT_ID:function:sample-lambda2) Download
curl "https://GENERATED_URL_FROM_PREVIOUS_COMMAND" --output lambda.zip3) Unzip contents
unzip lambda.zipEnumeration
1) Enumerate Lambda functions
aws lambda list-functions2) Enumerate policies attached to each function
FUNCTIONS="LAMBDA_FUNCTION_NAME NAME_2"
for f in $FUNCTIONS ; do
ROLE=`aws lambda get-function --function-name $f --query Configuration.Role --output text | awk -F\/ '{print $NF}'`
echo "$f has $ROLE with these managed policies:"
aws iam list-attached-role-policies --role-name $ROLE
for p in `aws iam list-role-policies --role-name $ROLE --query PolicyNames --output text` ; do
echo "$ROLE for $f has inline policy $p:"
aws iam get-role-policy --role-name $ROLE --policy-name $p
done
done3) Download function code for analysis
4) Create a new zip file to ready it for upload after modification
Insert Malicious Code
1) Check policies in the Lambda function
Interesting findings:
2) Modify the function with a reverse shell, or print sensitive information.
3) Invoke function
Last updated