Giter Club home page Giter Club logo

sadcloud's Introduction

Sadcloud

sadcloud is a tool for spinning up insecure AWS infrastructure with Terraform.

It supports approx. 84 misconfigurations across 22 AWS Services. The inital set of misconfigurations were drawn from ScoutSuite, NCCGroup's Multi-cloud auditing tool.

sadcloud was created to easily allow security researchers to misconfigure AWS for training purposes, or to use to asses AWS security tools - including built-ins and third-party.

Security Note - must read

This tool spins up intentionally vulnerable AWS configured resources. Please do not run it in your production cloud, or anywhere that is meant to be secure. Consider standing up a new AWS account in which to run this tool. As this tool spins up cloud resources, it will result in charges to your AWS account. Efforts have been made to minimize the costs incurred, but NCC Group and this tool's maintainers are not responsible for any charges or security issues that may result from usage of this tool. Make sure to tear down all - Terraform resources when not using them!

Costs

A 24 hour test run of sadcloud generated a bill of approximately $10. The majority of that cost is from the Redshift module (25c/hour = $6/day) and EKS module (10c/hour = $2.40/day).

Sample Audits using sadcloud

We periodically use sadcloud to demonstrate various AWS and terraform auditing tooling. All audits are against the full corpus of possible misconfigurations.

Tool Sample Report
ScoutSuite https://ramimac.github.io/sadcloud-reports/scoutsuite-reports/scoutsuite-report_03_2020/aws.html
prowler https://ramimac.github.io/sadcloud-reports/prowler-report/report.html
cloudmapper https://ramimac.github.io/sadcloud-reports/cloudmapper-reports/web_03_2020/account-data/report.html
cloudsploit https://ramimac.github.io/sadcloud-reports/cloudsploit-scans-reports/scans.04_2020.txt
tfsec https://ramimac.github.io/sadcloud-reports/tfsec/tfsec.03_27_2020.txt

Setup

Required software: Terraform

Ensure that your SSH keys are written to data/ssh_keys/terraform_rsa{,.pub}.

ssh-keygen -t rsa -b 4096 -f data/ssh_keys/terraform_rsa
  1. git clone https://github.com/nccgroup/sadcloud.git
  2. cd sadcloud/sadcloud

Environment Setup

Set up the AWS provider (see the "Using Providers Instead of Environment Variables" section below for instructions on avoiding this step):

export AWS_ACCESS_KEY_ID="accesskey"
export AWS_SECRET_ACCESS_KEY="secretkey"
export AWS_DEFAULT_REGION="us-east-1"

Get Terraform ready:

terraform init

Configure sadcloud

Configure sadcloud with your desired misconfigurations:

  • To enable all findings (... excluding those that are in conflict with other findings):

    1. Uncomment all modules in sadcloud/main.tf
    2. Either edit the all_findings flag in sadcloud/terraform.tfvars to true, or call terraform apply with the flag --var="all_findings=true"
  • To enable all findings in one or more services:

    1. Uncomment the relevant service(s) in sadcloud/main.tf
    2. For a single service, either edit the relevant all_{service}_findings flag in sadcloud/terraform.tfvars to true, or call terraform apply with the flag --var="all_{service}_findings=true"
    3. For multiple services, either edit the all_findings flag in sadcloud/terraform.tfvars to true, or call terraform apply with the flag --var="all_findings=true" NOTE: There is currently a Terraform bug with the Cloudformation service. To generate Cloudformation findings, you will need to run Terraform apply twice
  • To enable specific findings granularly:

    1. Uncomment the relevant service in sadcloud/main.tf
    2. Edit the variables of interest directly in sadcloud/main.tf, flipping them to true where desired.
    3. For services that require a VPC, make sure you set needs_network to true in sadcloud/main.tf

Note: All misconfigurations in sadcloud are disabled by default. All services are disabled by default to prevent spinning up unnecessary resources. Setting the variable for a misconfiguration to true always results in misconfiguration. Running all_findings can take 10-15 minutes.

Check it:

terraform plan

Deploy it:

terraform apply

Tear it down:

terraform destroy

Note: terraform apply will spin up services in AWS. These cost money. Don't forget to terraform destroy after you're done. Make sure you terraform plan before running all_findings so you understand what you're getting yourself into!

Extras

Using Providers Instead of Environment Variables

It's possible to set up an AWS provider so you won't have to set environment variables each time.

Create a file called sadcloud/providers.tf with the following contents:

provider "aws" {
  access_key = "YOUR_AWS_ACCESS_KEY"
  secret_key = "YOUR_AWS_SECRET_KEY"
  region     = "us-east-1"
}

sadcloud's People

Contributors

0xflotus avatar 0xjdow avatar danielperez660 avatar jdow-ncc avatar ramimac 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

sadcloud's Issues

Expand ScoutSuite AWS coverage

Currently, the following findings are not supported for supported services

  • s3

    • delete actions authorized to all principals
    • get actions authorized to all principals
    • list actions authorized to all principals
    • manage actions authorized to all principals
    • put actions authorized to all principals
    • all actions authorized to all principals
    • bucket world-listable
    • bucket world-listable (anonymous)
    • bucket world-writable
    • bucket world-writable (anonymous)
    • bucket permissions world-readable
    • bucket permissions world-readable (anonymous)
    • bucket permissions world-writable
    • bucket permissions world-writable (anonymous)
  • iam

    • managed policy findings
    • root account findings
    • unused role for ec2

redshift module fails

AWS seems to have sunset the instance type on line 24 of the redshift module.

│ Error: creating Redshift Cluster (sadcloud): NumberOfNodesQuotaExceeded: You do not have access to node type dw2.large. Choose another node type
│ status code: 400, request id: 0fc88c15-9a69-4cf6-8ba9-ca23ef77456a

│ with module.redshift.aws_redshift_cluster.main[0],
│ on ../modules/aws/redshift/main.tf line 24, in resource "aws_redshift_cluster" "main":
│ 24: resource "aws_redshift_cluster" "main" {

Terraform Version, subnet_ids Not Recognized

I'm unable to get the sadcloud scripts to deploy following an error in the Cloud Trail module.

(aws) sadcloud (master) $ terraform -version
Terraform v0.15.1
on darwin_amd64
(aws) sadcloud (master) $ git log -1
commit b3de799d960c51503558af749ed41f44efd7d359 (HEAD -> master, origin/master, origin/HEAD)
Author: Rami McCarthy <[email protected]>
Date:   Tue Jun 30 16:14:33 2020 -0400

    Update README.md
(aws) sadcloud (master) $ terraform apply

... some time later:

│ Error: Error launching source instance: VPCResourceNotSpecified: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.
│ 	status code: 400, request id: 2f47199d-6ed6-42ce-99e0-aa7982a5df6e
│
│   with module.ec2.aws_instance.main[0],
│   on ../modules/aws/ec2/main.tf line 18, in resource "aws_instance" "main":
│   18: resource "aws_instance" "main" {

Here is the context of the main.tf file:

(aws) sadcloud (master) $ cat -n ../modules/aws/ec2/main.tf | sed -n 17,23p
    17
    18	resource "aws_instance" "main" {
    19	  ami           = data.aws_ami.ubuntu.id
    20	  instance_type = var.disallowed_instance_type ? "t2.micro" : "t2.small"
    21	  subnet_id     = var.main_subnet_id
    22	  count         = var.disallowed_instance_type || var.instance_with_user_data_secrets || var.instance_with_public_ip ? 1 : 0
    23

I'm new to Terraform, and I'm not sure how to respond to this error. When I tried to build I get an error about the use of list() as deprecated, so I converted them to tolist() per the new API use. I've attached my diff, though it doesn't seem to be related to anything for subnets or network IDs. Any ideas? Thanks!

Add support for CloudFront

cloudfront is necessary for the following checks:

  1. Cloudmapper - CLOUDFRONT_MINIMUM_PROTOCOL_SUPPORT
  2. Prowler - 7.14 [extra714] Check if CloudFront distributions have logging enabled (Not Scored) (Not part of CIS benchmark)
  3. Prowler - 7.32 [extra732] Check if Geo restrictions are enabled in CloudFront distributions (Not Scored) (Not part of CIS benchmark)
  4. Prowler - 7.38 [extra738] Check if CloudFront distributions are set to HTTPS (Not Scored) (Not part of CIS benchmark)

Add auto self-destruction capability

It's entirely possible that someone might create these resources and forget to destroy them (or not know how)

It would be a good idea to provision a self-destruct mechanism by default, with a Scheduled Event to trigger it after X number of days. This could be something as simple as an hashicorp/terraform container in ECR with sufficient permission to destroy everything.

That would require moving the terraform backend to S3 - which opens up a whole bunch of new opportunities for vulnerabilities!

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.