Git Product home page Git Product logo

cloudgoat's Introduction

CloudGoat (☁️🐐)

Rhino PyPI GitHub license PRs Welcome

CloudGoat is Rhino Security Labs' "Vulnerable by Design" AWS deployment tool.

Quick reference

CloudGoat 2.0 is here!

CloudGoat is Rhino Security Labs' "Vulnerable by Design" AWS deployment tool. It allows you to hone your cloud cybersecurity skills by creating and completing several "capture-the-flag" style scenarios. Each scenario is composed of AWS resources arranged together to create a structured learning experience. Some scenarios are easy, some are hard, and many offer multiple paths to victory. As the attacker, it is your mission to explore the environment, identify vulnerabilities, and exploit your way to the scenario's goal(s).

Below are our main goals for CloudGoat:

  • Focused, Curated, High-Quality Learning Experiences - Each of CloudGoat’s scenarios should provide the opportunity for experimentation, exploration, and building hands-on cloud security skills.
  • Good Documentation - We've done our best to ensure that CloudGoat’s scenarios are well-documented and easy to understand and evaluate in terms of difficulty, content, structure, and skills-required.
  • Easy to Install and Use - We understand that CloudGoat is a means to an end - learning and practicing cloud security penetration testing. Therefore, we aim to keep things simple, straightforward, and reliable.
  • Modularity - Each scenario is a standalone learning environment with a clear goal (or set of goals), and CloudGoat is able to start up, reset, or shut down each scenario independently.
  • Expandability - CloudGoat’s core components (python app and scenarios) are designed to permit easy and independent expansion - by us or the community.

Before you proceed, please take note of these warnings!

Warning #1: CloudGoat creates intentionally vulnerable AWS resources into your account. DO NOT deploy CloudGoat in a production environment or alongside any sensitive AWS resources.

Warning #2: CloudGoat can only manage resources it creates. If you create any resources yourself in the course of a scenario, you should remove them manually before running the destroy command.

Requirements

  • Linux or MacOS. Windows is not officially supported.
    • Argument tab-completion requires bash 4.2+ (Linux, or OSX with some difficulty).
  • Python3.6+ is required.
  • Terraform >= 0.14 installed and in your $PATH.
  • The AWS CLI installed and in your $PATH, and an AWS account with sufficient privileges to create and destroy resources.
  • jq

Quick Start

To install CloudGoat, make sure your system meets the requirements above, and then run the following commands:

git clone https://github.com/RhinoSecurityLabs/cloudgoat.git
cd cloudgoat
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r ./requirements.txt
chmod +x cloudgoat.py

You may also want to run some quick configuration commands - it'll save you some time later:

$ ./cloudgoat.py config profile
$ ./cloudgoat.py config whitelist --auto

Now, at your command, CloudGoat can create an instance of a scenario in the cloud. When the environment is ready, a new folder will be created in the project base directory named after the scenario and with a unique scenario ID appended. Inside this folder will be a file called start.txt, which will contain all of the resources you'll need to begin the scenario, though these are also printed to your console when the create command completes. Sometimes an SSH keypair named cloudgoat/cloudgoat.pub will be created as well.

Note: Don't delete or modify the scenario instance folder or the files inside, as this could prevent CloudGoat from being able to manage your scenario's resources.

As you work through the scenario, feel free to refer to the scenario's readme if you need direction. If you get stuck, there are cheat sheets linked at the bottom of each route's walkthrough.

When you are finished with the scenario, delete any resources you created yourself (remember: CloudGoat can only manage resources it creates) and then run the destroy command. It's always a good idea to take a quick glance at your AWS web-console afterwards - just in case something didn't get deleted.

You can read the full documentation for CloudGoat's commands here in the Usage Guide section.

How to use CloudGoat's Docker image

Try in PWD

Option 1: Run with default entrypoint

$ docker run -it rhinosecuritylabs/cloudgoat:latest

Option 2: Run with AWS config and credentials

Warning: Running this command will mount your local AWS configuration files into the Docker container when it is launched. This means that any user with access to the container will have access to your host computer's AWS credentials.

$ docker run -it -v ~/.aws:/root/.aws/ rhinosecuritylabs/cloudgoat:latest

Scenarios Available

vulnerable_lambda (Small / Easy)

$ ./cloudgoat.py create vulnerable_lambda

In this scenario, you start as the 'bilbo' user. You will assume a role with more privileges, discover a lambda function that applies policies to users, and exploit a vulnerability in the function to escalate the privelages of the bilbo user in order to search for secrets.

Visit Scenario Page.

vulnerable_cognito (Small / Moderate)

$ ./cloudgoat.py create vulnerable_cognito

In this scenario, you are presented with a signup and login page with AWS Cognito in the backend. You need to bypass restrictions and exploit misconfigurations in Amazon Cognito in order to elevate your privileges and get Cognito Identity Pool credentials.

Contributed by TrustOnCloud.

Visit Scenario Page.

iam_privesc_by_key_rotation (Small / Easy)

$ ./cloudgoat.py create iam_privesc_by_key_rotation

Exploit insecure IAM permissions to escalate your access. Start with a role tha manages other users credentials and find a weakness in the setup to access the "admin" role. Using the admin role retrieve the flag from secretsmanager.

Contributed by infrasec.sh.

Visit Scenario Page.

iam_privesc_by_rollback (Small / Easy)

$ ./cloudgoat.py create iam_privesc_by_rollback

Starting with a highly-limited IAM user, the attacker is able to review previous IAM policy versions and restore one which allows full admin privileges, resulting in a privilege escalation exploit.

Visit Scenario Page.

lambda_privesc (Small / Easy)

$ ./cloudgoat.py create lambda_privesc

Starting as the IAM user Chris, the attacker discovers that they can assume a role that has full Lambda access and pass role permissions. The attacker can then perform privilege escalation using these new permissions to obtain full admin privileges.

Note: This scenario may require you to create some AWS resources, and because CloudGoat can only manage resources it creates, you should remove them manually before running ./cloudgoat destroy.

Visit Scenario Page.

sqs_flag_shop (Small / Easy)

$ ./cloudgoat.py create sqs_flag_shop

First, start with the SHOP page where you can buy FLAG. The website has a number of pages, and you can see that the source code is exposed. Attackers analyze the code to find vulnerabilities and use their privileges to purchase FLAG.

Visit Scenario Page.

cloud_breach_s3 (Small / Moderate)

$ ./cloudgoat.py create cloud_breach_s3

Starting as an anonymous outsider with no access or privileges, exploit a misconfigured reverse-proxy server to query the EC2 metadata service and acquire instance profile keys. Then, use those keys to discover, access, and exfiltrate sensitive data from an S3 bucket.

Visit Scenario Page.

iam_privesc_by_attachment (Medium / Moderate)

$ ./cloudgoat.py create iam_privesc_by_attachment

Starting with a very limited set of permissions, the attacker is able to leverage the instance-profile-attachment permissions to create a new EC2 instance with significantly greater privileges than their own. With access to this new EC2 instance, the attacker gains full administrative powers within the target account and is able to accomplish the scenario's goal - deleting the cg-super-critical-security-server and paving the way for further nefarious actions.

Note: This scenario may require you to create some AWS resources, and because CloudGoat can only manage resources it creates, you should remove them manually before running ./cloudgoat destroy.

Visit Scenario Page.

ec2_ssrf (Medium / Moderate)

$ ./cloudgoat.py create ec2_ssrf

Starting as the IAM user Solus, the attacker discovers they have ReadOnly permissions to a Lambda function, where hardcoded secrets lead them to an EC2 instance running a web application that is vulnerable to server-side request forgery (SSRF). After exploiting the vulnerable app and acquiring keys from the EC2 metadata service, the attacker gains access to a private S3 bucket with a set of keys that allow them to invoke the Lambda function and complete the scenario.

Visit Scenario Page.

ecs_takeover (Medium / Moderate)

$ ./cloudgoat.py create ecs_takeover

Starting with access to the external website, the attacker needs to find a remote code execution vulnerability. By using RCE the attacker can get access to resources available to the website container. Abusing several ECS misconfigurations the attacker gains access to IAM permissions that allow them to force ECS into rescheduling the target container to a compromised instance.

Visit Scenario Page.

rds_snapshot (Medium / Moderate)

$ ./cloudgoat.py Create rds_snapshot

In this scenario, we start with the user 'David'. Through David, you can leverage privileges to steal credentials. With the stolen credentials, an attacker can leverage the RDS vulnerability to access the DB and retrieve flags.

Note: This scenario may require you to create some AWS resources, and because CloudGoat can only manage resources it creates, you should remove them manually before running ./cloudgoat destroy.

Visit Scenario Page.

rce_web_app (Medium / Hard)

$ ./cloudgoat.py create rce_web_app

Starting as the IAM user Lara, the attacker explores a Load Balancer and S3 bucket for clues to vulnerabilities, leading to an RCE exploit on a vulnerable web app which exposes confidential files and culminates in access to the scenario’s goal: a highly-secured RDS database instance.

Alternatively, the attacker may start as the IAM user McDuck and enumerate S3 buckets, eventually leading to SSH keys which grant direct access to the EC2 server and the database beyond.

Visit Scenario Page.

codebuild_secrets (Large / Hard)

$ ./cloudgoat.py create codebuild_secrets

Starting as the IAM user Solo, the attacker first enumerates and explores CodeBuild projects, finding unsecured IAM keys for the IAM user Calrissian therein. Then operating as Calrissian, the attacker discovers an RDS database. Unable to access the database's contents directly, the attacker can make clever use of the RDS snapshot functionality to acquire the scenario's goal: a pair of secret strings.

Alternatively, the attacker may explore SSM parameters and find SSH keys to an EC2 instance. Using the metadata service, the attacker can acquire the EC2 instance-profile's keys and push deeper into the target environment, eventually gaining access to the original database and the scenario goal inside (a pair of secret strings) by a more circuitous route.

Note: This scenario may require you to create some AWS resources, and because CloudGoat can only manage resources it creates, you should remove them manually before running ./cloudgoat destroy.

Visit Scenario Page.

cicd (Medium / Moderate)

$ ./cloudgoat.py create cicd

FooCorp is a company exposing a public-facing API. Customers of FooCorp submit sensitive data to the API every minute. The API is implemented as a Lambda function, exposed through an API Gateway. Because FooCorp implements DevOps, it has a continuous deployment pipeline automatically deploying new versions of their Lambda function from source code to production in under a few minutes.

Your goal: steal the sensitive data submitted by FooCorp customers!

Contributed by Datadog.

Visit Scenario Page.

detection_evasion (Medium / Hard)

$ ./cloudgoat.py create detection_evasion

The goal of this scenario is to read out the values for both secrets without being detected. The secrets are both stored in Secrets Manager, and their values have the following format (cg-secret-XXXXXX-XXXXXX).

This scenario is significantly different from other CloudGoat scenarios. In detection_evasion, your goals will be outlined for you more clearly, and the challenge is to complete them without triggering alarms. There is more setup involved in this scenario, and it will take longer to play (you might want/need to play it multiple times).

Visit Scenario Page.

ecs_efs_attack (Large / Hard)

$ ./cloudgoat.py create ecs_efs_attack

Starting with access the "ruse" EC2 the user leverages the instace profile to backdoor the running ECS container. Using the backdoored container the attacker can retireve credentials from the container metadata API. These credentials allow the attacker to start a session on any EC2 with the proper tags set. The attacker uses their permissions to change the tags on the Admin EC2 and starts a session. Once in the Admin EC2 the attacker will port scan the subnet for an open EFS to mount. Once mounted the attacker can retrieve the flag from the elastic file system.

Visit Scenario Page.

glue_privesc(Large / Moderate)

$ ./cloudgoat.py create glue_privesc

This scenario starts with a web page that uploads a CSV file and performs data visualization through the Glue service. The attacker steals the credentials present on the webpage via a SQL injection attack and uploads a reverse shell to create a Glue Job to obtain the secret string

Note: This scenario may require you to create some AWS resources, and because CloudGoat can only manage resources it creates, you should remove them manually before running ./cloudgoat destroy.

Visit Scenario Page.

Usage Guide

The basic anatomy of a CloudGoat command is as follows:

$ ./cloudgoat.py [ command ] [ sub-command ] [ --arg-name ] [ arg-value ]

The five main commands in CloudGoat are summarized below:

create

create [ scenario-name ] deploys a scenario to the AWS account of your choosing. You can also run create against an existing scenario if you wish - CloudGoat will simply destroy and recreate the scenario named.

Tip: you can use /scenarios in the name, which allows for bash's native tab-completion.

Note that the --profile is required for safety reasons - we don't want anyone accidentally deploying CloudGoat scenarios to a production environment - and CloudGoat will not use the system's "default" AWS CLI profiles or profiles specified as defaults via environment variables. You can, however, set this via config profile to avoid having to provide it every time.

list

list shows some information about all, undeployed, or deployed scenarios, or even a lot of information about a [ scenario-name ] that's already deployed.

destroy

destroy shuts down and deletes a [ scenario-name ]'s cloud resources, and then moves the scenario instance folder to ./trash - just in case you need to recover the Terraform state file or other scenario files. You can also specify all instead of a scenario name to destroy all active scenarios.

Tip: CloudGoat can only manage resources it creates. If you create any resources yourself in the course of a scenario, you should remove them manually before running the destroy command.

config

config allows you to manage various aspects of your CloudGoat installation, specially the IP whitelist, your default AWS profile, and tab-completion via argcomplete. It's worth briefly describing what each of these sub-commands do.

whitelist

CloudGoat needs to know what IP addresses should be whitelisted when potentially-vulnerable resources are deployed in the cloud, and these IPs are tracked in a ./whitelist.txt file in the base project directory. The IP address you provide for whitelisting doesn't have to be in CIDR format, but CloudGoat will add a /32 to any naked IPs you provide. Optionally, you can add the --auto argument, and CloudGoat will automatically make a network request, using curl to ifconfig.co to find your IP address, and then create the whitelist file with the result.

profile

While CloudGoat will not ever use the system's "default" AWS CLI profiles or profiles specified as defaults via environment variables, you can instruct CloudGoat to use a particular AWS profile by name using the config profile command. This will prompt for and save your profile's name in a config.yml file in the base project directory. As long as that file is present CloudGoat will use the profile name listed inside for create and destroy commands, rather than requiring the --profile flag. You can run the config profile command at any time to view the name of your CloudGoat-default profile and validate the format of the config.yml. You can also create config.yml manually, if you wish, provided that you use the correct format.

argcomplete

We really wanted to have native tab-completion in CloudGoat, but as it turns out that was somewhat difficult to do outside of a REPL. It should work reasonably well for Linux users, and those OSX users brave enough to figure out a way to upgrade their bash version to 4.2+. CloudGoat does include and support the python library "argcomplete". A brief summary of how to install argcomplete is provided below, though for more detailed steps you should refer to the official documentation at the library's github page.

  1. Install the argcomplete Python package using CloudGoat's requirements.txt file: $ pip3 install -r core/python/requirements.txt
  2. In bash, run the global Python argument completion script provided by the argcomplete package: $ activate-global-python-argcomplete
  3. Source the completion script at the location printed by the previous activation command, or restart your shell session: $ source [ /path/to/the/completion/script ]

For those who cannot or do not wish to configure argcomplete, CloudGoat also supports the use of directory paths as scenario names, which means tab-completion will work for scenario names. Just use /scenario/[ scenario-name ] or ./[ scenarioinstance-name ] and your shell should do the rest.

help

help provides contextual help about commands. help can come before or after the command in question, so it's always there when you need it. Below are some examples:

  • $ ./cloudgoat.py create help
  • $ ./cloudgoat.py destroy help
  • $ ./cloudgoat.py list help
  • $ ./cloudgoat.py config help

One other use of note: $ ./cloudgoat.py [ scenario-name ] help can be used to print to the console a brief summary of the scenario, as defined by the scenario's author.

Feature Requests and Bug Reports

If you have a feature request or a bug to report, please submit them here.

For bugs, please make sure to include a description sufficient to reproduce the bug you found, including tracebacks and reproduction steps, and check for other reports of your bug before filing a new bug report.

For features, much the same applies! Be specific in your request, and make sure someone else hasn't already requested the same feature.

Contribution Guidelines

Contributions to CloudGoat are greatly appreciated. If you'd like to help make the project better, read on.

  1. Python code in CloudGoat should generally follow Python's style conventions, favoring readability and maintainability above all.
  2. Follow good git practices: use pull requests, prefer feature branches, always write clear commit messages.
  3. CloudGoat uses black and flake8 - Python syntax and style linters - If you're going to commit code for CloudGoat, ensure that first flake8, and then black are both run on all Python files in core/python/ and on cloudgoat.py. black's decisions take priority over flake8's. Both of these are commented out in the core/python/requirements.txt file since normal users don't need them.
  4. CloudGoat code should always use the BSD 3-clause license.

And lastly, thank you for contributing!

Changelog

  • 6/24/19: CloudGoat 2.0 is released!

Disclaimer

CloudGoat is software that comes with absolutely no warranties whatsoever. By using CloudGoat, you take full responsibility for any and all outcomes that result.

cloudgoat's People

Contributors

andrew-aiken avatar benjamincaudill avatar christophetd avatar cmd-ctrl-freq avatar daveyesland avatar dependabot[bot] avatar dickensja avatar galoget avatar gchib297 avatar hamstah avatar hosim33 avatar j0eblow avatar jack-ganbold avatar jdearmas avatar lazzslayer avatar lukaszmrozowski avatar n3ddih avatar naikordian avatar ryanjarv avatar sebastian-mora avatar sethsec-bf avatar sgn00 avatar sidejackthenativity avatar sn0x736e avatar spengietz avatar tenebrae93 avatar tt0kyu avatar usamaazad avatar west-wise avatar yogisec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudgoat's Issues

OSX Permission denied for ./cloudgoat.py config profile

How to Replicate

After a fresh clone following the README instructions when I attempted to run ./cloudgoat.py config profile I received a permissions error: eg.

~/Desktop/CloudGoat[master]: ./cloudgoat.py config profile
-bash: ./cloudgoat.py: Permission denied

I gave permissions a look:

~/Desktop/CloudGoat[master]: ls -la
total 56
drwxr-xr-x   9 andrewbrown  staff    288 29 Jun 12:40 .
drwx------+ 71 andrewbrown  staff   2272 29 Jun 12:40 ..
drwxr-xr-x  12 andrewbrown  staff    384 29 Jun 12:40 .git
-rw-r--r--   1 andrewbrown  staff    205 29 Jun 12:40 .gitignore
-rw-r--r--   1 andrewbrown  staff   1519 29 Jun 12:40 LICENSE
-rw-r--r--   1 andrewbrown  staff  14644 29 Jun 12:40 README.md
-rw-r--r--   1 andrewbrown  staff   3552 29 Jun 12:40 cloudgoat.py
drwxr-xr-x   4 andrewbrown  staff    128 29 Jun 12:40 core
drwxr-xr-x   7 andrewbrown  staff    224 29 Jun 12:40 scenarios

So I chmod u+x cloudgoat.py and this resolved the permission denied

~/Desktop/CloudGoat[master]: chmod u+x cloudgoat.py
~/Desktop/CloudGoat[master]: ls -la
total 56
drwxr-xr-x   9 andrewbrown  staff    288 29 Jun 12:40 .
drwx------+ 71 andrewbrown  staff   2272 29 Jun 12:40 ..
drwxr-xr-x  12 andrewbrown  staff    384 29 Jun 12:40 .git
-rw-r--r--   1 andrewbrown  staff    205 29 Jun 12:40 .gitignore
-rw-r--r--   1 andrewbrown  staff   1519 29 Jun 12:40 LICENSE
-rw-r--r--   1 andrewbrown  staff  14644 29 Jun 12:40 README.md
-rwxr--r--   1 andrewbrown  staff   3552 29 Jun 12:40 cloudgoat.py
drwxr-xr-x   4 andrewbrown  staff    128 29 Jun 12:40 core
drwxr-xr-x   7 andrewbrown  staff    224 29 Jun 12:40 scenarios

I don't have Terraform as of yet but did resolve permissions denied

~/Desktop/CloudGoat[master]: ./cloudgoat.py config profile
Terraform not found. Please install Terraform before using CloudGoat.

Recommended Suggestion

Update the Quick Start to include the step:

chmod u+x cloudgoat.py

User Data not applied on first boot - instance unreachable via SSH and HTTP

When creating the environment with ./start.sh it runs as intended however the instance is later unreachable as the User-Data is not executed on the created instance. It required the instance to be rebooted, which then executed UserData as intended.

This was verified by removing #cloud-boothook from ec2.tf file, which will cause User data to execute on initial launch instead of every-other reboot.

Feature Request: Tenant to Tenant Scenario

Fantastic tool all, really helping me learn more than I though on AWS testing. Do you have any plans of releasing a tenant to tenant scenario of say compromising a "prod" tenant from a "dev" tenant?

Thanks again for this tool!

Error deploying all labs related to S3 service

Hello!
I am getting the following errors for each lab that makes use of the S3 service:
I am using the terraform version: v1.0.4
And also my AWS version is: aws-cli/1.19.1 Python/3.9.2 botocore/1.20.0

LAB cloud_breach_s3
Error creating S3 bucket: InvalidBucketName: The specified bucket is not valid. │ status code: 400, request id: XXXXX, host id: XXXXX │ │ with aws_s3_bucket.cg-secret-s3-bucket, │ on s3.tf line 2, in resource "aws_s3_bucket" "cg-cardholder-data-bucket": │ 2: resource "aws_s3_bucket" "cg-cardholder-data-bucket"

LAB ec2_ssrf
Error creating S3 bucket: InvalidBucketName: The specified bucket is not valid. │ status code: 400, request id: XXXXX, host id: XXXXX │ │ with aws_s3_bucket.cg-secret-s3-bucket, │ on s3.tf line 2, in resource "aws_s3_bucket" "cg-secret-s3-bucket": │ 2: resource "aws_s3_bucket" "cg-secret-s3-bucket" {

LAB rce_web_app
[cloudgoat] terraform init completed with no error code. ╷ │ Error: only alphanumeric characters and hyphens allowed in "name": "cg-lb-rce_web_app_cgid8lfijuwyg9" │ │ with aws_lb.cg-lb, │ on lb.tf line 28, in resource "aws_lb" "cg-lb": │ 28: name = "cg-lb-${var.cgid}" │ ╵ ╷ │ Error: "name" cannot be longer than 32 characters │ │ with aws_lb_target_group.cg-target-group, │ on lb.tf line 52, in resource "aws_lb_target_group" "cg-target-group": │ 52: name = "cg-target-group-${var.cgid}" │ ╵ ╷ │ Error: only alphanumeric characters and hyphens allowed in "name" │ │ with aws_lb_target_group.cg-target-group, │ on lb.tf line 52, in resource "aws_lb_target_group" "cg-target-group": │ 52: name = "cg-target-group-${var.cgid}" │ ╵ ╷ │ Error: only lowercase alphanumeric characters and hyphens allowed in "identifier" │ │ with aws_db_instance.cg-psql-rds, │ on rds.tf line 47, in resource "aws_db_instance" "cg-psql-rds": │ 47: identifier = "cg-rds-instance-${var.cgid}"

IAM privesc by rollback variable.tf issue

Ran into the following issue on a mac
Seems like an issue during the terraform variable script generation.

(cloudgoat) ~/D/A/cloudgoat ❯❯❯ ./cloudgoat.py create iam_privesc_by_rollback                                       master ✱ ◼
Using default profile "cloudgoat" from config.yml...
Loading whitelist.txt...
A whitelist.txt file was found that contains at least one valid IP address or range.
You already have an instance of iam_privesc_by_rollback deployed. Do you want to destroy and recreate it (y) or cancel (n)? [y/n]: y

No terraform.tfstate file was found in the scenario instance's terraform directory, so "terraform destroy" will not be run.

Successfully destroyed iam_privesc_by_rollback_cgidicp2zml7sv.
Scenario instance files have been moved to /Users/d/Desktop/AWS exploits/cloudgoat/trash/iam_privesc_by_rollback_cgidicp2zml7sv
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Error parsing /Users/d/Desktop/AWS exploits/cloudgoat/iam_privesc_by_rollback_cgidff1qjx40y3/terraform/variables.tf: At 15:10: Unknown token: 15:10 IDENT list

[cloudgoat] Error while running `terraform init`.
    exit code: 1
    stdout: None
    stderr: None

hi bro

I want to create codebuild_secrets
but
Error: only lowercase alphanumeric characters and hyphens allowed in "identifier"

│ with aws_db_instance.cg-psql-rds,
│ on rds.tf line 51, in resource "aws_db_instance" "cg-psql-rds":
│ 51: identifier = "cg-rds-instance-${var.cgid}"

[cloudgoat] Error while running terraform plan.
exit code: 1
stdout: None
stderr: None

this error happen
how to solve this error ??

Feature request: Support authentication when AWS environment variables are already available in the environment

Using aws-vault to authenticate, it would be useful if cloudgoat could take into account the environment variables already available to authenticate to AWS rather than having to specify a profile.

$ aws sts get-caller-identity
{
    "UserId": "XXXXX:[email protected]",
    "Account": "123456789123",
    "Arn": "arn:aws:sts::123456789123:assumed-role/XXX/[email protected]"
}
$ ./cloudgoat.py create cloud_breach_s3
The create command requires the use of the --profile flag, or a default profile defined in the config.yml file (try "config profile").

Incorrect AWS CLI Command

In the Calrission cheat sheet here, one of the commands is wrong:

aws describe-db-subnet-groups --profile Calrissian

should be

aws rds describe-db-subnet-groups --profile Calrissian

Failing Installation - Credentials.txt Empty

I start off by running the below command:

./start.sh 192.168.1.0/24

I use my public IP and terraform appears to apply the changes fine, but then I get this error:

Apply complete! Resources: 39 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate
Traceback (most recent call last):
  File "./extract_creds.py", line 10, in <module>
    encryptpass = data['modules'][0]['resources']['aws_iam_user_login_profile.administrator']['primary']['attributes']['encrypted_password']
KeyError: 'modules'
root@ubuntu:/opt/cloudgoat# 

I'm on the newest version of Ubuntu:

root@ubuntu:/opt/cloudgoat# uname -a
Linux ubuntu 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

So I really don't know what else to try other than downgrading and installing it from like a 14.04/16.04 box. Thoughts?

MalformedPolicy: Policy has invalid resource

running on osx 10.13.6

$ terraform --version
Terraform v0.11.7

I tried a few times and it keeps erroring out here:

aws_s3_bucket.cloudgoat_private: Still creating... (1m0s elapsed)

Error: Error applying plan:

1 error(s) occurred:

  • aws_s3_bucket.cloudgoat_private: 1 error(s) occurred:

  • aws_s3_bucket.cloudgoat_private: Error putting S3 policy: MalformedPolicy: Policy has invalid resource
    status code: 400, request id: 7701E4DE13BAB6A4, host id: etGPXvw+2ym61N09FF3f3CHTM2jtCXPYO/mAUygUqdlkZkybmd1FfeuQMOjeWaSAq+VbYp57jmA=

[cloudgoat] Error while running `terraform apply`.

[Background]
I was attempting to learn AWS cloud security via cloudgate. Hence I proceeded to follow the steps of installation at https://github.com/RhinoSecurityLabs/cloudgoathttps://github.com/RhinoSecurityLabs/cloudgoat.
However, after installing the requisite dependencies, and executing the command: ./cloudgoat.py create iam_privesc_by_rollback gives me error [cloudgoat] Error while running terraform apply.

[Installed software]
OS: MacOS 11.3 beta
AWS: aws-cli/2.1.38 Python/3.8.8 Darwin/20.4.0 exe/x86_64 prompt/off
Terraform: Terraform v0.15.0

[Output just before the error]
[cloudgoat] terraform plan completed with no error code.
aws_iam_user.cg-raynor: Creating...
aws_iam_policy.cg-raynor-policy: Creating...
aws_iam_user.cg-raynor: Creation complete after 2s [id=raynor-cgid3ngisyr6xx]
aws_iam_access_key.cg-raynor: Creating...
aws_iam_access_key.cg-raynor: Creation complete after 1s [id=AKIATWRLSQ74V4REKXN4]
aws_iam_policy.cg-raynor-policy: Creation complete after 4s [id=arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx]
null_resource.cg-create-iam-user-policy-version-2: Creating...
aws_iam_user_policy_attachment.cg-raynor-attachment: Creating...
null_resource.cg-create-iam-user-policy-version-4: Creating...
null_resource.cg-create-iam-user-policy-version-5: Creating...
null_resource.cg-create-iam-user-policy-version-3: Creating...
null_resource.cg-create-iam-user-policy-version-2: Provisioning with 'local-exec'...
null_resource.cg-create-iam-user-policy-version-4: Provisioning with 'local-exec'...
null_resource.cg-create-iam-user-policy-version-2 (local-exec): Executing: ["/bin/sh" "-c" "aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v2.json --no-set-as-default --profile cloudgoat --region us-east-1"]
null_resource.cg-create-iam-user-policy-version-4 (local-exec): Executing: ["/bin/sh" "-c" "aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v4.json --no-set-as-default --profile cloudgoat --region us-east-1"]
null_resource.cg-create-iam-user-policy-version-5: Provisioning with 'local-exec'...
null_resource.cg-create-iam-user-policy-version-5 (local-exec): Executing: ["/bin/sh" "-c" "aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v5.json --no-set-as-default --profile cloudgoat --region us-east-1"]
null_resource.cg-create-iam-user-policy-version-3: Provisioning with 'local-exec'...
null_resource.cg-create-iam-user-policy-version-3 (local-exec): Executing: ["/bin/sh" "-c" "aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v3.json --no-set-as-default --profile cloudgoam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v3.json --no-set-as-default --profile cloudgoat --region us-east-1"]

null_resource.cg-create-iam-user-policy-version-5 (local-exec): Unknown output type:

null_resource.cg-create-iam-user-policy-version-4 (local-exec): Unknown output type:
aws_iam_user_policy_attachment.cg-raynor-attachment: Creation complete after 2s [id=raynor-cgid3ngisyr6xx-20210417171258177400000001]

null_resource.cg-create-iam-user-policy-version-3 (local-exec): Unknown output type:

null_resource.cg-create-iam-user-policy-version-2 (local-exec): Unknown output type:

│ Error: Error running command 'aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v5.json --no-set-as-default --profile cloudgoat --region us-east-1': exit status 255. Output:
│ Unknown output type:





│ Error: Error running command 'aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v4.json --no-set-as-default --profile cloudgoat --region us-east-1': exit status 255. Output:
│ Unknown output type:





│ Error: Error running command 'aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v3.json --no-set-as-default --profile cloudgoat --region us-east-1': exit status 255. Output:
│ Unknown output type:





│ Error: Error running command 'aws iam create-policy-version --policy-arn arn:aws:iam::254568204281:policy/cg-raynor-policy-cgid3ngisyr6xx --policy-document file://../assets/policies/v2.json --no-set-as-default --profile cloudgoat --region us-east-1': exit status 255. Output:
│ Unknown output type:



[cloudgoat] Error while running terraform apply.
exit code: 1
stdout: None
stderr: None

echo "<publicKey>" >> /home/ubuntu/.ssh/authorized_keys not working in RCE_WEB_APP

Not sure of the root cause, perhaps a nodejs parsing issue, but the = sign that is always present at the end of a public key (1 or 2 = signs) works as a truncation when passed through the input, and I didn't find any way to echo it or add it to the authorized_keys file.

To solve the problem, I did the following:
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -q -N ""
cp /tmp/sshkey.pub /home/ubuntu/.ssh/authorized_keys
cat /tmp/sshkey and put it in a file on my machine and chmod 400
then we can ssh in

./cloudgoat destroy scenario -error

Hey guys,
When I run the terraform destroy command I get the following error.

This happens for all of the scenarios. Do you know this can be?

Destroy "lambda_privesc"? [y/n]: y

│ Error: Failed to parse command-line flags

│ flag provided but not defined: -force

For more help on using this command, run:
terraform destroy -help

[cloudgoat] Error while running terraform destroy.
exit code: 1
stdout: None
stderr: None

Destruction complete.
0 scenarios successfully destroyed
2 destroys failed
0 skipped

Missing file? cloud_breach_s3/terraform/iam.tf

In attempting to go through this level, I get the EC2 instance credentials, but when I try to use them, I get an AccessKeyId does not exist error. I believe this is because of a missing iam.tf file in this scenario that doesn't create the "erratic" user in IAM that is associated with the key.

Output shown below...
(env) wuchang@mashimaro % curl http://52.205.207.234/latest/meta-data/iam/security-credentials/cg-banking-WAF-Role-cgidv6re74mqg9 -H 'Host: 169.254.169.254'
{
"Code" : "Success",
"LastUpdated" : "2019-12-03T21:39:53Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASIATAIYWS4KQHVW2NM7",
"SecretAccessKey" : "FnaI8mgszLNC42k6SGOcAkWFLObdRNRhwRup4YPB",
"Token" : "IQoJb3JpZ2luX2VjEO7//////////wEaCXVzLWVhc3QtMSJIMEYCIQCA/YpRlDzIKwMPgvSwIW5suGgJp0aWjFMrd8Q/iR+yygIhAOnF4jphA6C112X6Ovbc8oUlrF0UWX3tfWftDR8hOwSYKs8CCDcQARoMMjA2NzQ3MTEzMjM3IgyFeoT/tEILGpLRkncqrAIQyglkQplk0GV/Li9EfUgSV6K9sg5YN0kyp5MmSkBnjN3I0E3UmAuaCM80Qtv7g/16e/eeyl1RULKozWXCl8f3zuRXyCtqLLFcLa5IiukcIt/tRL1ug7z19vFrZkNR2n78AiYbnA1LrpxwE/8l9B5UOHqE0yszcbkWeSipag+o8jeYtwh4SJ1psZJ5I1fzT5nmHisZOEgLAMq1+mBhL7el82j6AkNtr5CY/G35zBxm6PIt2lxDBYOH35WlkXrhZRNKBpRdTuR9gsvBNilf/LskzmY37R6OweUAK3faqPLlYZkdfkMUfuM0PgFDOQMVcjLciTOhbUkytzkoL+0bMDoPYw/OjRU+lIsLkis11IdnsScxAKIH76G9p6p6IOCL+PYsR1EmY7XgrmF4M/cwuKyb7wU6zwKYCJAtvm74mwynUw83ssPRkHnoMCS4InokKI2rw+WX0Z+UdhpCr8BJW1Pi8JFHd/QiFmktcshvX1gMO7jaYIy4L4DOi3QZ8jTJ796cmdq1ChhBDNhy0+eL9pXvLiELMjnMHZH76ONrs+fpHrsN0l8nnzV1IPtx7JxmBsGM9+tz4fc57sJY4dj6jBBcjhTNPw5bqfJvdjfzBtg092632MmIsov9mlmPhE05oOJmKPEcuNj/4gMaCfm5cRw8v1jh8EEv9Pk9HOmpVKRvj4NKadbk7zbWsSpIHtMxCFfJ/MScGe6VuCImmly/kvmJfbfwe1pwJMYHofoTwq+9mQoLxBR8tOmfPw0ed62V3OIiYhE8GktGvLwWRwRHGSM0LkR2Ey8rDP5uNAtaD6BBmvXSu4334zNL/Zvvl9YzNr7fr9cauSWq6AKEhwYsQC1Y+3lC1A==",
"Expiration" : "2019-12-04T04:15:08Z"
}%

(env) wuchang@mashimaro% aws configure --profile erratic
AWS Access Key ID [****************FFNP]: ASIATAIYWS4KQHVW2NM7
AWS Secret Access Key [****************hdxQ]: FnaI8mgszLNC42k6SGOcAkWFLObdRNRhwRup4YPB
Default region name [None]:
Default output format [None]:
(env) wuchang@mashimaro% aws s3 ls --profile erratic

An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.

Hi bro

how to solve this error ??
I want to create cloud_breach_s3

Error: Error creating S3 bucket: InvalidBucketName: The specified bucket is not valid.
│ status code: 400, request id: [ ], host id: [ ]

│ with aws_s3_bucket.cg-cardholder-data-bucket,
│ on s3.tf line 2, in resource "aws_s3_bucket" "cg-cardholder-data-bucket":
│ 2: resource "aws_s3_bucket" "cg-cardholder-data-bucket" {

[cloudgoat] Error while running terraform apply.
exit code: 1
stdout: None
stderr: None

Error while running the iam_privesc_by_rollback script

./cloudgoat.py --profile test create iam_privesc_by_rollback
Loading whitelist.txt...
A whitelist.txt file was found that contains at least one valid IP address or range.
You already have an instance of iam_privesc_by_rollback deployed. Do you want to destroy and recreate it (y) or cancel (n)? [y/n]: y

No terraform.tfstate file was found in the scenario instance's terraform directory, so "terraform destroy" will not be run.

Successfully destroyed iam_privesc_by_rollback_cgidqog4aruu76.
Scenario instance files have been moved to /home/ubuntu/cloudgoat/trash/iam_privesc_by_rollback_cgidqog4aruu76
Usage: terraform init [options] [DIR]

Initialize a new or existing Terraform working directory by creating
initial files, loading any remote state, downloading modules, etc.

This is the first command that should be run for any new or existing
Terraform configuration per machine. This sets up all the local data
necessary to run Terraform that is typically not committed to version
control.

This command is always safe to run multiple times. Though subsequent runs
may give errors, this command will never delete your configuration or
state. Even so, if you have important information, please back it up prior
to running this command, just in case.

If no arguments are given, the configuration in this working directory
is initialized.

Options:

-backend=true Configure the backend for this configuration.

-backend-config=path This can be either a path to an HCL file with key/value
assignments (same format as terraform.tfvars) or a
'key=value' format. This is merged with what is in the
configuration file. This can be specified multiple
times. The backend type must be in the configuration
itself.

-force-copy Suppress prompts about copying state data. This is
equivalent to providing a "yes" to all confirmation
prompts.

-from-module=SOURCE Copy the contents of the given module into the target
directory before initialization.

-get=true Download any modules for this configuration.

-get-plugins=true Download any missing plugins for this configuration.

-input=true Ask for input if necessary. If false, will error if
input was required.

-lock=true Lock the state file when locking is supported.

-lock-timeout=0s Duration to retry a state lock.

-no-color If specified, output won't contain any color.

-plugin-dir Directory containing plugin binaries. This overrides all
default search paths for plugins, and prevents the
automatic installation of plugins. This flag can be used
multiple times.

-reconfigure Reconfigure the backend, ignoring any saved
configuration.

-upgrade=false If installing modules (-get) or plugins (-get-plugins),
ignore previously-downloaded objects and install the
latest version allowed within configured constraints.

-verify-plugins=true Verify the authenticity and integrity of automatically
downloaded plugins.

[cloudgoat] Error while running terraform init.
exit code: 1
stdout: None
stderr: None

Terraform version = v0.12.23

in Ec2_ssrf not able to connect to http://ecipinstance

Page Unable to connect

Firefox can’t establish a connection to the server at ec2-3-XXXXXXXX.compute-1.amazonaws.com.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Missing security group in EC2 instance

Hi guys!

I see that after deploying the Cloadgoat, the EC2 instance has only "cloudgoat_ec2_sg" security group assigned, what allows only for inbound SSH traffic. I guess it should also be assigned to "cloudgoat_lb_sg" group to allow for HTTP traffic by default.

P.S.
But also have to say that (at least so far) Cloudgoat works like a charm and I really enjoy it - awesome job guys!

ec2_ssrf error on default page

It looks like the default page of the EC2 instance results in the following error:

TypeError: URL must be a string, not undefined
    at new Needle (/node_modules/needle/lib/needle.js:172:11)
    at Function.module.exports.(anonymous function) [as get] (/node_modules/needle/lib/needle.js:818:12)
    at /home/ubuntu/app/ssrf-demo-app.js:32:12
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at next (/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at /node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/node_modules/express/lib/router/index.js:335:12)
    at next (/node_modules/express/lib/router/index.js:275:10)

The following URL does however work, just difficult to get to this step when the main page is broken.

http://<ec2 url>/?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/

Same issue in ec2_ssrf scenario as in rce_web_app scenario

nodejs doesn't not start automatically without adding

    echo '* libraries/restart-without-asking boolean true' | debconf-set-selections

after
user_data = <<-EOF
#!/bin/bash

in ec2.tf file.

So basically you cannot access the web app and you cannot perform the ssrf.
Please fix because having to troubleshoot something that was supposed to work has already spoiled two scenarios for me, and possibly for other people.

Thanks

Insufficient ELB configuration

Hi,

I've experienced an issue where ELB was put to the AZ us-west-2a whereas EC2 into us-west-2b. Because of that, ELB kept reporting that Instance is in the ec2 availability zone for which load balancer is not configured.

After couple of Health checks passed from ELB, it's status started switching among:

  • "Instance has not passed the configured HealthyThreshold number of health checks consecutively"
  • "Instance has failed at least the UnhealthyThreshold number of health checks consecutively"

As a fix for that I used below two commands:

aws --region us-west-2 elb enable-availability-zones-for-load-balancer --load-balancer-name cloudgoat-elb --availability-zones us-west-2a
aws --region us-west-2 elb enable-availability-zones-for-load-balancer --load-balancer-name cloudgoat-elb --availability-zones us-west-2b

Also, I think that this particular information should be added to repo's README, because people might easily resignate due to inability to reach out for the web server:

The EC2 instance is only given inbound access over SSH on purpose, as part of CloudGoat is figuring out a way to open that port on that instance, so you can access the web server.

unintended vulnerability in Scenario: ecs_efs_attack

I found some unintended way to get the flag of the "ecs_efs_attack".
But I think it must be patched so I write the issue about this vulnerability.

After command $ ./cloudgoat.py create ecs_efs_attack , I can access to the EC2 instance by using the given private key.
In that situation, I tried to mount EFS data. When I tried to mount, some error occur but I can solve that error by install nfs package.
$ sudo apt-get install nfs-common
After that, I can mount the data and I can see the flag.

./cloudgoat create results in NoCredentialProviders

I run the following:

./cloudgoat.py create iam_privesc_by_rollback --profile cloudgoat

This is the error that results:

data.local_file.v5: Refreshing state...
data.local_file.v2: Refreshing state...
data.local_file.v4: Refreshing state...
data.local_file.v1: Refreshing state...
data.local_file.v3: Refreshing state...

Error: error validating provider credentials: error calling sts:GetCallerIdentity: NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors

  on provider.tf line 1, in provider "aws":
   1: provider "aws" {

Looking into the terraform script variables.tf looks like the following:

#Required: AWS Profile
variable "profile" {

}
#Required: AWS Region
variable "region" {
  default = "us-east-1"
}
#Required: CGID Variable for unique naming
variable "cgid" {

}
#Required: User's Public IP Address(es)
variable "cg_whitelist" {
  type = list

}

I am not familiar enough with Terraform and uncertain if I should see the variables correctly set here.

I did setup in my ~/.aws/credentials a profile and I did also run

./cloudgoat.py config profile

scenario iam_privesc_by_rollback / set-default-policy-version issue

After executing a set-default-policy-version API call against IAM, in order to change the default policy version from v1 to v2 and complete the scenario, I do not see any changes.

The response I get from the CLI is aws-cli/1.16.19 Python/3.7.3 Darwin/18.6.0 botocore/1.12.9 and yet, when I list the policy versions, I still see v1 as the default.

aws> iam list-policy-versions --policy-arn "arn:aws:iam::xxxxxxxxxx:policy/cg-raynor-policy" --profile goat1

{
    "Versions": [
        {
            "VersionId": "v5",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v4",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v3",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v2",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v1",
            "IsDefaultVersion": true,
            "CreateDate": "2019-07-03T20:12:34Z"
        }
    ]
}

aws> iam set-default-policy-version --policy-arn "arn:aws:iam::xxxxxxxxxx:policy/cg-raynor-policy" --version v2

aws-cli/1.16.19 Python/3.7.3 Darwin/18.6.0 botocore/1.12.9

Re-listing the policy versions still indicates that the default is v1, and not v2 as I requested it be.
aws> iam list-policy-versions --policy-arn "arn:aws:iam::115754076533:policy/cg-raynor-policy" --profile goat1

{
    "Versions": [
        {
            "VersionId": "v5",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v4",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v3",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v2",
            "IsDefaultVersion": false,
            "CreateDate": "2019-07-03T20:12:36Z"
        },
        {
            "VersionId": "v1",
            "IsDefaultVersion": true,
            "CreateDate": "2019-07-03T20:12:34Z"
        }
    ]
}

Checked CloudTrail logs for all actions by the public key of this user, and there are not calls logged outside of List and Get API calls.

Perhaps this functionality has been removed and this scenario is no longer applicable?

first run of ./start.sh fails on credfile.write("Administrator Password: " + clearpass + '\n')

I'm running on osx 10.13.6
with brew installed gpg

$ gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.2
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/kbroughton/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Here is the error:

gpg: encrypted with 2048-bit RSA key, ID 2F5443323CA9803B, created 2018-08-01
"CloudGoat"
Traceback (most recent call last):
File "./extract_creds.py", line 14, in
credfile.write("Administrator Password: " + clearpass + '\n')
TypeError: must be str, not bytes

EC2 SSRF Scenario - I/O Timeout

Hello there, first of all kudos for such an amazing tool!
I have been playing around with most of the challenges so far but I have noticed that there might be an issue with the EC2 SSRF scenario (I have also heard someone else having the exact same problem). It seems to be related to the ZIP file needed for the lambda function deployment.
I am including a few details of my software version(s) if that helps

OS: Kali Linux
AWS CLI: aws-cli/1.18.80 Python/3.7.6 Linux/5.4.0-kali3-amd64 botocore/1.17.3
Terraform: v0.12.26

./cloudgoat.py create ec2_ssrf
[...SNIP...]
aws_instance.cg-ubuntu-ec2: Provisioning with 'file'...
[...SNIP...]
Error: timeout - last error: dial tcp 18.206.93.239:22: i/o timeout
[...SNIP...]
[cloudgoat] Error while running terraform apply.
exit code: 1
stdout: None
stderr: None

Unable to run "./cloudgoat.py config profile"

Hello I cloned the repository, I already installed all the requirements, but when running the configuration part I'm taking the following error:

root@kali:~/CloudGoat# ./cloudgoat.py config profile
Traceback (most recent call last):
File "./cloudgoat.py", line 112, in
from core.python.commands import CloudGoat
ModuleNotFoundError: No module named 'core.python'

image

Can you help me?

enhancement: address multi-tenancy issues with session ids for generated resources

I'm showing cloudgoat to some colleagues and we are using a company AWS org.
The multitenancy desired is:
shared AWS org
separate cloudgoat envs per user

This causes some problems:

cloudgoat_key is created once by the first user and others don't have access to the private key

  • workaround: choose a distinct region for the second user to upload a key to
  • fix: have the cloudgoat_key read from ~/.ssh/rsa and create a session id
    cloudgoat_key-12345

administrator user is generated by the first user. Subsequent users don't have the pwd.

  • workaround: share the admin user pwd
  • fix: generate a session suffix for administrator-12345 at terraform plan time.

Same issue for joe and bob users.

rce_web_app scenario 502 bad gateway

After some troubleshooting and creating and destroying multiple times, I found out that node.js on the ec2 instance was not started. Result: 502 bad gateway in browser when opening the elb url.
I connected via ssh by downloading cloudgoat private key from the related keystore bucket, I went to the home folder, unzipped app.zip, and run: node .
Not sure of the root cause.

Update cheat_sheet_kerrigan.md

Changes required:

  • Line-13: Write created key pair pwned to private key file pwned.pem and set permissions
  • Line-19: Set --instance-type t2.micro
  • Line-20: SSH to created EC2 instance

Feature Request: Minimum AWS Policy Template

Could you provide a bare minimum IAM security policy file that can be imported into an instance and assigned to the user CloudGoat is running under? I'd rather not create a full administrator user to run this, nor do most of our corporate sandbox instances allow for such a thing anyways. If you know what specific roles/permissions are needed to run the scenarios, that would make deployment much easier. As far as I can see, the only guidance is to grant the ability to create/destroy objects, but that isn't that specific.

Thanks! We are looking forward to using this.

Terraform init state checks for plugins

Hi,
How can i stop terraform from checking
Checking for available provider plugins...
Downloading plugin for provider "AWS" (hashicorp/aws)
and making it use only the existing plugins

Unable to Clone CloudGoat

I am trying to install the Rhino Security Labs CloudGoat on my AWS Ubuntu 18.04 LTS Free-tier EC2 instance. I followed the directions for setting up an admin user and configuring the AWS CLI and also set up terraform v0.12 per the directions. I also configured my instance's security group to allow All traffic.

However, when I run the git clone command I get "Permission denied" error. See below for full output:

sudo git clone [email protected]:RhinoSecurityLabs/cloudgoat.git ./CloudGoat
Cloning into './CloudGoat'...
The authenticity of host 'github.com ()' can't be established.
RSA key fingerprint is SHA256:.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,' (RSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists

Do I need to associate an SSH key on GitHub to my account and if so how do I do that? I'm not sure what else to try at this point. Thanks.

Not able to access any public ip/url

Everything was working good (rce_web_app) but when I got the public IP and tried to access the following error I got "This site can’t be reached"
Is there any misconfiguration coz I did everything accurately? 😅
Can some1 help me out???

iam_privesc_by_rollback issue

whenever i am executing below command i am getting the error like below any solutions thanx in advance.. This i happening with in all challenges.even i tried on normal user and root level user as well still getting this error.
Or is there anything to setup before starting this challenge

Error: No valid credential sources found for AWS Provider.
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider

on provider.tf line 1, in provider "aws":
1: provider "aws" {

[cloudgoat] Error while running terraform plan.
exit code: 1
stdout: None
stderr: None

Error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.

Not able to do any of these challenges because of the AWS provider error, using Kali...

Currently trying the iam_privesc_by_rollback...

I've set/used environment variables for the AWS credentials; tried to use the credentials file; I've verified the access keys work; but still getting the error:

│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.

│ Error: NoCredentialProviders: no valid providers in chain. Deprecated.
│ For verbose messaging see aws.Config.CredentialsChainVerboseErrors


│ with provider["registry.terraform.io/hashicorp/aws"],
│ on provider.tf line 1, in provider "aws":
│ 1: provider "aws" {

[cloudgoat] Error while running terraform plan.
exit code: 1
stdout: None
stderr: None

└─$ cat credentials
[cloudgoat]
aws_access_key_id = 123123123132123132
aws_secret_access_key =
region = us-east-1
role_arn = arn:aws:iam::123123123123:user/cloudgoat
source_profile = default
[default]
aws_access_key_id = 123123123132123132
aws_secret_access_key =

I even tried to modify the provider.tf file for the specific scenario:
└─$ cat /opt/cloudgoat/scenarios/iam_privesc_by_rollback/terraform/provider.tf 254 ⨯
provider "aws" {
profile = "cloudgoat"
region = "${var.region}"
}

Not sure what else I can do to get this to work.....

Terrform error

Hi there,

I am getting the following error:

Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.

Is there a Terraform config file I need to adjust?

Thanks!

Error while create many scenarios.

Hello please help me. I can't create this scenarios. When I create that show the error.

$ ./cloudgoat.py create [SCENARIO_NAME] --profile [PROFILE]

  • cloud_breach_s3
  • ec2_ssrf
  • rce_web_app

This is warning for 3 above.

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

Warning: Interpolation-only expressions are deprecated

on ec2.tf line 21, in resource "aws_iam_role" "cg-banking-WAF-Role":
21: Stack = "${var.stack-name}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

(and 58 more similar warnings elsewhere)

And this is error for 3 above.

Error: timeout - last error: dial tcp 52.xxx.xxx.xxx:22: i/o timeout

[cloudgoat] Error while running `terraform apply`.
exit code: 1
stdout: None
stderr: None

  • ecs_efs_attack

This is error for ecs_efs_attack scenario.

Error: Failed getting task definition ClientException: Unable to describe task definition. "webapp"

[cloudgoat] Error while running `terraform plan`.
exit code: 1
stdout: None
stderr: None

AWS CLI : 2.1.6
Terraform : v0.13.5

Error while running the ec2 terraform script.

./cloudgoat.py create rce_web_app
Using default profile "cloudgoat" from config.yml...
Loading whitelist.txt...
A whitelist.txt file was found that contains at least one valid IP address or range.

Now running rce_web_app's start.sh...
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Error parsing /Users/<****>/cloudgoat/rce_web_app_cgirwmfal/terraform/ec2.tf: At 67:21: Unknown token: 67:21 IDENT var.cg_whitelist

[cloudgoat] Error while running terraform init.
exit code: 1
stdout: None
stderr: None

Map scenarios to ATT&CK cloud

Opening for tracking - it would be great to have a mapping of each scenario to ATT&CK cloud, to

  1. Understand the overall coverage of CloudGoat
  2. For a specific scenario, have a high-level overview of the attack techniques that are used

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.