CloudGoat Lambda Privilege Escalation Walkthrough
This walkthrough demonstrates a complete CloudGoat Lambda privilege escalation scenario using the powerful CloudTap enumeration tool. We’ll explore how an attacker can leverage Lambda functions and IAM role passing to escalate from limited permissions to full administrative access in an AWS environment. This CloudGoat walkthrough showcases a critical privilege escalation path that security professionals should understand and defend against.
Initial Setup
First, configure CloudGoat to whitelist your IP address:
1 | cloudgoat config whitelist --auto |
Create the Lambda privilege escalation scenario:
1 | cloudgoat create lambda_privesc |
You’ll receive initial credentials:
1 | raynor_access_key_id = AKIAQ6VKGD5Y[REDACTED] |
Automated Enumeration with CloudTap
For this walkthrough, we’ll use CloudTap, an excellent automation tool that streamlines the initial enumeration phase of AWS penetration testing. CloudTap automatically discovers permissions, roles, and potential privilege escalation paths, making it invaluable for security assessments.
Initial Permission Discovery
CloudTap reveals the following attached policy:
1 | Found attached policy: cg-chris-policy-cgid[REDACTED] |
Role Discovery and Auto-Assumption
CloudTap also identifies a potential role we can assume:
1 | { |
One of CloudTap’s powerful features is its ability to automatically assume roles when the user has AssumeRole
permissions. The tool provides temporary session credentials:
1 | Temporary session credentials: |
Permission Analysis
Lambda Manager Role Permissions
Let’s examine what permissions our assumed role provides. First, get the policy ARN:
1 | aws iam list-attached-role-policies --role-name cg-lambdaManager-role-cgid[REDACTED] --profile init |
Output:
1 | { |
Get the policy details:
1 | aws iam get-policy --policy-arn arn:aws:iam::[ACCOUNT-ID]:policy/cg-lambdaManager-policy-cgid[REDACTED] --profile init |
Output:
1 | { |
Target Role Discovery
CloudTap also identifies a target role that we can assume:
1 | { |
Privilege Escalation Strategy
With the sts:AssumeRole
permission for the cg-target-role-cgid[REDACTED]
role, we can escalate our privileges. Assuming this role provides us with higher-level permissions, potentially including administrative access.
Lambda Function Creation and Exploitation
Creating the Malicious Lambda Function
To exploit the Lambda function, we can create a malicious Lambda function that performs actions such as attaching policies to users or roles. The function’s code might look like this:
1 | import boto3 |
Function Execution
Invoke the Lambda function to execute the malicious actions:
1 | aws lambda invoke --function-name maliciousLambdaFunction output.txt |
Verification of Privilege Escalation
After executing the malicious Lambda function, verify that the raynor
user has been granted administrative privileges:
1 | aws iam list-attached-user-policies --user-name raynor --profile init |
Output:
1 | { |
This confirms that the privilege escalation was successful.
About CloudTap
CloudTap is an automation tool designed to streamline the initial enumeration phase of AWS penetration testing. It assists in discovering permissions, roles, and potential privilege escalation paths, making it an invaluable tool for security assessments.
Note: This walkthrough is based on the CloudGoat Lambda privilege escalation scenario and is intended for educational purposes only. Always ensure you have proper authorization before conducting any security testing.