Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secrets in the cloud #189

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

j0eblow
Copy link
Contributor

@j0eblow j0eblow commented May 9, 2023

have fun

Copy link
Contributor

@jdearmas jdearmas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm blocked on completing the scenario. Can you add more detail/commands to the cheat sheet?

@@ -0,0 +1,13 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a single comment at the top of the file that explains what this file does in plain English?

For example:
# This 'manifest.yml' file provides configuration variables for the Cloudgoat scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,2 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a single comment at the almost top of the file that explains what this file does in plain English?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary file for my scenario so I deleted it.

@@ -0,0 +1,51 @@
locals {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a single comment at the top of the file that explains what this file does in plain English?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

# This is a Terraform file that creates three resources:
# 1. An AWS DynamoDB Table
# 2. An AWS DynamoDB Entry (for the Access ID)
# 3. An AWS DynamoDB Entry (for the Secret Key)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,95 @@
data "aws_ami" "amazon_linux_2" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a single comment at the top of the file that explains what this file does in plain English?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

# This is a Terraform file that creates several AWS EC2 resources:
# 1. A Data Source for an AWS Amazon Machine Image.
# 2. A TLS Private Key Resource
# 3. An AWS Key Pair Resource
# 4. An AWS Instance Resource
# 5. An AWS Security Group Resource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,199 @@
resource "aws_iam_user" "low_priv_user" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a single comment at the top of the file that explains what this file does in plain English?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

# This Terraform file creates several resources for AWS Identity and Access Management (IAM):
# - An IAM User 
# - An IAM Access Key 
#
#   For AWS Simple Storage Service (S3):
#     - An IAM Policy 
#     - An IAM User Policy Attachment 
#
#   For AWS Lambda:
#     - An IAM Policy 
#     - An IAM User Policy Attachment 
#     - An IAM Role Policy
#
#   For AWS DynamoDB:
#     - An IAM Policy 
#     - An IAM Role
#     - An IAM Role Policy Attachment
#     - An IAM Instance Profile
#
#   For AWS Secrets Manager:
#     - An IAM User 
#     - An IAM Access Key 
#     - An IAM Role 
#     - An IAM User Policy 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

resource "aws_iam_instance_profile" "ec2_instance_profile" {
name = "EC2InstanceProfile"
role = aws_iam_role.ec2_dynamodb_role.name
resource "aws_iam_instance_profile" "dynamodb_instance_profile" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example comment from my initial review should be updated to reflect this change.

8. After enumerating the EC2 metadata service, the attacker decides to list available DynamoDB tables and discovers a table containing IAM user credentials specific to the scenario.
9. Utilizing the newly acquired IAM user credentials, the attacker retrieves the final secret from the Secrets Manager, successfully completing the scenario.

A cheat sheet for the scenario is available [here](./cheat_sheet.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the ^M?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, that's super weird. Might be related to terminal or some random key press I did. It can be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be fixed now.

@@ -142,3 +137,13 @@ vault kv put secret/tylers_seekrit value='TylerTantalizingTacosTangleToucans'
vault kv put secret/brads_seekrit value='BradBefriendsBouncingBlueberryBison'
export SSH_PRIVATE_KEY="${private_key}"
vault kv put secret/id_rsa value="$SSH_PRIVATE_KEY"

# Update MOTD with a hint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is MOTD?

Copy link
Contributor Author

@j0eblow j0eblow May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://en.wikipedia.org/wiki/Message_of_the_day - basically the message users see when they log on.

2. The attacker enumerates the web application and uncovers an admin page that prompts for an API key.
3. While examining the admin page's HTML comments, the attacker finds information about environment variables and a HashiCorp endpoint.
4. By enumerating the scenario's Lambda function, the attacker locates the web application's API key and uses it to obtain the HashiCorp vault token.
5. The attacker exploits the vault token to log in to the HashiCorp endpoint and acquires the id_rsa key, which grants SSH access to the EC2 instance hosting the web application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After starting the scenario and using the cheat sheet, I'm unable to identify the HashiCorp endpoint. Can you add the steps need to identify the HashiCorp endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated step 3 to clarify the port number and location of the endpoint.

3. While examining the admin page's HTML comments, the attacker finds information about environment variables and a HashiCorp endpoint.
4. By enumerating the scenario's Lambda function, the attacker locates the web application's API key and uses it to obtain the HashiCorp vault token.
5. The attacker exploits the vault token to log in to the HashiCorp endpoint and acquires the id_rsa key, which grants SSH access to the EC2 instance hosting the web application.
6. Intrigued by the login message, the attacker queries the EC2 metadata service and discovers that IMDSv2 is in use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the commands needed to perform these steps in the cheat sheet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we decided to skip this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some changes to the README walk through and the cheat sheet so they're more descriptive.

@j0eblow j0eblow requested a review from jdearmas May 24, 2023 09:35
Replaced [id] with [web_app_id]
Better word choice for step 5
Copy link
Contributor

@jdearmas jdearmas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new scenario works.

@@ -35,12 +35,12 @@ As an IAM user with limited privileges, the attacker initiates their journey by

1. As the IAM user "low-priv-user", the attacker explores the AWS environment, discovering an S3 bucket containing the URL to a web application hosted on an EC2 instance.
2. The attacker enumerates the web application and uncovers an admin page that prompts for an API key.
3. While examining the admin page's HTML comments, the attacker finds information about environment variables and a HashiCorp endpoint.
3. While examining the admin page's HTML comments, the attacker finds information about environment variables and a HashiCorp endpoint (located on port 8200 of the EC2 instance).
4. By enumerating the scenario's Lambda function, the attacker locates the web application's API key and uses it to obtain the HashiCorp vault token.
5. The attacker exploits the vault token to log in to the HashiCorp endpoint and acquires the id_rsa key, which grants SSH access to the EC2 instance hosting the web application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the link to where the user will need to download the vault command to the cheat sheet? https://developer.hashicorp.com/vault/downloads

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloading this tool might be tricky for Docker-only users (aka me). I'll look into how to get around it and add the steps here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to download and mount into the docker container this zip file (https://releases.hashicorp.com/vault/1.13.2/vault_1.13.2_linux_amd64.zip). I would add it as a note for docker-users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants