├── terraform ├── environment │ ├── test │ │ ├── versions.tf │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── README.md │ │ └── variables.tf │ └── vpc │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf ├── .template │ ├── aws │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── versions.tf │ │ └── variables.tf │ ├── gcp │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── versions.tf │ │ └── variables.tf │ ├── github │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── versions.tf │ │ └── variables.tf │ └── azure │ │ ├── outputs.tf │ │ ├── main.tf │ │ ├── versions.tf │ │ └── variables.tf ├── backdoored_entities │ ├── ec2_ami │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ ├── variables.tf │ │ └── README.md │ ├── ebs_volume │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── iam_role │ │ ├── external_privesc │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ ├── main.tf │ │ │ └── README.md │ │ └── external_administrator │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── main.tf │ │ │ ├── variables.tf │ │ │ └── README.md │ └── iam_user │ │ ├── privesc_user │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ │ └── administrative_user │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ ├── variables.tf │ │ └── README.md ├── exposed_services │ ├── aws_sqs │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_ec2_ami │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_efs │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_sns_topic │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── aws_glacier │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── aws_glue │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── aws_iam_role │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_kms_key │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── google_storage_bucket │ │ ├── .DS_Store │ │ ├── public_get │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── main.tf │ │ │ └── variables.tf │ │ ├── public_get_list │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── main.tf │ │ │ └── variables.tf │ │ └── public_object │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ ├── aws_backup_vault │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_ec2_ebs │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ ├── aws_opensearch │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── subnets.tf │ │ ├── variables.tf │ │ └── main.tf │ ├── aws_s3 │ │ ├── public_write │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ ├── main.tf │ │ │ └── README.md │ │ ├── public_get │ │ │ ├── versions.tf │ │ │ ├── outputs.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ │ ├── public_list_get │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ │ └── public_object_acl │ │ │ ├── versions.tf │ │ │ ├── outputs.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ ├── github_repository │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── aws_secrets_manager │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_lambda │ │ ├── layer │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ ├── main.tf │ │ │ └── README.md │ │ ├── invoke │ │ │ ├── outputs.tf │ │ │ ├── index.py │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ ├── main.tf │ │ │ └── README.md │ │ └── endpoint │ │ │ ├── outputs.tf │ │ │ ├── index.py │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ ├── main.tf │ │ │ └── README.md │ └── aws_ecr │ │ ├── aws_ecr_public │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ │ └── aws_ecr_public_gallery │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── main.tf │ │ └── variables.tf ├── exposed_assets │ ├── aws_ec2 │ │ ├── ssh │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ │ ├── jenkins │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ └── variables.tf │ │ └── opensearch │ │ │ ├── versions.tf │ │ │ ├── outputs.tf │ │ │ ├── subnets.tf │ │ │ └── variables.tf │ ├── aws_ec2_alb │ │ ├── jenkins │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ └── variables.tf │ │ └── opensearch │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ └── variables.tf │ ├── aws_eks │ │ └── cluster │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ ├── aws_rds │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── subnets.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ ├── aws_ec2_clb │ │ └── opensearch │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── subnets.tf │ │ │ └── variables.tf │ ├── aws_redshift │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── subnets.tf │ │ ├── variables.tf │ │ └── main.tf │ └── aws_lightsail │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf ├── misconfigurations │ ├── aws_iam_role │ │ └── oidc │ │ │ ├── outputs.tf │ │ │ ├── versions.tf │ │ │ ├── variables.tf │ │ │ └── main.tf │ └── takeovers │ │ ├── aws_s3_takeover │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ ├── main.tf │ │ └── README.md │ │ ├── aws_eip_takeover │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ ├── variables.tf │ │ └── README.md │ │ ├── aws_second_order_takeover │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ │ ├── aws_thirdparty_takeover │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ ├── variables.tf │ │ └── README.md │ │ ├── aws_asg_takeover_rce │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ │ └── aws_delegation_takeover │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf └── README.md ├── .assets ├── cli.png ├── logo.png └── commotion.png ├── main.go ├── .gitignore ├── go.mod ├── .github └── workflows │ └── release.yml └── config └── config.yml /terraform/environment/test/versions.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /terraform/environment/test/main.tf: -------------------------------------------------------------------------------- 1 | # Nothing to see here 2 | -------------------------------------------------------------------------------- /terraform/.template/aws/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | -------------------------------------------------------------------------------- /.assets/cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SecurityRunners/CloudCommotion/HEAD/.assets/cli.png -------------------------------------------------------------------------------- /.assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SecurityRunners/CloudCommotion/HEAD/.assets/logo.png -------------------------------------------------------------------------------- /terraform/environment/test/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "Hello, World!" 3 | } 4 | -------------------------------------------------------------------------------- /.assets/commotion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SecurityRunners/CloudCommotion/HEAD/.assets/commotion.png -------------------------------------------------------------------------------- /terraform/environment/test/README.md: -------------------------------------------------------------------------------- 1 | # Hello World 2 | 3 | This is just a test module to help with development. 4 | -------------------------------------------------------------------------------- /terraform/.template/gcp/main.tf: -------------------------------------------------------------------------------- 1 | provider "google" { 2 | project = var.project_name 3 | region = var.region 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/github/main.tf: -------------------------------------------------------------------------------- 1 | provider "github" { 2 | organization = var.organization_name 3 | token = var.github_token 4 | } 5 | -------------------------------------------------------------------------------- /terraform/environment/vpc/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = module.vpc.vpc_id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/SecurityRunners/CloudCommotion/pkg/cmd" 5 | ) 6 | 7 | func main() { 8 | cmd.Execute() 9 | } 10 | -------------------------------------------------------------------------------- /terraform/.template/aws/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_something_radom.name.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/azure/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = azurerm_something_radom.name.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/gcp/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = google_something_radom.name.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ec2_ami/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_ami.xacct_ami.id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sqs/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_sqs_queue.public_queue.arn 3 | description = "Exposed SQS queue" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/github/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = github_repository.example.full_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/ssh/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_instance.ssh.public_ip 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ami/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_ami.public_ami.id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_efs/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_efs_file_system.fs.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sns_topic/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_sns_topic.topic.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/jenkins/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_lb.jenkins.dns_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_eks/cluster/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_something_radom.name.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glacier/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_glacier_vault.archive.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glue/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "All Glue Assets in the Account" 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_iam_role/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_role.public_role.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_kms_key/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_kms_key.public_key.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SecurityRunners/CloudCommotion/HEAD/terraform/exposed_services/google_storage_bucket/.DS_Store -------------------------------------------------------------------------------- /terraform/misconfigurations/aws_iam_role/oidc/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_role.role.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_s3_takeover/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = var.domain_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/opensearch/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_lb.opensearch.dns_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_db_instance.rds_instance.endpoint 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_backup_vault/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_backup_vault.vault.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ebs/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_ebs_snapshot.public_snapshot.id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_eip_takeover/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = var.domain_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CloudCommotion 2 | 3 | # Terraform 4 | .terraform/ 5 | *.tfstate 6 | *.tfstate.backup 7 | *.tfvars 8 | .terraform.lock.hcl 9 | *.zip 10 | .terraform.tfstate.lock.info 11 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ebs_volume/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_ebs_snapshot.public_snapshot.id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_clb/opensearch/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_elb.opensearch.dns_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_redshift/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_redshift_cluster.cluster.endpoint 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_opensearch/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_opensearch_domain.domain.endpoint 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_write/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_s3_bucket.public_bucket.id 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/github_repository/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = github_repository.repo.html_url 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_second_order_takeover/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = var.domain_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_thirdparty_takeover/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = var.domain_name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_privesc/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_role.exposed_asset.arn 3 | description = "Backdoored IAM role ARN" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_secrets_manager/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_secretsmanager_secret.secret.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/azure/main.tf: -------------------------------------------------------------------------------- 1 | provider "azurerm" { 2 | features {} 3 | } 4 | 5 | resource "azurerm_resource_group" "rg" { 6 | name = var.resource_name 7 | location = var.region 8 | } 9 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/jenkins/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "http://${aws_instance.jenkins.public_ip}:8080" 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/layer/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_lambda_layer_version.lambda_layer.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_asg_takeover_rce/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_autoscaling_group.asg.arn 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_administrator/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_role.exposed_asset.arn 3 | description = "Backdoored IAM role ARN" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/privesc_user/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_user.exposed_asset.arn 3 | description = "Name of the administrator IAM user" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_lambda_function.public_lambda.arn 3 | description = "Exposed Lambda invoke function ARN" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_delegation_takeover/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_route53_zone.sub_zone.name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/aws/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/administrative_user/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_iam_user.admin_user.arn 3 | description = "Name of the administrator IAM user" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_ecr_repository.public_repo.repository_url 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_lightsail/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "http://${aws_lightsail_instance.lightsail.public_ip_address}" 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_lambda_function_url.lambda_function_url.function_url 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_efs/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sqs/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = google_storage_bucket.public_all_objects.name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ec2_ami/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/ssh/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_lightsail/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_redshift/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ami/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glacier/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glue/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_iam_role/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_kms_key/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/index.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def lambda_handler(event, context): 4 | return { 5 | 'statusCode': 200, 6 | 'body': os.environ.get('SENSITIVE_CONTENT') 7 | } 8 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/index.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def lambda_handler(event, context): 4 | return { 5 | 'statusCode': 200, 6 | 'body': os.environ.get('SENSITIVE_CONTENT') 7 | } 8 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get_list/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = google_storage_bucket.public_all_objects.name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_object/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = google_storage_bucket.public_single_object.name 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/.template/gcp/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | google = { 5 | source = "hashicorp/google" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/environment/vpc/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/jenkins/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/opensearch/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/jenkins/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_eks/cluster/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_backup_vault/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_opensearch/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_get/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_list_get/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = aws_s3_bucket.public_bucket.arn 3 | description = "Name of the public bucket that was created for the exercise" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sns_topic/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/.template/azure/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | google = { 5 | source = "hashicorp/azurerm" 6 | version = ">= 3.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/opensearch/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "curl -X GET https://${aws_instance.opensearch.public_ip}:9200 -ku admin:admin" 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/opensearch/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_clb/opensearch/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_list_get/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_write/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_secrets_manager/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/aws_iam_role/oidc/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/.template/github/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | github = { 5 | source = "integrations/github" 6 | version = ">= 5.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/privesc_user/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ebs/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_object_acl/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_eip_takeover/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_s3_takeover/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/ebs_volume/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_privesc/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/administrative_user/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public_gallery/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_administrator/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_delegation_takeover/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_thirdparty_takeover/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_get/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "${aws_s3_bucket.public_bucket.arn}/${aws_s3_object.object.key}" 3 | description = "ARN of the public file that was created for the exercise" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/github_repository/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | github = { 5 | source = "integrations/github" 6 | version = ">= 5.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_object_acl/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = "${aws_s3_bucket.public_bucket.arn}/${aws_s3_object.object.key}" 3 | description = "ARN of the public file that was created for the exercise" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | google = { 5 | source = "hashicorp/google" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_object/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | google = { 5 | source = "hashicorp/google" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public_gallery/outputs.tf: -------------------------------------------------------------------------------- 1 | output "exposed_asset" { 2 | value = replace(aws_ecrpublic_repository.ecrpublic.repository_uri, "public.ecr.aws", "https://gallery.ecr.aws") 3 | description = "Name of the exposed asset" 4 | } 5 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get_list/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | google = { 5 | source = "hashicorp/google" 6 | version = ">= 4.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public_gallery/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ecrpublic_repository" "ecrpublic" { 6 | repository_name = var.resource_name 7 | 8 | catalog_data { 9 | description = var.sensitive_content 10 | } 11 | 12 | tags = var.tags 13 | } 14 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/layer/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | 9 | null = { 10 | source = "hashicorp/null" 11 | version = ">= 3.2" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_thirdparty_takeover/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_route53_record" "thirdparty_alias" { 6 | zone_id = var.hosted_zone_id 7 | name = var.domain_name 8 | type = "CNAME" 9 | ttl = "300" 10 | records = [var.thirdparty_alias] 11 | } 12 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_asg_takeover_rce/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | 9 | null = { 10 | source = "hashicorp/null" 11 | version = ">= 3.2" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_second_order_takeover/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = ">= 4.0" 7 | } 8 | 9 | null = { 10 | source = "hashicorp/null" 11 | version = ">= 3.2" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_lightsail/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_lightsail_instance" "lightsail" { 6 | name = var.resource_name 7 | availability_zone = "${var.region}a" 8 | blueprint_id = "amazon_linux_2" 9 | bundle_id = "nano_1_0" 10 | user_data = "sudo yum install -y httpd && sudo systemctl start httpd && sudo systemctl enable httpd && echo '

${var.sensitive_content}

' | sudo tee /var/www/html/index.html" 11 | } 12 | -------------------------------------------------------------------------------- /terraform/environment/vpc/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | module "vpc" { 6 | source = "terraform-aws-modules/vpc/aws" 7 | 8 | name = var.resource_name 9 | cidr = "10.0.0.0/16" 10 | 11 | azs = ["${var.region}a", "${var.region}b", "${var.region}c"] 12 | private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] 13 | public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] 14 | 15 | enable_nat_gateway = true 16 | 17 | tags = var.tags 18 | } 19 | -------------------------------------------------------------------------------- /terraform/exposed_services/github_repository/main.tf: -------------------------------------------------------------------------------- 1 | provider "github" { 2 | owner = var.organization_name 3 | token = var.github_token 4 | } 5 | 6 | resource "github_repository" "repo" { 7 | name = var.resource_name 8 | description = "Created through cloudcommotion terraform" 9 | visibility = "public" 10 | } 11 | 12 | resource "github_repository_file" "flag" { 13 | repository = github_repository.repo.name 14 | file = var.file_name 15 | content = var.sensitive_content 16 | } 17 | -------------------------------------------------------------------------------- /terraform/README.md: -------------------------------------------------------------------------------- 1 | # Terraform Modules 2 | 3 | This directory contains the terraform modules for commotion infrastructure in the following directory structure. 4 | 5 | - Backdoored Entities 6 | - Contains terraform modules for potential backdoors within your environment that could be created 7 | - Exposed Assets 8 | - Contains network related assets that can be exposed 9 | - Exposed Services 10 | - Contains cloud services that can be publicly exposed 11 | - Misconfigurations 12 | - Contains misconfigurations that can occur within your environment 13 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glue/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_caller_identity" "current" {} 6 | 7 | data "aws_iam_policy_document" "policy" { 8 | statement { 9 | actions = [ 10 | "glue:*", 11 | ] 12 | resources = ["arn:aws:glue:${var.region}:${data.aws_caller_identity.current.id}:*"] 13 | principals { 14 | identifiers = ["*"] 15 | type = "AWS" 16 | } 17 | } 18 | } 19 | 20 | resource "aws_glue_resource_policy" "policy" { 21 | policy = data.aws_iam_policy_document.policy.json 22 | } 23 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ebs_volume/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ebs_volume" "volume" { 6 | availability_zone = "${var.region}a" 7 | size = 1 8 | type = "gp2" 9 | 10 | tags = var.tags 11 | } 12 | 13 | resource "aws_ebs_snapshot" "xacct_snapshot" { 14 | volume_id = aws_ebs_volume.volume.id 15 | 16 | tags = var.tags 17 | } 18 | 19 | resource "aws_snapshot_create_volume_permission" "xacct_snapshot" { 20 | snapshot_id = aws_ebs_snapshot.xacct_snapshot.id 21 | account_id = var.account_id 22 | } 23 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if anytrue([for r in rt.routes : startswith(r.gateway_id, "igw-") if r.gateway_id != null]) 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/jenkins/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if anytrue([for r in rt.routes : startswith(r.gateway_id, "igw-") if r.gateway_id != null]) 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/ssh/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if anytrue([for r in rt.routes : startswith(r.gateway_id, "igw-") if r.gateway_id != null]) 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_redshift/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if anytrue([for r in rt.routes : startswith(r.gateway_id, "igw-") if r.gateway_id != null]) 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/opensearch/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if anytrue([for r in rt.routes : startswith(r.gateway_id, "igw-") if r.gateway_id != null]) 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/administrative_user/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "random_password" "user_password" { 6 | length = 16 7 | special = true 8 | } 9 | 10 | resource "aws_iam_user" "admin_user" { 11 | name = var.resource_name 12 | tags = var.tags 13 | } 14 | 15 | resource "aws_iam_access_key" "admin_user_key" { 16 | user = aws_iam_user.admin_user.name 17 | } 18 | 19 | resource "aws_iam_user_policy_attachment" "admin_user_policy_attach" { 20 | user = aws_iam_user.admin_user.name 21 | policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" 22 | } -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get/main.tf: -------------------------------------------------------------------------------- 1 | provider "google" { 2 | project = var.project_name 3 | region = var.region 4 | } 5 | 6 | resource "google_storage_bucket" "public_all_objects" { 7 | name = var.resource_name 8 | location = "US" 9 | 10 | cors { 11 | origin = ["*"] 12 | method = ["GET"] 13 | response_header = ["Content-Type"] 14 | max_age_seconds = 3600 15 | } 16 | 17 | labels = var.tags 18 | } 19 | 20 | resource "google_storage_default_object_access_control" "public_all_objects_acl" { 21 | bucket = google_storage_bucket.public_all_objects.name 22 | role = "READER" 23 | entity = "allUsers" 24 | } 25 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_eip_takeover/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # Create EIP 6 | resource "aws_eip" "eip" { 7 | domain = "vpc" 8 | 9 | tags = var.tags 10 | } 11 | 12 | resource "aws_route53_record" "eip_takeover" { 13 | zone_id = var.hosted_zone_id 14 | name = var.domain_name 15 | type = "A" 16 | ttl = "300" 17 | records = [aws_eip.eip.public_ip] 18 | } 19 | 20 | resource "null_resource" "eip_deletion" { 21 | depends_on = [aws_eip.eip, aws_route53_record.eip_takeover] 22 | 23 | provisioner "local-exec" { 24 | command = "aws ec2 release-address --allocation-id ${aws_eip.eip.allocation_id}" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/SecurityRunners/CloudCommotion 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be 7 | github.com/hashicorp/terraform-exec v0.18.1 8 | github.com/spf13/cobra v1.7.0 9 | gopkg.in/yaml.v2 v2.4.0 10 | ) 11 | 12 | require ( 13 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect 14 | github.com/hashicorp/go-version v1.6.0 // indirect 15 | github.com/hashicorp/terraform-json v0.15.0 // indirect 16 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 17 | github.com/spf13/pflag v1.0.5 // indirect 18 | github.com/zclconf/go-cty v1.13.0 // indirect 19 | golang.org/x/text v0.6.0 // indirect 20 | ) 21 | -------------------------------------------------------------------------------- /terraform/environment/test/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | variable "tags" { 18 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 19 | type = map(string) 20 | default = { 21 | "Creator" = "CloudCommotion" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /terraform/.template/azure/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /terraform/.template/github/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Custom variables 18 | variable "github_token" { 19 | description = "GitHub API token" 20 | type = string 21 | } 22 | 23 | variable "organization_name" { 24 | description = "GitHub organization name" 25 | type = string 26 | } 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get_list/main.tf: -------------------------------------------------------------------------------- 1 | provider "google" { 2 | project = var.project_name 3 | region = var.region 4 | } 5 | 6 | resource "google_storage_bucket" "public_all_objects" { 7 | name = var.resource_name 8 | location = "US" 9 | 10 | cors { 11 | origin = ["*"] 12 | method = ["GET"] 13 | response_header = ["Content-Type"] 14 | max_age_seconds = 3600 15 | } 16 | 17 | labels = var.tags 18 | } 19 | 20 | resource "google_storage_bucket_iam_binding" "public_all_objects_and_listable_bucket_acl" { 21 | bucket = google_storage_bucket.public_all_objects.name 22 | role = "roles/storage.legacyBucketReader" 23 | members = [ 24 | "allUsers", 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sns_topic/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_sns_topic" "topic" { 6 | name = var.resource_name 7 | 8 | display_name = var.sensitive_content 9 | 10 | tags = var.tags 11 | } 12 | 13 | data "aws_iam_policy_document" "policy" { 14 | statement { 15 | actions = ["SNS:Publish", "SNS:Subscribe", "SNS:Receive"] 16 | effect = "Allow" 17 | resources = [aws_sns_topic.topic.arn] 18 | 19 | principals { 20 | type = "AWS" 21 | identifiers = ["*"] 22 | } 23 | } 24 | } 25 | 26 | resource "aws_sns_topic_policy" "public_topic_policy" { 27 | arn = aws_sns_topic.topic.arn 28 | policy = data.aws_iam_policy_document.policy.json 29 | } 30 | -------------------------------------------------------------------------------- /terraform/.template/aws/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/environment/vpc/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glacier/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_caller_identity" "current" {} 6 | 7 | resource "aws_glacier_vault" "archive" { 8 | name = var.resource_name 9 | 10 | access_policy = data.aws_iam_policy_document.policy.json 11 | 12 | tags = var.tags 13 | } 14 | 15 | data "aws_iam_policy_document" "policy" { 16 | statement { 17 | actions = [ 18 | "glacier:InitiateJob", 19 | "glacier:GetJobOutput" 20 | ] 21 | 22 | resources = [ 23 | "arn:aws:glacier:${var.region}:${data.aws_caller_identity.current.account_id}:vaults/${var.resource_name}" 24 | ] 25 | 26 | principals { 27 | type = "AWS" 28 | identifiers = ["*"] 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_efs/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glue/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom 27 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_administrator/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_iam_role" "exposed_asset" { 6 | name = var.resource_name 7 | tags = var.tags 8 | 9 | assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json 10 | } 11 | 12 | data "aws_iam_policy_document" "assume_role_policy" { 13 | statement { 14 | actions = ["sts:AssumeRole"] 15 | 16 | principals { 17 | type = "AWS" 18 | identifiers = ["arn:aws:iam::${var.account_id}:root"] 19 | } 20 | } 21 | } 22 | 23 | resource "aws_iam_role_policy_attachment" "admin_full_access" { 24 | role = aws_iam_role.exposed_asset.name 25 | policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" 26 | } 27 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_lightsail/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ami/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ebs/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_glacier/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_iam_role/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_kms_key/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sns_topic/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_backup_vault/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/layer/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_write/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_secrets_manager/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/privesc_user/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/administrative_user/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public_gallery/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_eks/cluster/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) > 0 17 | ] 18 | 19 | private_subnets = [ 20 | for rt in data.aws_route_table.subnet_route_tables : 21 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) == 0 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_opensearch/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) > 0 17 | ] 18 | 19 | private_subnets = [ 20 | for rt in data.aws_route_table.subnet_route_tables : 21 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) == 0 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/jenkins/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) > 0 17 | ] 18 | 19 | private_subnets = [ 20 | for rt in data.aws_route_table.subnet_route_tables : 21 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) == 0 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/opensearch/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) > 0 17 | ] 18 | 19 | private_subnets = [ 20 | for rt in data.aws_route_table.subnet_route_tables : 21 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) == 0 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_clb/opensearch/subnets.tf: -------------------------------------------------------------------------------- 1 | data "aws_subnets" "vpc_subnets" { 2 | filter { 3 | name = "vpc-id" 4 | values = [var.vpc_id] 5 | } 6 | } 7 | 8 | data "aws_route_table" "subnet_route_tables" { 9 | count = length(data.aws_subnets.vpc_subnets.ids) 10 | subnet_id = tolist(data.aws_subnets.vpc_subnets.ids)[count.index] 11 | } 12 | 13 | locals { 14 | public_subnets = [ 15 | for rt in data.aws_route_table.subnet_route_tables : 16 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) > 0 17 | ] 18 | 19 | private_subnets = [ 20 | for rt in data.aws_route_table.subnet_route_tables : 21 | rt.subnet_id if length([for r in rt.routes : r.gateway_id if startswith(r.gateway_id, "igw-")]) == 0 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_efs/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_efs_file_system" "fs" { 6 | creation_token = "my-product" 7 | 8 | tags = var.tags 9 | } 10 | 11 | resource "aws_efs_file_system_policy" "policy" { 12 | file_system_id = aws_efs_file_system.fs.id 13 | 14 | policy = data.aws_iam_policy_document.policy.json 15 | } 16 | 17 | data "aws_iam_policy_document" "policy" { 18 | statement { 19 | sid = "AllowMountWriteAnywhere" 20 | effect = "Allow" 21 | 22 | principals { 23 | type = "AWS" 24 | identifiers = ["*"] 25 | } 26 | 27 | actions = [ 28 | "elasticfilesystem:ClientMount", 29 | "elasticfilesystem:ClientWrite", 30 | "elasticfilesystem:ClientRootAccess" 31 | ] 32 | 33 | resources = [ 34 | aws_efs_file_system.fs.arn 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_eks/cluster/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "vpc_id" { 28 | description = "The VPC ID to create resources in" 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /terraform/.template/gcp/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "project_name" { 28 | description = "Name of the project to be used in the resource names" 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ebs_volume/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "account_id" { 28 | description = "The AWS account ID to share the EBS volume with" 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | release: 3 | types: [created] 4 | 5 | permissions: 6 | contents: write 7 | packages: write 8 | 9 | jobs: 10 | releases-matrix: 11 | name: Release Go Binary 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | goos: [linux, windows, darwin] 16 | goarch: ["386", amd64, arm64] 17 | exclude: 18 | - goarch: "386" 19 | goos: darwin 20 | - goarch: arm64 21 | goos: windows 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: wangyoucao577/go-release-action@v1.34 25 | with: 26 | github_token: ${{ secrets.GITHUB_TOKEN }} 27 | goos: ${{ matrix.goos }} 28 | goarch: ${{ matrix.goarch }} 29 | goversion: "https://dl.google.com/go/go1.19.linux-amd64.tar.gz" 30 | project_path: "." 31 | binary_name: "cloudcommotion" 32 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ami/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ebs_volume" "volume" { 6 | availability_zone = "${var.region}a" 7 | size = 1 8 | type = "gp2" 9 | 10 | tags = var.tags 11 | } 12 | 13 | resource "aws_ebs_snapshot" "snapshot" { 14 | volume_id = aws_ebs_volume.volume.id 15 | 16 | tags = var.tags 17 | } 18 | 19 | resource "aws_ami" "public_ami" { 20 | name = var.resource_name 21 | virtualization_type = "hvm" 22 | root_device_name = "/dev/xvda" 23 | tags = var.tags 24 | 25 | ebs_block_device { 26 | device_name = "/dev/xvda" 27 | snapshot_id = aws_ebs_snapshot.snapshot.id 28 | volume_size = 8 29 | } 30 | } 31 | 32 | resource "aws_ami_launch_permission" "public_ami_launch_permission" { 33 | image_id = aws_ami.public_ami.id 34 | group = "all" 35 | } 36 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ec2_ami/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ebs_volume" "volume" { 6 | availability_zone = "${var.region}a" 7 | size = 1 8 | type = "gp2" 9 | 10 | tags = var.tags 11 | } 12 | 13 | resource "aws_ebs_snapshot" "snapshot" { 14 | volume_id = aws_ebs_volume.volume.id 15 | 16 | tags = var.tags 17 | } 18 | 19 | resource "aws_ami" "xacct_ami" { 20 | name = var.resource_name 21 | virtualization_type = "hvm" 22 | root_device_name = "/dev/xvda" 23 | tags = var.tags 24 | 25 | ebs_block_device { 26 | device_name = "/dev/xvda" 27 | snapshot_id = aws_ebs_snapshot.snapshot.id 28 | volume_size = 8 29 | } 30 | } 31 | 32 | resource "aws_ami_launch_permission" "xacct_ami_launch_permission" { 33 | image_id = aws_ami.xacct_ami.id 34 | account_id = var.account_id 35 | } 36 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sqs/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom 27 | variable "message_retention" { 28 | description = "Retention time defaults to 4 days (345600 seconds)" 29 | type = number 30 | default = 345600 31 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/ec2_ami/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "account_id" { 28 | description = "Account ID for the AMI to be shared with" 29 | type = string 30 | default = "t3.micro" 31 | } 32 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "project_name" { 28 | description = "Name of the project to be used in the resource names" 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_get_list/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "project_name" { 28 | description = "Name of the project to be used in the resource names" 29 | type = string 30 | } 31 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_delegation_takeover/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # Create a Route53 hosted zone for the subdomain 6 | resource "aws_route53_zone" "sub_zone" { 7 | name = "${var.resource_name}.${var.parent_domain}." 8 | } 9 | 10 | # Add NS records to the parent domain to delegate to the subdomain 11 | resource "aws_route53_record" "sub_ns" { 12 | zone_id = var.parent_zone_id 13 | name = "${var.resource_name}.${var.parent_domain}" 14 | type = "NS" 15 | ttl = "300" 16 | records = aws_route53_zone.sub_zone.name_servers 17 | } 18 | 19 | resource "null_resource" "delete_sub_zone" { 20 | triggers = { 21 | sub_zone_id = aws_route53_zone.sub_zone.zone_id 22 | } 23 | 24 | provisioner "local-exec" { 25 | command = "aws route53 delete-hosted-zone --id ${aws_route53_zone.sub_zone.zone_id}" 26 | } 27 | 28 | depends_on = [aws_route53_record.sub_ns] 29 | } 30 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ecr_repository" "public_repo" { 6 | name = var.resource_name 7 | 8 | tags = var.tags 9 | } 10 | 11 | data "aws_iam_policy_document" "policy" { 12 | statement { 13 | sid = "AllowPushPull" 14 | effect = "Allow" 15 | 16 | principals { 17 | type = "AWS" 18 | identifiers = ["*"] 19 | } 20 | 21 | actions = [ 22 | "ecr:BatchCheckLayerAvailability", 23 | "ecr:BatchGetImage", 24 | "ecr:CompleteLayerUpload", 25 | "ecr:GetDownloadUrlForLayer", 26 | "ecr:InitiateLayerUpload", 27 | "ecr:PutImage", 28 | "ecr:UploadLayerPart" 29 | ] 30 | } 31 | } 32 | 33 | 34 | resource "aws_ecr_repository_policy" "my_repo_policy" { 35 | repository = aws_ecr_repository.public_repo.name 36 | policy = data.aws_iam_policy_document.policy.json 37 | } 38 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_backup_vault/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_backup_global_settings" "settings" { 6 | global_settings = { 7 | "isCrossAccountBackupEnabled" = "true" 8 | } 9 | } 10 | 11 | resource "aws_backup_vault" "vault" { 12 | name = var.resource_name 13 | 14 | tags = var.tags 15 | } 16 | 17 | data "aws_iam_policy_document" "policy" { 18 | statement { 19 | effect = "Allow" 20 | 21 | principals { 22 | type = "AWS" 23 | identifiers = ["*"] 24 | } 25 | 26 | actions = [ 27 | "backup:CopyIntoBackupVault", 28 | ] 29 | 30 | resources = [aws_backup_vault.vault.arn] 31 | } 32 | } 33 | 34 | resource "aws_backup_vault_policy" "policy" { 35 | backup_vault_name = aws_backup_vault.vault.name 36 | policy = data.aws_iam_policy_document.policy.json 37 | 38 | depends_on = [aws_backup_global_settings.settings] 39 | } 40 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_privesc/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "account_id" { 28 | description = "The AWS account ID that will have backdoor access" 29 | type = string 30 | default = "111111111111" 31 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_get/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "custom_sensitive_file" { 28 | description = "Convincing sensitive file name, randomly generated otherwise." 29 | type = string 30 | default = "" 31 | } -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_administrator/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "account_id" { 28 | description = "The AWS account ID that will have backdoor access" 29 | type = string 30 | default = "111111111111" 31 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_list_get/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "custom_sensitive_file" { 28 | description = "Convincing sensitive file name, randomly generated otherwise." 29 | type = string 30 | default = "" 31 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_object_acl/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "custom_sensitive_file" { 28 | description = "Convincing sensitive file name, randomly generated otherwise." 29 | type = string 30 | default = "" 31 | } -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ebs/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_ebs_volume" "volume" { 6 | availability_zone = "${var.region}a" 7 | size = 1 8 | type = "gp2" 9 | 10 | tags = var.tags 11 | } 12 | 13 | resource "aws_ebs_snapshot" "public_snapshot" { 14 | volume_id = aws_ebs_volume.volume.id 15 | 16 | tags = var.tags 17 | } 18 | 19 | # Forgotten issue and not possible through terraform 20 | # https://github.com/hashicorp/terraform-provider-aws/issues/13198 21 | resource "null_resource" "make_snapshot_public" { 22 | provisioner "local-exec" { 23 | command = "aws ec2 modify-snapshot-attribute --snapshot-id ${aws_ebs_snapshot.public_snapshot.id} --attribute createVolumePermission --operation-type add --group-names all" 24 | } 25 | 26 | triggers = { 27 | snapshot_id = aws_ebs_snapshot.public_snapshot.id 28 | } 29 | 30 | depends_on = [aws_ebs_snapshot.public_snapshot] 31 | } 32 | 33 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_secrets_manager/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_secretsmanager_secret" "secret" { 6 | name = var.resource_name 7 | 8 | tags = var.tags 9 | } 10 | 11 | data "aws_iam_policy_document" "policy" { 12 | statement { 13 | sid = "AllowPublicAccessToSecret" 14 | effect = "Allow" 15 | 16 | principals { 17 | type = "AWS" 18 | identifiers = ["*"] 19 | } 20 | 21 | actions = [ 22 | "secretsmanager:GetSecretValue" 23 | ] 24 | 25 | resources = [aws_secretsmanager_secret.secret.arn] 26 | } 27 | } 28 | 29 | resource "aws_secretsmanager_secret_policy" "public_policy" { 30 | secret_arn = aws_secretsmanager_secret.secret.arn 31 | policy = data.aws_iam_policy_document.policy.json 32 | } 33 | 34 | resource "aws_secretsmanager_secret_version" "secret_version" { 35 | secret_id = aws_secretsmanager_secret.secret.id 36 | secret_string = var.sensitive_content 37 | } 38 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_delegation_takeover/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "parent_domain" { 28 | description = "The parent domain name." 29 | type = string 30 | } 31 | 32 | variable "parent_zone_id" { 33 | description = "The Route53 Zone ID for the parent domain." 34 | type = string 35 | } 36 | -------------------------------------------------------------------------------- /terraform/exposed_services/github_repository/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | variable "tags" { 18 | description = "Tags to apply to resources" 19 | type = map(string) 20 | default = {} 21 | } 22 | 23 | # Custom variables 24 | variable "github_token" { 25 | description = "GitHub API token" 26 | type = string 27 | } 28 | 29 | variable "organization_name" { 30 | description = "GitHub organization name" 31 | type = string 32 | } 33 | 34 | variable "file_name" { 35 | description = "Name of the file to create in the repository" 36 | type = string 37 | default = "sensitive.txt" 38 | } 39 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_eip_takeover/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "domain_name" { 28 | description = "The domain name used for the takeover" 29 | type = string 30 | default = "www.example.com" 31 | } 32 | 33 | variable "hosted_zone_id" { 34 | description = "The hosted zone ID for the domain name" 35 | type = string 36 | } 37 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_s3_takeover/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "domain_name" { 28 | description = "The domain name used for the takeover" 29 | type = string 30 | default = "www.example.com" 31 | } 32 | 33 | variable "hosted_zone_id" { 34 | description = "The hosted zone ID for the domain name" 35 | type = string 36 | } 37 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_second_order_takeover/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "domain_name" { 28 | description = "The domain name used for the takeover" 29 | type = string 30 | default = "www.example.com" 31 | } 32 | 33 | variable "hosted_zone_id" { 34 | description = "The hosted zone ID for the domain name" 35 | type = string 36 | } 37 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_object/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "project_name" { 28 | description = "Name of the project to be used in the resource names" 29 | type = string 30 | } 31 | 32 | variable "custom_sensitive_file" { 33 | description = "Convincing sensitive file name, randomly generated otherwise." 34 | type = string 35 | default = "" 36 | } 37 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sqs/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_sqs_queue" "public_queue" { 6 | name = var.resource_name 7 | 8 | message_retention_seconds = var.message_retention 9 | } 10 | 11 | 12 | data "aws_iam_policy_document" "public_queue_policy" { 13 | statement { 14 | sid = "PublicSendReceiveMessages" 15 | effect = "Allow" 16 | principals { 17 | type = "AWS" 18 | identifiers = ["*"] 19 | } 20 | actions = [ 21 | "sqs:ReceiveMessage" 22 | ] 23 | resources = [aws_sqs_queue.public_queue.arn] 24 | } 25 | } 26 | 27 | resource "aws_sqs_queue_policy" "public_queue_policy_attach" { 28 | queue_url = aws_sqs_queue.public_queue.id 29 | policy = data.aws_iam_policy_document.public_queue_policy.json 30 | } 31 | 32 | resource "null_resource" "send_sqs_message" { 33 | triggers = { 34 | queue_url = aws_sqs_queue.public_queue.id 35 | } 36 | 37 | provisioner "local-exec" { 38 | command = "aws sqs send-message --queue-url ${aws_sqs_queue.public_queue.id} --message-body '${var.sensitive_content}'" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_s3_takeover/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # Create an S3 bucket for static website hosting 6 | resource "aws_s3_bucket" "static_bucket" { 7 | bucket = var.resource_name 8 | 9 | tags = var.tags 10 | } 11 | 12 | resource "aws_s3_bucket_website_configuration" "static_bucket" { 13 | bucket = aws_s3_bucket.static_bucket.id 14 | 15 | index_document { 16 | suffix = "index.html" 17 | } 18 | 19 | error_document { 20 | key = "error.html" 21 | } 22 | } 23 | 24 | resource "aws_route53_record" "website_record" { 25 | zone_id = var.hosted_zone_id 26 | name = var.domain_name 27 | type = "A" 28 | 29 | alias { 30 | name = aws_s3_bucket_website_configuration.static_bucket.website_domain 31 | zone_id = aws_s3_bucket.static_bucket.hosted_zone_id 32 | evaluate_target_health = false 33 | } 34 | } 35 | 36 | resource "null_resource" "bucket_deletion" { 37 | depends_on = [aws_s3_bucket.static_bucket] 38 | 39 | provisioner "local-exec" { 40 | command = "aws s3 rb s3://${aws_s3_bucket.static_bucket.bucket} --force" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_privesc/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_iam_role" "exposed_asset" { 6 | name = var.resource_name 7 | tags = var.tags 8 | 9 | assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json 10 | } 11 | 12 | data "aws_iam_policy_document" "assume_role_policy" { 13 | statement { 14 | actions = ["sts:AssumeRole"] 15 | 16 | principals { 17 | type = "AWS" 18 | identifiers = ["arn:aws:iam::${var.account_id}:root"] 19 | } 20 | } 21 | } 22 | 23 | resource "aws_iam_policy" "priv_esc_policy" { 24 | name = "PotentialPrivEscPolicy" 25 | description = "A policy that might allow privilege escalation" 26 | 27 | policy = data.aws_iam_policy_document.priv_esc_policy.json 28 | } 29 | 30 | data "aws_iam_policy_document" "priv_esc_policy" { 31 | statement { 32 | actions = ["iam:PutRolePolicy"] 33 | resources = ["*"] 34 | } 35 | } 36 | 37 | resource "aws_iam_role_policy_attachment" "potential_priv_esc_attachment" { 38 | role = aws_iam_role.exposed_asset.name 39 | policy_arn = aws_iam_policy.priv_esc_policy.arn 40 | } 41 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_iam_role/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_iam_policy_document" "wildcard_assume_role" { 6 | statement { 7 | effect = "Allow" 8 | 9 | principals { 10 | type = "AWS" 11 | identifiers = ["*"] 12 | } 13 | 14 | actions = ["sts:AssumeRole"] 15 | } 16 | } 17 | 18 | resource "aws_iam_role" "public_role" { 19 | name = var.resource_name 20 | assume_role_policy = data.aws_iam_policy_document.wildcard_assume_role.json 21 | 22 | tags = var.tags 23 | } 24 | 25 | data "aws_iam_policy_document" "get_caller_identity_policy" { 26 | statement { 27 | effect = "Allow" 28 | actions = ["sts:GetCallerIdentity"] 29 | resources = ["*"] 30 | } 31 | } 32 | 33 | resource "aws_iam_policy" "policy" { 34 | name = var.resource_name 35 | description = var.sensitive_content 36 | policy = data.aws_iam_policy_document.get_caller_identity_policy.json 37 | 38 | tags = var.tags 39 | } 40 | 41 | resource "aws_iam_role_policy_attachment" "example_attach" { 42 | role = aws_iam_role.public_role.name 43 | policy_arn = aws_iam_policy.policy.arn 44 | } 45 | -------------------------------------------------------------------------------- /config/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Default configuration file 3 | provider: aws # Does not impact anything at this time but should in the future 4 | #profile: prod-operations-user # AWS profile list maybe 5 | region: us-east-1 # Can select any valid region or `random` to randomize regions 6 | 7 | # List of exercises to run 8 | module: 9 | # This is for the VPC creation for exposed_assets to be created if you need a VPC 10 | # - name: VPC Creation 11 | # terraform_dir: terraform/environment/vpc 12 | - name: Publicly Accessible S3 Bucket(Get) 13 | terraform_dir: terraform/exposed_services/aws_s3/public_get 14 | - name: Public Lambda Endpoint 15 | terraform_dir: terraform/exposed_services/aws_lambda/endpoint 16 | - name: Public ECR Gallery 17 | terraform_dir: terraform/exposed_services/aws_ecr/aws_ecr_public_gallery 18 | variables: 19 | resource_name: "securityrunners-static-website" # Convincing resource name for all resources to be created as 20 | sensitive_content: "This is a message to provide to incident responders who have appropriately triaged the asset" 21 | tags: 22 | Name: "securityrunners-static-website" 23 | Owner: "Operations" 24 | Project: "CloudCommotion" 25 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_asg_takeover_rce/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "vpc_id" { 28 | description = "The VPC to create the instance in" 29 | type = string 30 | } 31 | 32 | variable "subnet_id" { 33 | description = "The subnet to create the instance in" 34 | type = string 35 | } 36 | 37 | variable "instance_type" { 38 | description = "The instance type to use for the instance" 39 | type = string 40 | default = "t3.micro" 41 | } 42 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "vpc_id" { 28 | description = "The VPC ID to launch the instance in" 29 | type = string 30 | } 31 | 32 | variable "allowed_ip" { 33 | description = "List of IP addresses to allow access to the box" 34 | type = string 35 | default = "0.0.0.0/0" 36 | } 37 | 38 | variable "node_type" { 39 | description = "The instance type to use for the instance" 40 | type = string 41 | default = "db.t2.micro" 42 | } 43 | -------------------------------------------------------------------------------- /terraform/misconfigurations/aws_iam_role/oidc/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "openid_url" { 28 | type = string 29 | default = "https://token.actions.githubusercontent.com" 30 | } 31 | 32 | variable "client_id_list" { 33 | type = list(string) 34 | default = [ 35 | "https://github.com/SecurityRunners" 36 | ] 37 | } 38 | 39 | variable "thumbprint_list" { 40 | type = list(string) 41 | default = [ 42 | "6938fd4d98bab03faadb97b34396831e3780aea1", 43 | "1c58a3a8518e8759bf075b76b750d4f2df264fcd" 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/privesc_user/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_caller_identity" "current" {} 2 | 3 | provider "aws" { 4 | region = var.region 5 | } 6 | 7 | resource "random_password" "user_password" { 8 | length = 16 9 | special = true 10 | } 11 | 12 | resource "aws_iam_user" "exposed_asset" { 13 | name = var.resource_name 14 | tags = var.tags 15 | } 16 | 17 | resource "aws_iam_access_key" "admin_user_key" { 18 | user = aws_iam_user.exposed_asset.name 19 | } 20 | 21 | resource "aws_iam_policy" "priv_esc_policy" { 22 | name = var.resource_name 23 | description = var.sensitive_content 24 | 25 | policy = data.aws_iam_policy_document.priv_esc_policy.json 26 | } 27 | 28 | data "aws_iam_policy_document" "priv_esc_policy" { 29 | statement { 30 | actions = ["iam:PutUserPolicy", "iam:AttachUserPolicy"] 31 | resources = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:user/${aws_iam_user.exposed_asset.name}"] 32 | } 33 | 34 | statement { 35 | actions = ["iam:CreatePolicy"] 36 | resources = ["*"] 37 | } 38 | } 39 | 40 | resource "aws_iam_user_policy_attachment" "potential_priv_esc_attachment" { 41 | user = aws_iam_user.exposed_asset.name 42 | policy_arn = aws_iam_policy.priv_esc_policy.arn 43 | } 44 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_kms_key/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_caller_identity" "current" {} 6 | 7 | data "aws_iam_policy_document" "public_kms_policy" { 8 | statement { 9 | sid = "AllowRootAccess" 10 | 11 | actions = ["kms:*"] 12 | 13 | resources = ["*"] 14 | 15 | principals { 16 | type = "AWS" 17 | identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] 18 | } 19 | 20 | condition { 21 | test = "StringEquals" 22 | variable = "aws:principaltype" 23 | values = ["Account"] 24 | } 25 | } 26 | 27 | 28 | statement { 29 | sid = "AllowAllUsersAccess" 30 | 31 | actions = ["kms:*"] 32 | 33 | resources = ["*"] 34 | 35 | principals { 36 | type = "AWS" 37 | identifiers = ["*"] 38 | } 39 | } 40 | } 41 | 42 | resource "aws_kms_key" "public_key" { 43 | description = var.sensitive_content 44 | enable_key_rotation = true 45 | policy = data.aws_iam_policy_document.public_kms_policy.json 46 | 47 | tags = var.tags 48 | } 49 | 50 | resource "aws_kms_alias" "alias" { 51 | name = "alias/${var.resource_name}" 52 | target_key_id = aws_kms_key.public_key.key_id 53 | } 54 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_thirdparty_takeover/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "domain_name" { 28 | description = "The domain name used for the takeover" 29 | type = string 30 | default = "www.example.com" 31 | } 32 | 33 | variable "hosted_zone_id" { 34 | description = "The hosted zone ID for the domain name" 35 | type = string 36 | } 37 | 38 | variable "thirdparty_alias" { 39 | description = "The alias of the site that does not exist" 40 | type = string 41 | default = "thissitedefinetelydoesnotexist.wordpress.com" 42 | } 43 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/layer/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "null_resource" "layer_zip" { 6 | provisioner "local-exec" { 7 | command = < layer.txt 9 | zip layer.zip layer.txt 10 | EOL 11 | } 12 | 13 | triggers = { 14 | content = var.sensitive_content 15 | } 16 | } 17 | 18 | resource "aws_lambda_layer_version" "lambda_layer" { 19 | filename = "layer.zip" 20 | layer_name = var.resource_name 21 | compatible_runtimes = ["nodejs14.x"] 22 | 23 | depends_on = [null_resource.layer_zip] 24 | } 25 | 26 | resource "aws_lambda_layer_version_permission" "lambda_layer_permission" { 27 | depends_on = [aws_lambda_layer_version.lambda_layer] 28 | layer_name = aws_lambda_layer_version.lambda_layer.layer_name 29 | version_number = aws_lambda_layer_version.lambda_layer.version 30 | principal = "*" 31 | action = "lambda:GetLayerVersion" 32 | statement_id = var.resource_name 33 | } 34 | 35 | # Remove the layer once complete 36 | resource "null_resource" "remove_zip" { 37 | provisioner "local-exec" { 38 | command = "rm -f layer.zip layer.txt" 39 | } 40 | 41 | depends_on = [aws_lambda_layer_version.lambda_layer] 42 | } 43 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/ssh/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.micro" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/jenkins/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.micro" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/opensearch/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.small" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/jenkins/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.micro" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_alb/opensearch/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.small" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2_clb/opensearch/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "allowed_ip" { 28 | description = "List of IP addresses to allow access to the box" 29 | type = string 30 | default = "0.0.0.0/0" 31 | } 32 | 33 | variable "vpc_id" { 34 | description = "The VPC ID to launch the instance in" 35 | type = string 36 | } 37 | 38 | variable "instance_type" { 39 | description = "The type of instance to start" 40 | type = string 41 | default = "t3.small" 42 | } 43 | 44 | variable "key_pair" { 45 | description = "The key pair to use for SSH access" 46 | type = string 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_redshift/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "vpc_id" { 28 | description = "The VPC ID to launch the instance in" 29 | type = string 30 | } 31 | 32 | variable "subnet_id" { 33 | description = "The subnet ID to launch the instance in" 34 | type = string 35 | } 36 | 37 | variable "allowed_ip" { 38 | description = "List of IP addresses to allow access to the box" 39 | type = string 40 | default = "0.0.0.0/0" 41 | } 42 | 43 | variable "node_type" { 44 | description = "The instance type to use for the instance" 45 | type = string 46 | default = "dc2.large" 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_opensearch/variables.tf: -------------------------------------------------------------------------------- 1 | # Global variables 2 | variable "resource_name" { 3 | description = "Convincing bucket name for the organization" 4 | type = string 5 | } 6 | 7 | variable "sensitive_content" { 8 | description = "Content of the sensitive file to reach out to an appropriate contact." 9 | type = string 10 | } 11 | 12 | variable "region" { 13 | description = "The AWS region to create resources in" 14 | type = string 15 | } 16 | 17 | # Optional variables 18 | variable "tags" { 19 | description = "Organization tagging strategy but should keep Creator tag for discovery later." 20 | type = map(string) 21 | default = { 22 | "Creator" = "CloudCommotion" 23 | } 24 | } 25 | 26 | # Custom variables 27 | variable "opensearch_version" { 28 | description = "OpenSearch version." 29 | type = string 30 | default = "OpenSearch_2.7" 31 | } 32 | 33 | variable "instance_type" { 34 | description = "OpenSearch instance type." 35 | type = string 36 | default = "t3.small.search" 37 | } 38 | 39 | variable "allowed_ip" { 40 | description = "List of IP addresses to allow access to the box" 41 | type = string 42 | default = "0.0.0.0/0" 43 | } 44 | 45 | variable "vpc_id" { 46 | description = "The VPC ID to launch the instance in" 47 | type = string 48 | } 49 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "archive_file" "lambda_zip" { 6 | type = "zip" 7 | source_file = "index.py" 8 | output_path = "lambda_function_payload.zip" 9 | } 10 | 11 | resource "aws_lambda_function" "public_lambda" { 12 | filename = data.archive_file.lambda_zip.output_path 13 | function_name = var.resource_name 14 | role = aws_iam_role.lambda_execution_role.arn 15 | handler = "index.lambda_handler" 16 | runtime = "python3.8" 17 | tags = var.tags 18 | 19 | environment { 20 | variables = { 21 | SENSITIVE_CONTENT = var.sensitive_content 22 | } 23 | } 24 | } 25 | 26 | resource "aws_lambda_function_url" "lambda_function_url" { 27 | function_name = aws_lambda_function.public_lambda.arn 28 | authorization_type = "NONE" 29 | } 30 | 31 | resource "aws_iam_role" "lambda_execution_role" { 32 | name = "lambda_execution_role" 33 | tags = var.tags 34 | 35 | assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json 36 | } 37 | 38 | data "aws_iam_policy_document" "lambda_assume_role" { 39 | statement { 40 | actions = ["sts:AssumeRole"] 41 | effect = "Allow" 42 | principals { 43 | type = "Service" 44 | identifiers = ["lambda.amazonaws.com"] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_write/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_s3_bucket" "public_bucket" { 6 | bucket = var.resource_name 7 | tags = var.tags 8 | 9 | lifecycle { 10 | prevent_destroy = false 11 | } 12 | } 13 | 14 | data "aws_iam_policy_document" "public_policy" { 15 | statement { 16 | sid = "PublicPutObject" 17 | effect = "Allow" 18 | principals { 19 | type = "AWS" 20 | identifiers = ["*"] 21 | } 22 | actions = ["s3:PutObject"] 23 | resources = [ 24 | "arn:aws:s3:::${aws_s3_bucket.public_bucket.id}/*" 25 | ] 26 | } 27 | } 28 | 29 | resource "aws_s3_bucket_policy" "s3_bucket_policy" { 30 | bucket = aws_s3_bucket.public_bucket.id 31 | policy = data.aws_iam_policy_document.public_policy.json 32 | } 33 | 34 | resource "aws_s3_bucket_server_side_encryption_configuration" "s3_bucket_server_side_encryption_configuration" { 35 | bucket = aws_s3_bucket.public_bucket.id 36 | rule { 37 | apply_server_side_encryption_by_default { 38 | sse_algorithm = "AES256" 39 | } 40 | } 41 | } 42 | 43 | resource "aws_s3_bucket_public_access_block" "s3_bucket_public_access_block" { 44 | bucket = aws_s3_bucket.public_bucket.id 45 | 46 | block_public_acls = true 47 | ignore_public_acls = true 48 | block_public_policy = false 49 | restrict_public_buckets = false 50 | } 51 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_db_instance" "rds_instance" { 6 | identifier = var.resource_name 7 | 8 | db_name = "mydb" 9 | allocated_storage = 20 10 | storage_type = "gp2" 11 | engine = "mysql" 12 | engine_version = "5.7" 13 | instance_class = var.node_type 14 | username = "admin" 15 | password = resource.random_password.password.result 16 | parameter_group_name = "default.mysql5.7" 17 | skip_final_snapshot = true 18 | multi_az = false 19 | 20 | vpc_security_group_ids = [aws_security_group.rds_security_group.id] 21 | db_subnet_group_name = aws_db_subnet_group.rds_subnet_group.name 22 | 23 | tags = var.tags 24 | } 25 | 26 | resource "aws_db_subnet_group" "rds_subnet_group" { 27 | name = "${var.resource_name}-subnet-group" 28 | subnet_ids = local.public_subnets 29 | 30 | tags = var.tags 31 | } 32 | 33 | resource "aws_security_group" "rds_security_group" { 34 | name = var.resource_name 35 | description = var.sensitive_content 36 | vpc_id = var.vpc_id 37 | 38 | tags = var.tags 39 | } 40 | 41 | resource "aws_security_group_rule" "rds_security_group_rule" { 42 | type = "ingress" 43 | from_port = 3306 44 | to_port = 3306 45 | protocol = "tcp" 46 | cidr_blocks = [var.allowed_ip] 47 | security_group_id = aws_security_group.rds_security_group.id 48 | } 49 | 50 | resource "random_password" "password" { 51 | length = 16 52 | special = true 53 | override_special = "!#$%&*()-_=+[]{}<>:?" 54 | } 55 | -------------------------------------------------------------------------------- /terraform/misconfigurations/aws_iam_role/oidc/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # aws iam open id connect provider github 6 | resource "aws_iam_openid_connect_provider" "provider" { 7 | url = var.openid_url 8 | client_id_list = var.client_id_list 9 | thumbprint_list = var.thumbprint_list 10 | 11 | tags = var.tags 12 | } 13 | 14 | 15 | resource "aws_iam_role" "role" { 16 | name = var.resource_name 17 | description = var.sensitive_content 18 | 19 | assume_role_policy = data.aws_iam_policy_document.document.json 20 | 21 | tags = var.tags 22 | } 23 | 24 | # Misconfigured policy document 25 | data "aws_iam_policy_document" "document" { 26 | statement { 27 | sid = "AssumeRoleFromOIDCProvider" 28 | effect = "Allow" 29 | actions = ["sts:AssumeRoleWithWebIdentity"] 30 | 31 | principals { 32 | type = "Federated" 33 | identifiers = [aws_iam_openid_connect_provider.provider.arn] 34 | } 35 | 36 | condition { 37 | test = "StringEquals" 38 | variable = "token.actions.githubusercontent.com:aud" 39 | values = ["sts.amazonaws.com"] 40 | } 41 | } 42 | } 43 | 44 | resource "aws_iam_role_policy_attachment" "attach" { 45 | role = aws_iam_role.role.name 46 | policy_arn = aws_iam_policy.policy.arn 47 | } 48 | 49 | data "aws_iam_policy_document" "policy" { 50 | statement { 51 | sid = "GetCallerIdentity" 52 | effect = "Allow" 53 | actions = ["sts:GetCallerIdentity"] 54 | 55 | resources = ["*"] 56 | } 57 | } 58 | 59 | resource "aws_iam_policy" "policy" { 60 | name = var.resource_name 61 | description = var.sensitive_content 62 | policy = data.aws_iam_policy_document.policy.json 63 | 64 | tags = var.tags 65 | } 66 | -------------------------------------------------------------------------------- /terraform/exposed_services/google_storage_bucket/public_object/main.tf: -------------------------------------------------------------------------------- 1 | provider "google" { 2 | project = var.project_name 3 | region = var.region 4 | } 5 | 6 | locals { 7 | ### Generate fake file name to ensure once found it is investigated 8 | # Default fake sensitive file names 9 | sensitive_files_generator = [ 10 | "financial_report.pdf", 11 | "financial_data.xlsx", 12 | "personnel_records.csv", 13 | "decrypt_users.py", 14 | "revenue.docx", 15 | "government_ids.csv", 16 | "healthcare_data.json", 17 | "research_findings.ppt", 18 | "q1_earnings_report.pdf", 19 | "customer_ids.docx", 20 | ] 21 | # If a variable named "custom_sensitive_file" is set, use it as the sensitive file name 22 | sensitive_file = var.custom_sensitive_file != "" ? var.custom_sensitive_file : local.sensitive_files_generator[random_integer.index.result] 23 | } 24 | 25 | resource "random_integer" "index" { 26 | min = 0 27 | max = length(local.sensitive_files_generator) - 1 28 | } 29 | 30 | resource "google_storage_bucket" "public_single_object" { 31 | name = var.resource_name 32 | location = "US" 33 | 34 | cors { 35 | origin = ["*"] 36 | method = ["GET"] 37 | response_header = ["Content-Type"] 38 | max_age_seconds = 3600 39 | } 40 | 41 | labels = var.tags 42 | } 43 | 44 | resource "google_storage_bucket_object" "public_single_object_content" { 45 | name = local.sensitive_file 46 | bucket = google_storage_bucket.public_single_object.name 47 | content = var.sensitive_content 48 | } 49 | 50 | resource "google_storage_object_access_control" "public_single_object_acl" { 51 | object = google_storage_bucket_object.public_single_object_content.name 52 | bucket = google_storage_bucket.public_single_object.name 53 | role = "READER" 54 | entity = "allUsers" 55 | } 56 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "archive_file" "lambda_zip" { 6 | type = "zip" 7 | source_file = "index.py" 8 | output_path = "lambda_function_payload.zip" 9 | } 10 | 11 | resource "aws_iam_role" "lambda_execution_role" { 12 | name = "lambda_execution_role" 13 | tags = var.tags 14 | 15 | assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json 16 | } 17 | 18 | data "aws_iam_policy_document" "lambda_assume_role" { 19 | statement { 20 | actions = ["sts:AssumeRole"] 21 | effect = "Allow" 22 | principals { 23 | type = "Service" 24 | identifiers = ["lambda.amazonaws.com"] 25 | } 26 | } 27 | } 28 | 29 | data "aws_iam_policy_document" "public_lambda_invoke_policy" { 30 | statement { 31 | sid = "PublicInvoke" 32 | effect = "Allow" 33 | principals { 34 | type = "AWS" 35 | identifiers = ["*"] 36 | } 37 | actions = ["lambda:InvokeFunction"] 38 | resources = [aws_lambda_function.public_lambda.arn] 39 | } 40 | } 41 | 42 | resource "aws_lambda_permission" "public_invoke_permission" { 43 | statement_id = "AllowInvokeFromAnyone" 44 | action = "lambda:InvokeFunction" 45 | function_name = aws_lambda_function.public_lambda.function_name 46 | principal = "*" 47 | source_arn = aws_lambda_function.public_lambda.arn 48 | } 49 | 50 | resource "aws_lambda_function" "public_lambda" { 51 | filename = data.archive_file.lambda_zip.output_path 52 | function_name = var.resource_name 53 | role = aws_iam_role.lambda_execution_role.arn 54 | handler = "index.lambda_handler" 55 | runtime = "python3.8" 56 | tags = var.tags 57 | 58 | environment { 59 | variables = { 60 | SENSITIVE_CONTENT = var.sensitive_content 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_eks/cluster/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # I am really sick of doing this by hand over and over so taking the lazy way out 6 | module "eks" { 7 | source = "terraform-aws-modules/eks/aws" 8 | version = "~> 19.0" 9 | 10 | cluster_name = var.resource_name 11 | cluster_version = "1.27" 12 | 13 | cluster_endpoint_public_access = true 14 | 15 | cluster_addons = { 16 | coredns = { 17 | most_recent = true 18 | } 19 | kube-proxy = { 20 | most_recent = true 21 | } 22 | vpc-cni = { 23 | most_recent = true 24 | } 25 | } 26 | 27 | vpc_id = var.vpc_id 28 | subnet_ids = local.private_subnets 29 | control_plane_subnet_ids = local.public_subnets 30 | 31 | # EKS Managed Node Group(s) 32 | eks_managed_node_group_defaults = { 33 | instance_types = ["t3.small"] 34 | } 35 | 36 | eks_managed_node_groups = { 37 | blue = {} 38 | green = { 39 | min_size = 1 40 | max_size = 3 41 | desired_size = 1 42 | 43 | instance_types = ["t3.large"] 44 | capacity_type = "SPOT" 45 | } 46 | } 47 | 48 | # aws-auth configmap 49 | manage_aws_auth_configmap = true 50 | 51 | # aws_auth_roles = [ 52 | # { 53 | # rolearn = "arn:aws:iam::66666666666:role/role1" 54 | # username = "role1" 55 | # groups = ["system:masters"] 56 | # }, 57 | # ] 58 | 59 | # aws_auth_users = [ 60 | # { 61 | # userarn = "arn:aws:iam::66666666666:user/user1" 62 | # username = "user1" 63 | # groups = ["system:masters"] 64 | # }, 65 | # { 66 | # userarn = "arn:aws:iam::66666666666:user/user2" 67 | # username = "user2" 68 | # groups = ["system:masters"] 69 | # }, 70 | # ] 71 | 72 | # aws_auth_accounts = [ 73 | # "777777777777", 74 | # "888888888888", 75 | # ] 76 | 77 | tags = var.tags 78 | } 79 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_efs/README.md: -------------------------------------------------------------------------------- 1 | # Public EFS 2 | 3 | This creates a public EFS share. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_efs_file_system.fs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_file_system) | resource | 28 | | [aws_efs_file_system_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_file_system_policy) | resource | 29 | | [aws_iam_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 30 | 31 | ## Inputs 32 | 33 | | Name | Description | Type | Default | Required | 34 | |------|-------------|------|---------|:--------:| 35 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 36 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 37 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 38 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 39 | 40 | ## Outputs 41 | 42 | | Name | Description | 43 | |------|-------------| 44 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 45 | 46 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_ec2/ssh/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_ami" "al2" { 6 | most_recent = true 7 | 8 | filter { 9 | name = "name" 10 | values = ["amzn2-ami-hvm-2.0.*-x86_64-gp2"] 11 | } 12 | 13 | filter { 14 | name = "owner-alias" 15 | values = ["amazon"] 16 | } 17 | } 18 | 19 | resource "aws_instance" "ssh" { 20 | ami = data.aws_ami.al2.id 21 | instance_type = var.instance_type 22 | subnet_id = element(local.public_subnets, 0) 23 | key_name = var.key_pair 24 | 25 | associate_public_ip_address = true 26 | 27 | vpc_security_group_ids = [aws_security_group.ssh.id] 28 | iam_instance_profile = aws_iam_instance_profile.ssm_profile.name 29 | 30 | tags = var.tags 31 | } 32 | 33 | # Session manager for some debugging 34 | resource "aws_iam_role" "ssm_role" { 35 | name = var.resource_name 36 | description = var.sensitive_content 37 | 38 | tags = var.tags 39 | 40 | assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json 41 | } 42 | 43 | data "aws_iam_policy_document" "assume_role_policy" { 44 | statement { 45 | actions = ["sts:AssumeRole"] 46 | 47 | principals { 48 | type = "Service" 49 | identifiers = ["ec2.amazonaws.com"] 50 | } 51 | } 52 | } 53 | 54 | resource "aws_iam_role_policy_attachment" "ssm_attach" { 55 | role = aws_iam_role.ssm_role.name 56 | policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore" 57 | } 58 | 59 | resource "aws_iam_instance_profile" "ssm_profile" { 60 | name = var.resource_name 61 | 62 | role = aws_iam_role.ssm_role.name 63 | } 64 | 65 | resource "aws_security_group" "ssh" { 66 | name = var.resource_name 67 | description = var.sensitive_content 68 | 69 | vpc_id = var.vpc_id 70 | 71 | tags = var.tags 72 | } 73 | 74 | # Allow inbound traffic 75 | resource "aws_security_group_rule" "ssh" { 76 | type = "ingress" 77 | from_port = 22 78 | to_port = 22 79 | protocol = "tcp" 80 | cidr_blocks = [var.allowed_ip] 81 | security_group_id = aws_security_group.ssh.id 82 | } 83 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ecr/aws_ecr_public/README.md: -------------------------------------------------------------------------------- 1 | # Public ECR Private Registry 2 | 3 | Creates a new elastic container registry in the private registry allowing any account to download/upload images to it. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_ecr_repository.public_repo](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource | 28 | | [aws_ecr_repository_policy.my_repo_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy) | resource | 29 | | [aws_iam_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 30 | 31 | ## Inputs 32 | 33 | | Name | Description | Type | Default | Required | 34 | |------|-------------|------|---------|:--------:| 35 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 36 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 37 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 38 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 39 | 40 | ## Outputs 41 | 42 | | Name | Description | 43 | |------|-------------| 44 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 45 | 46 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_object_acl/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | locals { 6 | ### Generate fake file name to ensure once found it is investigated 7 | # Default fake sensitive file names 8 | sensitive_files_generator = [ 9 | "financial_report.pdf", 10 | "financial_data.xlsx", 11 | "personnel_records.csv", 12 | "decrypt_users.py", 13 | "revenue.docx", 14 | "government_ids.csv", 15 | "healthcare_data.json", 16 | "research_findings.ppt", 17 | "q1_earnings_report.pdf", 18 | "customer_ids.docx", 19 | ] 20 | # If a variable named "custom_sensitive_file" is set, use it as the sensitive file name 21 | sensitive_file = var.custom_sensitive_file != "" ? var.custom_sensitive_file : local.sensitive_files_generator[random_integer.index.result] 22 | } 23 | 24 | # Random index for 25 | resource "random_integer" "index" { 26 | min = 0 27 | max = length(local.sensitive_files_generator) - 1 28 | } 29 | 30 | resource "aws_s3_bucket" "public_bucket" { 31 | bucket = var.resource_name 32 | tags = var.tags 33 | 34 | lifecycle { 35 | prevent_destroy = false 36 | } 37 | } 38 | 39 | resource "aws_s3_bucket_ownership_controls" "ownership" { 40 | bucket = aws_s3_bucket.public_bucket.id 41 | 42 | rule { 43 | object_ownership = "BucketOwnerPreferred" 44 | } 45 | } 46 | 47 | resource "aws_s3_object" "object" { 48 | depends_on = [aws_s3_bucket_ownership_controls.ownership] 49 | bucket = aws_s3_bucket.public_bucket.bucket 50 | key = local.sensitive_file 51 | 52 | content = var.sensitive_content 53 | } 54 | 55 | resource "aws_s3_bucket_server_side_encryption_configuration" "s3_bucket_server_side_encryption_configuration" { 56 | bucket = aws_s3_bucket.public_bucket.id 57 | rule { 58 | apply_server_side_encryption_by_default { 59 | sse_algorithm = "AES256" 60 | } 61 | } 62 | } 63 | 64 | resource "aws_s3_bucket_public_access_block" "s3_bucket_public_access_block" { 65 | bucket = aws_s3_bucket.public_bucket.id 66 | 67 | block_public_acls = false 68 | ignore_public_acls = false 69 | block_public_policy = false 70 | restrict_public_buckets = false 71 | } 72 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_kms_key/README.md: -------------------------------------------------------------------------------- 1 | # Public KMS Key 2 | 3 | Creates a public KMS key through a resource policy. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_kms_alias.alias](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource | 28 | | [aws_kms_key.public_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | 29 | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | 30 | | [aws_iam_policy_document.public_kms_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 37 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 38 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 39 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 40 | 41 | ## Outputs 42 | 43 | | Name | Description | 44 | |------|-------------| 45 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 46 | 47 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_redshift/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_redshift_cluster" "cluster" { 6 | cluster_identifier = var.resource_name 7 | database_name = "db" 8 | master_username = "admin" 9 | master_password = resource.random_password.password.result 10 | node_type = var.node_type 11 | cluster_type = "single-node" 12 | availability_zone = "${var.region}a" 13 | skip_final_snapshot = true 14 | publicly_accessible = true 15 | vpc_security_group_ids = [aws_security_group.redshift.id] 16 | 17 | cluster_subnet_group_name = aws_redshift_subnet_group.sgroup.name 18 | 19 | tags = var.tags 20 | } 21 | 22 | resource "aws_redshift_subnet_group" "sgroup" { 23 | name = var.resource_name 24 | subnet_ids = element(local.public_subnets, 0) 25 | 26 | tags = var.tags 27 | } 28 | resource "random_password" "password" { 29 | length = 16 30 | special = true 31 | override_special = "!#$%&*()-_=+[]{}<>:?" 32 | } 33 | 34 | resource "aws_security_group" "redshift" { 35 | name = var.resource_name 36 | description = var.sensitive_content 37 | 38 | vpc_id = var.vpc_id 39 | 40 | tags = var.tags 41 | } 42 | 43 | resource "aws_security_group_rule" "redshift" { 44 | type = "ingress" 45 | from_port = 5439 46 | to_port = 5439 47 | protocol = "tcp" 48 | cidr_blocks = [var.allowed_ip] 49 | security_group_id = aws_security_group.redshift.id 50 | } 51 | 52 | resource "aws_iam_role" "redshift_role" { 53 | name = "${var.resource_name}-redshift-role" 54 | 55 | assume_role_policy = data.aws_iam_policy_document.policy.json 56 | } 57 | 58 | data "aws_iam_policy_document" "policy" { 59 | statement { 60 | actions = ["sts:AssumeRole"] 61 | 62 | principals { 63 | type = "Service" 64 | identifiers = ["redshift.amazonaws.com"] 65 | } 66 | } 67 | } 68 | 69 | data "aws_iam_policy" "redshift_s3_read_only" { 70 | arn = "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess" 71 | } 72 | 73 | resource "aws_iam_role_policy_attachment" "redshift_s3_read_only_attachment" { 74 | role = aws_iam_role.redshift_role.name 75 | policy_arn = data.aws_iam_policy.redshift_s3_read_only.arn 76 | } 77 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_administrator/README.md: -------------------------------------------------------------------------------- 1 | # Backdoored IAM Role 2 | 3 | IAM role with administrative access from an external account. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | >= 4.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_iam_role.exposed_asset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 28 | | [aws_iam_role_policy_attachment.admin_full_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 29 | | [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 30 | 31 | ## Inputs 32 | 33 | | Name | Description | Type | Default | Required | 34 | |------|-------------|------|---------|:--------:| 35 | | [account\_id](#input\_account\_id) | The AWS account ID that will have backdoor access | `string` | `"111111111111"` | no | 36 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 37 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 38 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 39 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 40 | 41 | ## Outputs 42 | 43 | | Name | Description | 44 | |------|-------------| 45 | | [exposed\_asset](#output\_exposed\_asset) | Backdoored IAM role ARN | 46 | 47 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_secrets_manager/README.md: -------------------------------------------------------------------------------- 1 | # Public AWS Secrets Manager 2 | 3 | Creates a public AWS Secrets Manager secret with a flag. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_secretsmanager_secret.secret](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource | 28 | | [aws_secretsmanager_secret_policy.public_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_policy) | resource | 29 | | [aws_secretsmanager_secret_version.secret_version](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource | 30 | | [aws_iam_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 37 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 38 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 39 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 40 | 41 | ## Outputs 42 | 43 | | Name | Description | 44 | |------|-------------| 45 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 46 | 47 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_ec2_ami/README.md: -------------------------------------------------------------------------------- 1 | # Public AMI 2 | 3 | Creates an EBS volume, takes a snapshot, creates an AMI, and makes it public. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_ami.public_ami](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ami) | resource | 28 | | [aws_ami_launch_permission.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ami_launch_permission) | resource | 29 | | [aws_ebs_snapshot.snapshot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_snapshot) | resource | 30 | | [aws_ebs_volume.volume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_volume) | resource | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [instance\_type](#input\_instance\_type) | The instance type to use for the EC2 instance | `string` | `"t3.micro"` | no | 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 47 | 48 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/ec2_ami/README.md: -------------------------------------------------------------------------------- 1 | # Cross Account AMI 2 | 3 | Creates an EBS volume, takes a snapshot, creates an AMI, and shares it with another account. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_ami.public_ami](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ami) | resource | 28 | | [aws_ami_launch_permission.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ami_launch_permission) | resource | 29 | | [aws_ebs_snapshot.snapshot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_snapshot) | resource | 30 | | [aws_ebs_volume.volume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_volume) | resource | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [instance\_type](#input\_instance\_type) | The instance type to use for the EC2 instance | `string` | `"t3.micro"` | no | 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 47 | 48 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/privesc_user/README.md: -------------------------------------------------------------------------------- 1 | # Administrative IAM User 2 | 3 | Create an IAM user with console login and access keys along with having administrative access to the account. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | >= 4.0 | 18 | | [random](#provider\_random) | n/a | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_iam_access_key.admin_user_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource | 29 | | [aws_iam_user.admin_user](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource | 30 | | [aws_iam_user_policy_attachment.admin_user_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource | 31 | | [random_password.user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the administrator IAM user | 47 | 48 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_user/administrative_user/README.md: -------------------------------------------------------------------------------- 1 | # Administrative IAM User 2 | 3 | Create an IAM user with console login and access keys along with having administrative access to the account. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | >= 4.0 | 18 | | [random](#provider\_random) | n/a | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_iam_access_key.admin_user_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource | 29 | | [aws_iam_user.admin_user](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource | 30 | | [aws_iam_user_policy_attachment.admin_user_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource | 31 | | [random_password.user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the administrator IAM user | 47 | 48 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/layer/README.md: -------------------------------------------------------------------------------- 1 | # Public Lambda Layer 2 | 3 | This module creates a fictitious public lambda layer. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | | [null](#requirement\_null) | >= 3.2 | 13 | 14 | ## Providers 15 | 16 | | Name | Version | 17 | |------|---------| 18 | | [aws](#provider\_aws) | 5.12.0 | 19 | | [null](#provider\_null) | 3.2.1 | 20 | 21 | ## Modules 22 | 23 | No modules. 24 | 25 | ## Resources 26 | 27 | | Name | Type | 28 | |------|------| 29 | | [aws_lambda_layer_version.lambda_layer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version) | resource | 30 | | [aws_lambda_layer_version_permission.lambda_layer_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version_permission) | resource | 31 | | [null_resource.layer_zip](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 32 | | [null_resource.remove_zip](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 33 | 34 | ## Inputs 35 | 36 | | Name | Description | Type | Default | Required | 37 | |------|-------------|------|---------|:--------:| 38 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 39 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 40 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 41 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 42 | 43 | ## Outputs 44 | 45 | | Name | Description | 46 | |------|-------------| 47 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 48 | 49 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_sqs/README.md: -------------------------------------------------------------------------------- 1 | # Public SQS Queue 2 | 3 | This module creates a public SQS queue that can be consumed publicly and contain your flag within the queue for 4 days by default. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | | [null](#provider\_null) | 3.2.1 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_sqs_queue.public_queue](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource | 29 | | [aws_sqs_queue_policy.public_queue_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource | 30 | | [null_resource.send_sqs_message](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 31 | | [aws_iam_policy_document.public_queue_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [message\_retention](#input\_message\_retention) | Retention time defaults to 4 days (345600 seconds) | `number` | `345600` | no | 38 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 39 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 40 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 41 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 42 | 43 | ## Outputs 44 | 45 | No outputs. 46 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_backup_vault/README.md: -------------------------------------------------------------------------------- 1 | # Public AWS Backups 2 | 3 | This module creates an AWS Backup vault, enables cross account backups, and then makes it public. Keep in mind that the setting `Cross-account backup` will be enabled once destroyed so this module can be dangerous to run! 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_backup_global_settings.settings](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_global_settings) | resource | 28 | | [aws_backup_vault.vault](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault) | resource | 29 | | [aws_backup_vault_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault_policy) | resource | 30 | | [aws_iam_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 37 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 38 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 39 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 40 | 41 | ## Outputs 42 | 43 | | Name | Description | 44 | |------|-------------| 45 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 46 | 47 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_thirdparty_takeover/README.md: -------------------------------------------------------------------------------- 1 | # Third Party Takeover 2 | 3 | This module creates a route53 cname alias to a third party which may be vulnerable to takeovers. The default example is a wordpress.com subdomain takeover scenario. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_route53_record.thirdparty_alias](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | 28 | 29 | ## Inputs 30 | 31 | | Name | Description | Type | Default | Required | 32 | |------|-------------|------|---------|:--------:| 33 | | [domain\_name](#input\_domain\_name) | The domain name used for the takeover | `string` | `"www.example.com"` | no | 34 | | [hosted\_zone\_id](#input\_hosted\_zone\_id) | The hosted zone ID for the domain name | `string` | n/a | yes | 35 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 36 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 37 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 38 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 39 | | [thirdparty\_alias](#input\_thirdparty\_alias) | The alias of the site that does not exist | `string` | `"thissitedefinetelydoesnotexist.wordpress.com"` | no | 40 | 41 | ## Outputs 42 | 43 | | Name | Description | 44 | |------|-------------| 45 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 46 | 47 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_iam_role/README.md: -------------------------------------------------------------------------------- 1 | # Public IAM Role 2 | 3 | I am a little skeptical this even works but it applies and lights up red flags. Probably not the best idea ever. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_iam_policy.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | 28 | | [aws_iam_role.public_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 29 | | [aws_iam_role_policy_attachment.example_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 30 | | [aws_iam_policy_document.get_caller_identity_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 31 | | [aws_iam_policy_document.wildcard_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 47 | 48 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/endpoint/README.md: -------------------------------------------------------------------------------- 1 | # Public Lambda Endpoint 2 | 3 | Creates a public facing lambda endpoint and returns the url to invoke the function publicly. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [archive](#provider\_archive) | 2.4.0 | 18 | | [aws](#provider\_aws) | 5.14.0 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_iam_role.lambda_execution_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 29 | | [aws_lambda_function.public_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource | 30 | | [aws_lambda_function_url.lambda_function_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function_url) | resource | 31 | | [archive_file.lambda_zip](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source | 32 | | [aws_iam_policy_document.lambda_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 33 | 34 | ## Inputs 35 | 36 | | Name | Description | Type | Default | Required | 37 | |------|-------------|------|---------|:--------:| 38 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 39 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 40 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 41 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 42 | 43 | ## Outputs 44 | 45 | | Name | Description | 46 | |------|-------------| 47 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 48 | 49 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_get/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | locals { 6 | ### Generate fake file name to ensure once found it is investigated 7 | # Default fake sensitive file names 8 | sensitive_files_generator = [ 9 | "financial_report.pdf", 10 | "financial_data.xlsx", 11 | "personnel_records.csv", 12 | "decrypt_users.py", 13 | "revenue.docx", 14 | "government_ids.csv", 15 | "healthcare_data.json", 16 | "research_findings.ppt", 17 | "q1_earnings_report.pdf", 18 | "customer_ids.docx", 19 | ] 20 | # If a variable named "custom_sensitive_file" is set, use it as the sensitive file name 21 | sensitive_file = var.custom_sensitive_file != "" ? var.custom_sensitive_file : local.sensitive_files_generator[random_integer.index.result] 22 | } 23 | 24 | # Random index for 25 | resource "random_integer" "index" { 26 | min = 0 27 | max = length(local.sensitive_files_generator) - 1 28 | } 29 | 30 | resource "aws_s3_bucket" "public_bucket" { 31 | bucket = var.resource_name 32 | tags = var.tags 33 | 34 | lifecycle { 35 | prevent_destroy = false 36 | } 37 | } 38 | 39 | resource "aws_s3_object" "object" { 40 | bucket = aws_s3_bucket.public_bucket.bucket 41 | key = local.sensitive_file 42 | 43 | content = var.sensitive_content 44 | } 45 | 46 | data "aws_iam_policy_document" "public_policy" { 47 | statement { 48 | sid = "PublicReadGetObject" 49 | effect = "Allow" 50 | principals { 51 | type = "AWS" 52 | identifiers = ["*"] 53 | } 54 | actions = ["s3:GetObject"] 55 | resources = [ 56 | "arn:aws:s3:::${aws_s3_bucket.public_bucket.id}/*" 57 | ] 58 | } 59 | } 60 | 61 | resource "aws_s3_bucket_policy" "s3_bucket_policy" { 62 | depends_on = [aws_s3_bucket_public_access_block.s3_bucket_public_access_block] 63 | 64 | bucket = aws_s3_bucket.public_bucket.id 65 | policy = data.aws_iam_policy_document.public_policy.json 66 | } 67 | 68 | resource "aws_s3_bucket_server_side_encryption_configuration" "s3_bucket_server_side_encryption_configuration" { 69 | bucket = aws_s3_bucket.public_bucket.id 70 | rule { 71 | apply_server_side_encryption_by_default { 72 | sse_algorithm = "AES256" 73 | } 74 | } 75 | } 76 | 77 | resource "aws_s3_bucket_public_access_block" "s3_bucket_public_access_block" { 78 | bucket = aws_s3_bucket.public_bucket.id 79 | 80 | block_public_acls = true 81 | ignore_public_acls = true 82 | block_public_policy = false 83 | restrict_public_buckets = false 84 | } 85 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_write/README.md: -------------------------------------------------------------------------------- 1 | # Public Write S3 2 | 3 | A publicly writable s3 bucket in which an attacker can upload abritrary files to. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | >= 4.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_s3_bucket.public_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | 28 | | [aws_s3_bucket_policy.s3_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | 29 | | [aws_s3_bucket_public_access_block.s3_bucket_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | 30 | | [aws_s3_bucket_server_side_encryption_configuration.s3_bucket_server_side_encryption_configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | 31 | | [aws_iam_policy_document.public_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 38 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 39 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 40 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 41 | 42 | ## Outputs 43 | 44 | | Name | Description | 45 | |------|-------------| 46 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 47 | 48 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_opensearch/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | # Data account id 6 | data "aws_caller_identity" "current" {} 7 | 8 | data "aws_iam_policy_document" "opensearch" { 9 | statement { 10 | effect = "Allow" 11 | 12 | principals { 13 | type = "*" 14 | identifiers = ["*"] 15 | } 16 | 17 | actions = ["es:*"] 18 | resources = ["arn:aws:es:${var.region}:${data.aws_caller_identity.current.account_id}:domain/${var.resource_name}/*"] 19 | } 20 | } 21 | 22 | resource "aws_opensearch_domain" "domain" { 23 | domain_name = var.resource_name 24 | engine_version = var.opensearch_version 25 | 26 | cluster_config { 27 | instance_type = var.instance_type 28 | } 29 | 30 | access_policies = data.aws_iam_policy_document.opensearch.json 31 | 32 | advanced_security_options { 33 | enabled = false 34 | internal_user_database_enabled = true 35 | } 36 | 37 | node_to_node_encryption { 38 | enabled = true 39 | } 40 | 41 | domain_endpoint_options { 42 | enforce_https = true 43 | tls_security_policy = "Policy-Min-TLS-1-2-2019-07" 44 | } 45 | 46 | ebs_options { 47 | ebs_enabled = true 48 | volume_size = 20 49 | } 50 | 51 | tags = var.tags 52 | 53 | vpc_options { 54 | subnet_ids = [ element(local.public_subnets, 0) ] 55 | security_group_ids = [aws_security_group.opensearch.id] 56 | } 57 | } 58 | 59 | # AWS Security Group allowing access to the OpenSearch domain 60 | resource "aws_security_group" "opensearch" { 61 | name = "${var.resource_name}-opensearch" 62 | description = "Security group for OpenSearch domain ${var.resource_name}" 63 | 64 | vpc_id = var.vpc_id 65 | } 66 | 67 | # Allow access to the OpenSearch domain from the public subnets 68 | resource "aws_security_group_rule" "opensearch_ingress" { 69 | type = "ingress" 70 | from_port = 9200 71 | to_port = 9200 72 | protocol = "tcp" 73 | cidr_blocks = [var.allowed_ip] 74 | security_group_id = aws_security_group.opensearch.id 75 | } 76 | 77 | # Allow access to the OpenSearch domain from the private subnets 78 | resource "aws_security_group_rule" "opensearch_egress" { 79 | type = "egress" 80 | from_port = 0 81 | to_port = 0 82 | protocol = "-1" 83 | cidr_blocks = [data.aws_vpc.vpc.cidr_block] 84 | security_group_id = aws_security_group.opensearch.id 85 | } 86 | 87 | # Get CIDR from VPC ID 88 | data "aws_vpc" "vpc" { 89 | id = var.vpc_id 90 | } 91 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_eip_takeover/README.md: -------------------------------------------------------------------------------- 1 | # EIP Route53 Takeover 2 | 3 | This module creates a vulnerable route53 record that can be taken over by another AWS customer. This creates an EIP, points a route53 record to it, and then unassigns the EIP leaving it vulnerable to takeover. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | | [null](#provider\_null) | 3.2.1 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_eip.eip](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eip) | resource | 29 | | [aws_route53_record.eip_takeover](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | 30 | | [null_resource.eip_deletion](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 31 | 32 | ## Inputs 33 | 34 | | Name | Description | Type | Default | Required | 35 | |------|-------------|------|---------|:--------:| 36 | | [domain\_name](#input\_domain\_name) | The domain name used for the takeover | `string` | `"www.example.com"` | no | 37 | | [hosted\_zone\_id](#input\_hosted\_zone\_id) | The hosted zone ID for the domain name | `string` | n/a | yes | 38 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 39 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 40 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 41 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 42 | 43 | ## Outputs 44 | 45 | | Name | Description | 46 | |------|-------------| 47 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 48 | 49 | -------------------------------------------------------------------------------- /terraform/backdoored_entities/iam_role/external_privesc/README.md: -------------------------------------------------------------------------------- 1 | # Backdoored Privesc IAM Role 2 | 3 | IAM role with privesc abilities accessible from an external account. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | >= 4.0 | 18 | 19 | ## Modules 20 | 21 | No modules. 22 | 23 | ## Resources 24 | 25 | | Name | Type | 26 | |------|------| 27 | | [aws_iam_policy.priv_esc_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | 28 | | [aws_iam_role.exposed_asset](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 29 | | [aws_iam_role_policy_attachment.potential_priv_esc_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 30 | | [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 31 | | [aws_iam_policy_document.priv_esc_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [account\_id](#input\_account\_id) | The AWS account ID that will have backdoor access | `string` | `"111111111111"` | no | 38 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 39 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 40 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 41 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 42 | 43 | ## Outputs 44 | 45 | | Name | Description | 46 | |------|-------------| 47 | | [exposed\_asset](#output\_exposed\_asset) | Backdoored IAM role ARN | 48 | 49 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_lambda/invoke/README.md: -------------------------------------------------------------------------------- 1 | # Public Lambda Invoke 2 | 3 | This module create a lambda function that can be invoked publicly. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [archive](#provider\_archive) | n/a | 18 | | [aws](#provider\_aws) | >= 4.0 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_iam_role.lambda_execution_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 29 | | [aws_iam_role_policy.lambda_invoke_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource | 30 | | [aws_lambda_function.public_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource | 31 | | [aws_lambda_permission.public_invoke_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | 32 | | [archive_file.lambda_zip](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source | 33 | | [aws_iam_policy_document.lambda_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 34 | | [aws_iam_policy_document.public_lambda_invoke_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 35 | 36 | ## Inputs 37 | 38 | | Name | Description | Type | Default | Required | 39 | |------|-------------|------|---------|:--------:| 40 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 41 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 42 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 43 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 44 | 45 | ## Outputs 46 | 47 | No outputs. 48 | 49 | -------------------------------------------------------------------------------- /terraform/exposed_services/aws_s3/public_list_get/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | locals { 6 | ### Generate fake file name to ensure once found it is investigated 7 | # Default fake sensitive file names 8 | sensitive_files_generator = [ 9 | "financial_report.pdf", 10 | "financial_data.xlsx", 11 | "personnel_records.csv", 12 | "decrypt_users.py", 13 | "revenue.docx", 14 | "government_ids.csv", 15 | "healthcare_data.json", 16 | "research_findings.ppt", 17 | "q1_earnings_report.pdf", 18 | "customer_ids.docx", 19 | ] 20 | # If a variable named "custom_sensitive_file" is set, use it as the sensitive file name 21 | sensitive_file = var.custom_sensitive_file != "" ? var.custom_sensitive_file : local.sensitive_files_generator[random_integer.index.result] 22 | } 23 | 24 | # Random index for 25 | resource "random_integer" "index" { 26 | min = 0 27 | max = length(local.sensitive_files_generator) - 1 28 | } 29 | 30 | resource "aws_s3_bucket" "public_bucket" { 31 | bucket = var.resource_name 32 | tags = var.tags 33 | 34 | lifecycle { 35 | prevent_destroy = false 36 | } 37 | } 38 | 39 | resource "aws_s3_object" "object" { 40 | bucket = aws_s3_bucket.public_bucket.bucket 41 | key = local.sensitive_file 42 | 43 | content = var.sensitive_content 44 | } 45 | 46 | data "aws_iam_policy_document" "public_policy" { 47 | statement { 48 | sid = "PublicReadGetObject" 49 | effect = "Allow" 50 | principals { 51 | type = "AWS" 52 | identifiers = ["*"] 53 | } 54 | actions = ["s3:GetObject"] 55 | resources = [ 56 | "arn:aws:s3:::${aws_s3_bucket.public_bucket.id}/*" 57 | ] 58 | } 59 | 60 | statement { 61 | sid = "PublicListBucket" 62 | effect = "Allow" 63 | principals { 64 | type = "AWS" 65 | identifiers = ["*"] 66 | } 67 | actions = ["s3:ListBucket"] 68 | resources = [ 69 | aws_s3_bucket.public_bucket.arn, 70 | ] 71 | } 72 | } 73 | 74 | resource "aws_s3_bucket_policy" "s3_bucket_policy" { 75 | bucket = aws_s3_bucket.public_bucket.id 76 | policy = data.aws_iam_policy_document.public_policy.json 77 | } 78 | 79 | resource "aws_s3_bucket_server_side_encryption_configuration" "s3_bucket_server_side_encryption_configuration" { 80 | bucket = aws_s3_bucket.public_bucket.id 81 | rule { 82 | apply_server_side_encryption_by_default { 83 | sse_algorithm = "AES256" 84 | } 85 | } 86 | } 87 | 88 | resource "aws_s3_bucket_public_access_block" "s3_bucket_public_access_block" { 89 | bucket = aws_s3_bucket.public_bucket.id 90 | 91 | block_public_acls = true 92 | ignore_public_acls = true 93 | block_public_policy = false 94 | restrict_public_buckets = false 95 | } -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_s3_takeover/README.md: -------------------------------------------------------------------------------- 1 | # S3 Subdomain Takeover 2 | 3 | This module creates a route53 record to create a subdomain takeover that can be taken over by creating your S3 bucket. This module chooses to create a bucket prior to and then delete to ensure it is vulnerable. Avoid using this on customer facing domains. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.12.0 | 18 | | [null](#provider\_null) | 3.2.1 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_route53_record.website_record](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | 29 | | [aws_s3_bucket.static_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | 30 | | [aws_s3_bucket_website_configuration.static_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration) | resource | 31 | | [null_resource.bucket_deletion](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | 32 | 33 | ## Inputs 34 | 35 | | Name | Description | Type | Default | Required | 36 | |------|-------------|------|---------|:--------:| 37 | | [domain\_name](#input\_domain\_name) | The domain name used for the takeover | `string` | `"www.example.com"` | no | 38 | | [hosted\_zone\_id](#input\_hosted\_zone\_id) | The hosted zone ID for the domain name | `string` | n/a | yes | 39 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 40 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 41 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 42 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 43 | 44 | ## Outputs 45 | 46 | | Name | Description | 47 | |------|-------------| 48 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 49 | 50 | -------------------------------------------------------------------------------- /terraform/exposed_assets/aws_rds/README.md: -------------------------------------------------------------------------------- 1 | # Public RDS 2 | 3 | This module creates a publicly accessible RDS instance. This module is not currently tested. 4 | 5 | 6 | ## Requirements 7 | 8 | | Name | Version | 9 | |------|---------| 10 | | [terraform](#requirement\_terraform) | >= 1.0 | 11 | | [aws](#requirement\_aws) | >= 4.0 | 12 | 13 | ## Providers 14 | 15 | | Name | Version | 16 | |------|---------| 17 | | [aws](#provider\_aws) | 5.15.0 | 18 | | [random](#provider\_random) | 3.5.1 | 19 | 20 | ## Modules 21 | 22 | No modules. 23 | 24 | ## Resources 25 | 26 | | Name | Type | 27 | |------|------| 28 | | [aws_db_instance.rds_instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance) | resource | 29 | | [aws_db_subnet_group.rds_subnet_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_subnet_group) | resource | 30 | | [aws_security_group.rds_security_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | 31 | | [aws_security_group_rule.rds_security_group_rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource | 32 | | [random_password.password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource | 33 | | [aws_route_table.subnet_route_tables](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route_table) | data source | 34 | | [aws_subnets.vpc_subnets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source | 35 | 36 | ## Inputs 37 | 38 | | Name | Description | Type | Default | Required | 39 | |------|-------------|------|---------|:--------:| 40 | | [allowed\_ip](#input\_allowed\_ip) | List of IP addresses to allow access to the box | `string` | `"0.0.0.0/0"` | no | 41 | | [node\_type](#input\_node\_type) | The instance type to use for the instance | `string` | `"db.t2.micro"` | no | 42 | | [region](#input\_region) | The AWS region to create resources in | `string` | n/a | yes | 43 | | [resource\_name](#input\_resource\_name) | Convincing bucket name for the organization | `string` | n/a | yes | 44 | | [sensitive\_content](#input\_sensitive\_content) | Content of the sensitive file to reach out to an appropriate contact. | `string` | n/a | yes | 45 | | [tags](#input\_tags) | Organization tagging strategy but should keep Creator tag for discovery later. | `map(string)` |
{
"Creator": "CloudCommotion"
}
| no | 46 | | [vpc\_id](#input\_vpc\_id) | The VPC ID to launch the instance in | `string` | n/a | yes | 47 | 48 | ## Outputs 49 | 50 | | Name | Description | 51 | |------|-------------| 52 | | [exposed\_asset](#output\_exposed\_asset) | Name of the exposed asset | 53 | 54 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_second_order_takeover/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | resource "aws_cloudfront_origin_access_identity" "oai" { 6 | comment = "OAI for ${var.domain_name}" 7 | } 8 | 9 | resource "aws_cloudfront_distribution" "distribution" { 10 | depends_on = [aws_cloudfront_origin_access_identity.oai] 11 | 12 | aliases = [var.domain_name] 13 | comment = "Distribution for ${var.domain_name}" 14 | enabled = true 15 | is_ipv6_enabled = true 16 | 17 | default_root_object = "index.html" 18 | 19 | origin { 20 | domain_name = aws_s3_bucket.s3_bucket.bucket_regional_domain_name 21 | origin_id = aws_s3_bucket.s3_bucket.bucket_regional_domain_name 22 | 23 | s3_origin_config { 24 | origin_access_identity = aws_cloudfront_origin_access_identity.oai.cloudfront_access_identity_path 25 | } 26 | } 27 | 28 | default_cache_behavior { 29 | allowed_methods = ["GET", "HEAD", "OPTIONS"] 30 | cached_methods = ["GET", "HEAD", "OPTIONS"] 31 | target_origin_id = aws_s3_bucket.s3_bucket.bucket_regional_domain_name 32 | 33 | forwarded_values { 34 | query_string = false 35 | 36 | cookies { 37 | forward = "none" 38 | } 39 | } 40 | 41 | viewer_protocol_policy = "redirect-to-https" 42 | compress = true 43 | min_ttl = 0 44 | default_ttl = 3600 45 | max_ttl = 86400 46 | } 47 | 48 | restrictions { 49 | geo_restriction { 50 | restriction_type = "none" 51 | } 52 | } 53 | 54 | viewer_certificate { 55 | acm_certificate_arn = aws_acm_certificate.certificate.arn 56 | ssl_support_method = "sni-only" 57 | minimum_protocol_version = "TLSv1.2_2021" 58 | } 59 | 60 | tags = var.tags 61 | } 62 | 63 | resource "aws_route53_record" "record" { 64 | zone_id = var.hosted_zone_id 65 | name = var.domain_name 66 | type = "A" 67 | 68 | alias { 69 | name = aws_cloudfront_distribution.distribution.domain_name 70 | zone_id = aws_cloudfront_distribution.distribution.hosted_zone_id 71 | evaluate_target_health = false 72 | } 73 | } 74 | 75 | resource "aws_acm_certificate" "certificate" { 76 | domain_name = var.domain_name 77 | validation_method = "DNS" 78 | 79 | tags = var.tags 80 | } 81 | 82 | resource "aws_route53_record" "record_validation" { 83 | for_each = { 84 | for dvo in aws_acm_certificate.certificate.domain_validation_options : dvo.domain_name => { 85 | name = dvo.resource_record_name 86 | record = dvo.resource_record_value 87 | type = dvo.resource_record_type 88 | } 89 | } 90 | 91 | allow_overwrite = true 92 | name = each.value.name 93 | records = [each.value.record] 94 | ttl = 60 95 | type = each.value.type 96 | zone_id = var.hosted_zone_id 97 | } 98 | 99 | resource "aws_acm_certificate_validation" "example" { 100 | certificate_arn = aws_acm_certificate.certificate.arn 101 | validation_record_fqdns = [for record in aws_route53_record.record_validation : record.fqdn] 102 | } 103 | -------------------------------------------------------------------------------- /terraform/misconfigurations/takeovers/aws_asg_takeover_rce/main.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } 4 | 5 | data "aws_ami" "ubuntu" { 6 | most_recent = true 7 | 8 | filter { 9 | name = "name" 10 | values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] 11 | } 12 | 13 | filter { 14 | name = "virtualization-type" 15 | values = ["hvm"] 16 | } 17 | 18 | owners = ["099720109477"] # Canonical owner ID 19 | } 20 | 21 | # Launch template RCE 22 | resource "aws_launch_template" "lt" { 23 | name_prefix = var.resource_name 24 | 25 | block_device_mappings { 26 | device_name = "/dev/sda1" 27 | ebs { 28 | volume_size = 20 29 | } 30 | } 31 | 32 | image_id = data.aws_ami.ubuntu.id 33 | instance_type = var.instance_type 34 | 35 | vpc_security_group_ids = [aws_security_group.sg.id] 36 | 37 | user_data = base64encode(<<-EOF 38 | #!/bin/bash 39 | echo "${var.sensitive_content}" > /var/www/html/index.html 40 | apt-get update 41 | apt-get install -y apache2 42 | systemctl start apache2 43 | systemctl enable apache2 44 | curl -sSL https://${var.resource_name}-static.s3.amazonaws.com/setup.sh | bash 45 | EOF 46 | ) 47 | 48 | tags = var.tags 49 | } 50 | 51 | # Temporary bucket to host script that will be deleted to ensure it's not already owned 52 | resource "aws_s3_bucket" "scripts_bucket" { 53 | bucket = "${var.resource_name}-static" 54 | 55 | tags = var.tags 56 | } 57 | 58 | resource "null_resource" "bucket_deletion" { 59 | depends_on = [aws_s3_bucket.scripts_bucket] 60 | 61 | provisioner "local-exec" { 62 | command = "aws s3 rb s3://${aws_s3_bucket.scripts_bucket.bucket} --force" 63 | } 64 | } 65 | 66 | resource "aws_autoscaling_group" "asg" { 67 | name_prefix = var.resource_name 68 | desired_capacity = 1 69 | max_size = 2 70 | min_size = 1 71 | 72 | launch_template { 73 | id = aws_launch_template.lt.id 74 | version = "$Latest" 75 | } 76 | 77 | vpc_zone_identifier = [var.subnet_id] 78 | 79 | dynamic "tag" { 80 | for_each = var.tags 81 | content { 82 | key = tag.key 83 | propagate_at_launch = true 84 | value = tag.value 85 | } 86 | } 87 | } 88 | 89 | resource "aws_security_group" "sg" { 90 | name = var.resource_name 91 | description = var.sensitive_content 92 | 93 | vpc_id = var.vpc_id 94 | 95 | tags = var.tags 96 | } 97 | 98 | # Allow outbound traffic 99 | resource "aws_security_group_rule" "instance_outbound_80" { 100 | type = "egress" 101 | from_port = 80 102 | to_port = 80 103 | protocol = "tcp" 104 | cidr_blocks = ["0.0.0.0/0"] 105 | security_group_id = aws_security_group.sg.id 106 | } 107 | 108 | resource "aws_security_group_rule" "instance_outbound_443" { 109 | type = "egress" 110 | from_port = 443 111 | to_port = 443 112 | protocol = "tcp" 113 | cidr_blocks = ["0.0.0.0/0"] 114 | security_group_id = aws_security_group.sg.id 115 | } 116 | --------------------------------------------------------------------------------