Code Monkey home page Code Monkey logo

cloudfox's Introduction

๐ŸฆŠ CloudFox ๐ŸฆŠ

CloudFox helps you gain situational awareness in unfamiliar cloud environments. Itโ€™s an open source command line tool created to help penetration testers and other offensive security professionals find exploitable attack paths in cloud infrastructure.

CloudFox helps you answer the following common questions (and many more):

  • What regions is this AWS account using and roughly how many resources are in the account?
  • What secrets are lurking in EC2 userdata or service specific environment variables?
  • What workloads have administrative permissions attached?
  • What actions/permissions does this [principal] have?
  • What role trusts are overly permissive or allow cross-account assumption?
  • What endpoints/hostnames/IPs can I attack from an external starting point (public internet)?
  • What endpoints/hostnames/IPs can I attack from an internal starting point (assumed breach within the VPC)?
  • What filesystems can I potentially mount from a compromised resource inside the VPC?

Demos, Examples, Walkthroughs

Intentionally Vulnerable Playground

Want to chat about CloudFox?

Join us on the RedSec discord server

Quick Start

CloudFox is modular (you can run one command at a time), but there is an aws all-checks command that will run the other aws commands for you with sane defaults:

cloudfox aws --profile [profile-name] all-checks

White Box Enumeration

CloudFox was designed to be executed by a principal with limited read-only permissions, but it's purpose is to help you find attack paths that can be exploited in simulated compromise scenarios (aka, objective based penetration testing).

Black Box Enumeration

CloudFox can be used with "found" credentials, similar to how you would use weirdAAL or enumerate-iam. Checks that fail, do so silently, so any data returned means your "found" creds have the access needed to retrieve it.

Documentation

For the full documentation please refer to our wiki.

Supported Cloud Providers

Provider CloudFox Commands
AWS 34
Azure 4
GCP 8
Kubernetes Support Planned

Install

Option 1: Download the latest binary release for your platform.

Option 2: If you use homebrew: brew install cloudfox

Option 3: Install Go, use go install github.com/BishopFox/cloudfox@latest to install from the remote source

Option 4: Developer mode:

Install Go, clone the CloudFox repository and compile from source

# git clone https://github.com/BishopFox/cloudfox.git
# cd ./cloudfox
# Make any changes necessary
# go build .
# ./cloudfox

Option 5: Testing a bug fix

git clone [email protected]:BishopFox/cloudfox.git
git checkout seth-dev 
go build .
./cloudfox [rest of the command options]

Prerequisites

AWS

  • AWS CLI installed
  • Supports AWS profiles, AWS environment variables, or metadata retrieval (on an ec2 instance)
    • To run commands on multiple profiles at once, you can specify the path to a file with a list of profile names separated by a new line using the -l flag or pass all stored profiles with the -a flag.
  • A principal with one recommended policies attached (described below)
  • Recommended attached policies: SecurityAudit + CloudFox custom policy

Additional policy notes (as of 09/2022):

Policy Notes
CloudFox custom policy Has a complete list of every permission cloudfox uses and nothing else
arn:aws:iam::aws:policy/SecurityAudit Covers most cloudfox checks but is missing newer services or permissions like apprunner:*, grafana:*, lambda:GetFunctionURL, lightsail:GetContainerServices
arn:aws:iam::aws:policy/job-function/ViewOnlyAccess Covers most cloudfox checks but is missing newer services or permissions like AppRunner:*, grafana:*, lambda:GetFunctionURL, lightsail:GetContainerServices - and is also missing iam:SimulatePrincipalPolicy.
arn:aws:iam::aws:policy/ReadOnlyAccess Only missing AppRunner, but also grants things like "s3:Get*" which can be overly permissive.
arn:aws:iam::aws:policy/AdministratorAccess This will work just fine with CloudFox, but if you were handed this level of access as a penetration tester, that should probably be a finding in itself :)

Azure

  • Viewer or similar permissions applied.

AWS Commands

Provider Command Name Description
AWS all-checks Run all of the other commands using reasonable defaults. You'll still want to check out the non-default options of each command, but this is a great place to start.
AWS access-keys Lists active access keys for all users. Useful for cross referencing a key you found with which in-scope account it belongs to.
AWS api-gw Lists API gateway endpoints and gives you custom curl commands including API tokens if they are stored in metadata.
AWS buckets Lists the buckets in the account and gives you handy commands for inspecting them further.
AWS cape Enumerates cross-account privilege escalation paths. Requires pmapper to be run first
AWS cloudformation Lists the cloudformation stacks in the account. Generates loot file with stack details, stack parameters, and stack output - look for secrets.
AWS codebuild Enumerate CodeBuild projects
AWS databases Enumerate RDS databases. Get a loot file with connection strings.
AWS ecr List the most recently pushed image URI from all repositories. Use the loot file to pull selected images down with docker/nerdctl for inspection.
AWS ecs-tasks List all ecs tasks. This returns a list of ecs tasks and associated cluster, task definition, container instance, launch type, and associated IAM principal.
AWS eks List all EKS clusters, see if they expose their endpoint publicly, and check the associated IAM roles attached to reach cluster or node group. Generates a loot file with the aws eks udpate-kubeconfig command needed to connect to each cluster.
AWS elastic-network-interfaces List all eni information. This returns a list of eni ID, type, external IP, private IP, VPCID, attached instance and a description.
AWS endpoints Enumerates endpoints from various services. Scan these endpoints from both an internal and external position to look for things that don't require authentication, are misconfigured, etc.
AWS env-vars Grabs the environment variables from services that have them (App Runner, ECS, Lambda, Lightsail containers, Sagemaker are supported. If you find a sensitive secret, use cloudfox iam-simulator AND pmapper to see who has access to them.
AWS filesystems Enumerate the EFS and FSx filesystems that you might be able to mount without creds (if you have the right network access). For example, this is useful when you have ec:RunInstance but not iam:PassRole.
AWS iam-simulator Like pmapper, but uses the IAM policy simulator. It uses AWS's evaluation logic, but notably, it doesn't consider transitive access via privesc, which is why you should also always also use pmapper.
AWS instances Enumerates useful information for EC2 Instances in all regions like name, public/private IPs, and instance profiles. Generates loot files you can feed to nmap and other tools for service enumeration.
AWS inventory Gain a rough understanding of size of the account and preferred regions.
AWS lambda Lists the lambda functions in the account, including which one's have admin roles attached. Also gives you handy commands for downloading each function.
AWS network-ports Enumerates AWS services that are potentially exposing a network service. The security groups and the network ACLs are parsed for each resource to determine what ports are potentially exposed.
AWS orgs Enumerate accounts in an organization
AWS outbound-assumed-roles List the roles that have been assumed by principals in this account. This is an excellent way to find outbound attack paths that lead into other accounts.
AWS permissions Enumerates IAM permissions associated with all users and roles. Grep this output to figure out what permissions a particular principal has rather than logging into the AWS console and painstakingly expanding each policy attached to the principal you are investigating.
AWS pmapper Looks for pmapper data stored on the local filesystem, in the locations defined here. If pmapper data has been found (you already ran pmapper graph create), then this command will use this data to build a graph in cloudfox memory let you know who can privesc to admin.
AWS principals Enumerates IAM users and Roles so you have the data at your fingertips.
AWS ram List all resources in this account that are shared with other accounts, or resources from other accounts that are shared with this account. Useful for cross-account attack paths.
AWS resource-trusts Looks through multiple services that support resource policies and helps you find any overly permissive resource trusts.
AWS role-trusts Enumerates IAM role trust policies so you can look for overly permissive role trusts or find roles that trust a specific service.
AWS route53 Enumerate all records from all route53 managed zones. Use this for application and service enumeration.
AWS secrets List secrets from SecretsManager and SSM. Look for interesting secrets in the list and then see who has access to them using use cloudfox iam-simulator and/or pmapper.
AWS sns This command enumerates all of the sns topics and gives you the commands to subscribe to a topic or send messages to a topic (if you have the permissions needed). This command only deals with topics, and not the SMS functionality. This command also attempts to summarize topic resource policies if they exist.
AWS sqs This command enumerates all of the sqs queues and gives you the commands to receive messages from a queue and send messages to a queue (if you have the permissions needed). This command also attempts to summarize queue resource policies if they exist.
AWS tags List all resources with tags, and all of the tags. This can be used similar to inventory as another method to identify what types of resources exist in an account.
AWS workloads List all of the compute workloads and what role they have. Tells you if any of the roles are admin (bad) and if you have pmapper data locally, it will tell you if any of the roles can privesc to admin (also bad)
AWS ds List all of the AWS-managed directories and their attributes. Also summarizes the current trusts with their directions and types.

Azure Commands

Provider Command Name Description
Azure whoami Displays information on the tenant, subscriptions and resource groups available to your current Azure CLI session. This is useful to provide situation awareness on what tenant and subscription IDs to use with the other sub commands.
Azure inventory Display an inventory table of all resources per location.
Azure rbac Lists Azure RBAC role assignments at subscription or tenant level
Azure storage The storage command is still under development. Currently it only displays limited data about the storage accounts
Azure vms Enumerates useful information for Compute instances in all available resource groups and subscriptions

GCP Commands

Provider Command Name Description
GCP whoami Display the email address of the GCP authenticated user
GCP all-checks Runs all available GCP commands
GCP artifact-registry Display GCP artifact registry information
GCP bigquery Display Bigquery datasets and tables information
GCP buckets Display GCP buckets information
GCP iam Display GCP IAM information
GCP instances Display GCP Compute Engine instances information
GCP secrets Display GCP secrets information

Authors

Contributing

Wiki - How to Contribute

FAQ

How does CloudFox compare with ScoutSuite, Prowler, Steampipe's AWS Compliance Module, AWS Security Hub, etc.

CloudFox doesn't create any alerts or findings, and doesn't check your environment for compliance to a baseline or benchmark. Instead, it simply enables you to be more efficient during your manual penetration testing activities. If gives you the information you'll likely need to validate whether an attack path is possible or not.

Why do I see errors in some CloudFox commands?

  • Services that don't exist in all regions - CloudFox tries a few ways to figure out what services are supported in each region. However some services don't support the methods CloudFox uses, so CloudFox defaults to just asking every region about the service. Regions that don't support the service will return errors.
  • You don't have permission - Another reason you might see errors if you don't have permissions to make calls that CloudFox is making. Either because the policy doesn't allow it (e.g., SecurityAudit doesn't allow all of the permissions CloudFox needs. Or, it might be an SCP that is blocking you.

You can always look in the ~/.cloudfox/cloudfox-error.log file to get more information on errors.

Prior work and other related projects

  • SmogCloud - Inspiration for the endpoints command
  • SummitRoute's AWS Exposable Resources - Inspiration for the endpoints command
  • Steampipe - We used steampipe to prototype many cloudfox commands. While CloudFox is laser focused on helping cloud penetration testers, steampipe is an easy way to query any and all of your cloud resources.
  • Principal Mapper - Inspiration for, and a strongly recommended partner to the iam-simulator command
  • Cloudsplaining - Inspiration for the permissions command
  • ScoutSuite - Excellent cloud security benchmark tool. Provided inspiration for the --userdata functionality in the instances command, the permissions command, and many others
  • Prowler - Another excellent cloud security benchmark tool.
  • Pacu - Excellent cloud penetration testing tool. PACU has quite a few enumeration commands similar to CloudFox, and lots of other commands that automate exploitation tasks (something that CloudFox avoids by design)
  • CloudMapper - Inspiration for the inventory command and just generally CloudFox as a whole

cloudfox's People

Contributors

bishopfaure avatar carlosvendramini avatar carlosvendramini-bf avatar cclauss avatar dbravo-bishopfox avatar dependabot[bot] avatar dominicbreuker avatar enzowritescode avatar jonzeolla avatar moloch-- avatar motikan2010 avatar rpunnett-bf avatar sethsec avatar sethsec-bf avatar testwill avatar tragulum avatar wdahlenburg avatar xntrik avatar

Stargazers

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

Watchers

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

cloudfox's Issues

No cache data - Error: unexpected EOF

Description of Bug

When running: cloudfox aws instances -c I get the following error:

[๐ŸฆŠ cloudfox v1.12.2 ๐ŸฆŠ ] AWS Caller Identity: arn:aws:iam::XXXXXXXXXXXX:user/pentest-user-2023
[๐ŸฆŠ cloudfox v1.12.2 ๐ŸฆŠ ] No cache data for XXXXXXXXXXXX. Error: unexpected EOF
[๐ŸฆŠ cloudfox v1.12.2 ๐ŸฆŠ ] Account is not part of an Organization

Here is the error file:

โฏ cat /Users/XXX/.cloudfox/cloudfox-error.log
time="2023-09-19T11:30:07+02:00" level=error msg="Could not decode the following file: /Users/XXX/.cloudfox/cached-data/aws/XXXXXXXXXXXX/XXXXXXXXXXXX-apigatewayv2-GetApis-ap-northeast-1.json"
time="2023-09-19T11:30:08+02:00" level=error msg="Failed to describe organization: operation error Organizations: DescribeOrganization, https response error StatusCode: 400, RequestID: 8b38ad4f-db5f-4404-809a-b4c232829860, AWSOrganizationsNotInUseException: Your account is not a member of an organization."
โฏ cat /Users/XXX/.cloudfox/cached-data/aws/XXXXXXXXXXXX/XXXXXXXXXXXX-apigatewayv2-GetApis-ap-northeast-1.json
{
  "Value": null,
  "Exp": 0
}

What should the expected behavior be

It should list the instances from cache.

Note: The error is the same for all commands

[Bug]AWS "SNS" and "SQS" were not inspected

Description of Bug

When "cloudfox aws all-checks" was specified at runtime, "sns" and "sqs" were not checked.

Version: v1.10.1

Ex.

$ ./cloudfox aws all-checks --profile  MY_PROFILE
(...snip...)
[inventory][(...MY_PROFILE...)] Enumerating selected services in all regions for account 36xxxxxxxxxx.
(...snip...)
[tags][(...MY_PROFILE...)] Enumerating tags for account 36xxxxxxxxxx.
(...snip...)
[instances][(...MY_PROFILE...)] Enumerating EC2 instances in all regions for account 36xxxxxxxxxx
(...snip...)
[lambda][(...MY_PROFILE...)] Enumerating lambdas for account 36xxxxxxxxxx.
(...snip...)
[route53][(...MY_PROFILE...)] Enumerating Route53 for account 36xxxxxxxxxx.
(...snip...)
[filesystems][(...MY_PROFILE...)] Enumerating filesystems for account 36xxxxxxxxxx.
(...snip...)
[endpoints][(...MY_PROFILE...)] Enumerating endpoints for account 36xxxxxxxxxx.
(...snip...)
[ecs-tasks][(...MY_PROFILE...)] Enumerating ECS tasks in all regions for account 36xxxxxxxxxx
(...snip...)
[eks][(...MY_PROFILE...)] Enumerating EKS clusters for account 36xxxxxxxxxx.
(...snip...)
[elastic-network-interfaces][(...MY_PROFILE...)] Enumerating elastic network interfaces in all regions for account 36xxxxxxxxxx
(...snip...)
[instances][(...MY_PROFILE...)] Enumerating EC2 instances in all regions for account 36xxxxxxxxxx
(...snip...)
[env-vars][(...MY_PROFILE...)] Enumerating environment variables in all regions for account 36xxxxxxxxxx.
(...snip...)
[cloudformation][(...MY_PROFILE...)] Enumerating cloudformation stacks for account 36xxxxxxxxxx.
(...snip...)
[buckets][(...MY_PROFILE...)] Enumerating buckets for account 36xxxxxxxxxx.
(...snip...)
[ecr][(...MY_PROFILE...)] Enumerating container repositories for account 36xxxxxxxxxx.
(...snip...)
[secrets][(...MY_PROFILE...)] Enumerating secrets for account 36xxxxxxxxxx.
(...snip...)
[ram][(...MY_PROFILE...)] Enumerating shared resources for account 36xxxxxxxxxx.
(...snip...)
[network-ports][(...MY_PROFILE...)] Enumerating potentially accessible network services for account 36xxxxxxxxxx.
(...snip...)
[principals][(...MY_PROFILE...)] Enumerating IAM Users and Roles for account 36xxxxxxxxxx.
(...snip...)
[permissions][(...MY_PROFILE...)] Enumerating IAM permissions for account 36xxxxxxxxxx.
(...snip...)
[access-keys][(...MY_PROFILE...)] Mapping user access keys for account: 36xxxxxxxxxx.
(...snip...)
[role-trusts][(...MY_PROFILE...)] Enumerating role trusts for account 36xxxxxxxxxx.
(...snip...)
[pmapper][(...MY_PROFILE...)] Looking for pmapper data for this account and building a PrivEsc graph in golang if it exists.
(...snip...)
[iam-simulator][(...MY_PROFILE...)] Running multiple iam-simulator queries for account 36xxxxxxxxxx. (This command can be pretty slow, FYI)
(...snip...)

Stacktrace when enumerating EFS Filesystems

Great tool!

Description of Bug

I received a nil pointer dereference when running this across our environment. It seemed to occur when analyzing EFS:

[filesystems][prod/prod_admin] Supported Services: EFS, FSx
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x35a4485]

goroutine 6277 [running]:
github.com/BishopFox/cloudfox/aws.(*FilesystemsModule).getEFSfilesystemPermissions(...)
	/home/ccastrapel/localrepos/cloudfox/aws/filesystems.go:491
github.com/BishopFox/cloudfox/aws.(*FilesystemsModule).getEFSSharesPerRegion(0xc0027c5300, {0xc000a5f170, 0x9}, 0x6d4a8a?, 0x6f8d66?, 0xc0014c2a20?)
	/home/ccastrapel/localrepos/cloudfox/aws/filesystems.go:322 +0x885
created by github.com/BishopFox/cloudfox/aws.(*FilesystemsModule).executeChecks
	/home/ccastrapel/localrepos/cloudfox/aws/filesystems.go:193 +0x1ed

Here is the tf code that generates the EFS that I think this is stuck on:



# Creating Amazon EFS File system
resource "aws_efs_file_system" "data_storage" {
  # Creating the AWS EFS lifecycle policy
  # Amazon EFS supports two lifecycle policies. Transition into IA and Transition out of IA
  # Transition into IA transition files into the file systems's Infrequent Access storage class
  # Transition files out of IA storage
  lifecycle_policy {
    transition_to_ia = "AFTER_7_DAYS"
  }
  kms_key_id = var.kms_key_id
  encrypted  = true
  tags       = var.tags
}

# Creating the EFS access point for AWS EFS File system
resource "aws_efs_access_point" "data_storage_access_point" {
  file_system_id = aws_efs_file_system.data_storage.id
  tags           = var.tags
}
# Creating the AWS EFS System policy to transition files into and out of the file system.
resource "aws_efs_file_system_policy" "policy" {
  file_system_id                     = aws_efs_file_system.data_storage.id
  bypass_policy_lockout_safety_check = true
  # The EFS System Policy allows clients to mount, read and perform
  # write operations on File system
  # The communication of client and EFS is set using aws:secureTransport Option
  policy = <<POLICY
{
    "Version": "2012-10-17",
    "Id": "Policy01",
    "Statement": [
        {
            "Effect": "Deny",
            "Principal": {
                "AWS": "*"
            },
            "Action": "*",
            "Condition": {
                "Bool": {
                    "aws:SecureTransport": "false"
                }
            }
        },
        {
            "Sid": "Statement",
            "Effect": "Allow",
            "Principal": {
                "AWS": "${var.ecs_task_role_arn}"
            },
            "Resource": "${aws_efs_file_system.data_storage.arn}",
            "Action": [
                "elasticfilesystem:ClientMount",
                "elasticfilesystem:ClientRootAccess",
                "elasticfilesystem:ClientWrite"
            ]
        }
    ]
}
POLICY
}
# Creating the AWS EFS Mount point in a specified Subnet
# AWS EFS Mount point uses File system ID to launch.
resource "aws_efs_mount_target" "efs-mount-target" {
  file_system_id  = aws_efs_file_system.data_storage.id
  subnet_id       = var.subnet_ids[0]
  security_groups = [aws_security_group.efs-sg.id]
}

resource "aws_efs_mount_target" "efs-mount-target-2" {
  file_system_id  = aws_efs_file_system.data_storage.id
  subnet_id       = var.subnet_ids[1]
  security_groups = [aws_security_group.efs-sg.id]
}

resource "aws_security_group" "efs-sg" {
  name        = "${var.cluster_id}-efs-access-sg"
  description = "Allows access to EFS storage from the containers"
  vpc_id      = var.vpc_id

  ingress {
    description     = "NFS for container access to EFS storage"
    from_port       = 2049
    to_port         = 2049
    protocol        = "tcp"
    security_groups = var.ecs_security_group_id
  }

  egress {
    description = "Full egress access"
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"] #tfsec:ignore:aws-vpc-no-public-egress-sgr
  }

  tags = merge(
    var.tags,
    {
      Name = "allow_access_to_efs"
    }
  )
}

Here's what the EFS file system looks like in the console:

image

This is where the nil reference appears to occur:

image

Access points (I suspect the issue is here due to blank Creation Info):

image

Cloudfox throws an AssumeRoleTokenProvider error when I use an assumed IAM role

Description of Bug

I'm trying to call a profile with an assumed IAM role when using Cloudfox and I'm getting a 'AssumeRoleTokenProvider' error. Is there a preferred way to call an assumed role profile with Cloudfox other than what's suggested by AWS here: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html

Here is my ~/.aws/config

[profile client-cli-admin]
role_arn = arn:aws:iam::REDACTED:role/AdminRole
source_profile = client-cli-audit
mfa_serial = arn:aws:iam::REDACTED:mfa/6mile-mfa
region = ap-southeast-2

And here's my ~/.aws/credentials file:

[client-cli-audit]
aws_access_key_id = REDACTED
aws_secret_access_key = REDACTED

6mile Demo ~/projects/security-audits/client % cloudfox aws buckets --profile client-cli-admin
assume role with MFA enabled, but AssumeRoleTokenProvider session option not set.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x20cc6e3]

goroutine 1 [running]:
github.com/BishopFox/cloudfox/internal.AWSConfigFileLoader({_, _}, {_, _})
	github.com/BishopFox/cloudfox/internal/aws.go:41 +0x303
github.com/BishopFox/cloudfox/internal.AWSWhoami({0x20ce2f997, 0xf}, {0x5ea277b, 0x6})
	github.com/BishopFox/cloudfox/internal/aws.go:53 +0x45
github.com/BishopFox/cloudfox/cli.awsPreRun(0xc0002eb900?, {0x5ea0272?, 0x4?, 0x5ea0276?})
	github.com/BishopFox/cloudfox/cli/aws.go:484 +0x188
github.com/spf13/cobra.(*Command).execute(0x81604e0, {0xc0006a7a60, 0x2, 0x2})
	github.com/spf13/[email protected]/command.go:929 +0x7d1
github.com/spf13/cobra.(*Command).ExecuteC(0x815fc40)
	github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:992
main.main()
	github.com/BishopFox/cloudfox/main.go:19 +0x51

My setup works when I use the AWS CLI itself and I can use the profile that assumes an IAM role, but that same thing doesn't appear to happen with Cloudfox.

6mile Demo ~/projects/security-audits/client % aws s3 ls --profile client-cli-admin
2021-09-14 13:47:02 REDACTED
2023-04-18 17:51:43 REDACTED
2022-07-22 11:30:21 REDACTED

What should the expected behavior be

I should be able to run the Cloudfox command successfully.

Steps to Reproduce

Try calling Cloudfox with an assumed role in AWS and see if it works.

Additional context

MacOS, AWS CLI version 2.0.62

Relevant screenshots

Working AWS CLI commands via assumed role:

Screenshot 2023-12-06 at 2 06 05โ€ฏpm

Cloudfox errors out when I try using the same assumed role:
Screenshot 2023-12-06 at 11 27 05โ€ฏam

authenticating

file format to pass containing the credentials? how to authenticate via the metadata?

List on Homebrew for easier installation and regular updates

As a security professional,
I want to install CloudFox using Homebrew
so that installation and updating is as easy as possible.

Overview

Homebrew is a well-known package manager for MacOS and Linux, which allows single command installations of packages (called Formula) and single command updating.

CloudFox meets all requirements to be listed as a Formula in Homebrew. I feel like listing on Homebrew will lower the barrier of entry (and of keeping up to date) for many security professionals.

Listing CloudFox as a formula in Homebrew should be easy, but I've never done it, so I can't speak from first-hand experience.

Acceptance Criteria

  • Security implications approved.
  • CloudFox is installable on MacOS with brew install cloudfox.

Non Functional Requirements/Wants

  • Ideally, the Homebrew formula for CloudFox is updated with the latest version numbers via CI from this project.

External Documents / Links

Conditionals of the following format are not captured by the tool when Federated principals in `role-trusts-federated`

Description of Bug

Conditionals of the following format are not captured by the tool when Federated principals in role-trusts-federated.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::012345678912:oidc-provider/oidc.eks.us-west-2.amazonaws.com/id/SOMEID"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "oidc.eks.us-west-2.amazonaws.com/id/SOMEID:sub": [
                        "system:serviceaccount:some-system:some-controller",
                        "system:serviceaccount:myoperator-system:myoperator-controller-manager"
                    ]
                }
            }
        }
    ]
}

What should the expected behavior be

The tool should capture both.

Associate container to ECS task in env-vars or ecs-task definitions

As a person
I want to map a container name to the ecs task
so that when im looking at env-vars i can know which task is associated to a specific container

Overview

Just add a column in ecs-task with the container name or env-vars add the task definition name column as well

Acceptance Criteria

  • Easily find out affected ecs tasks

Non Functional Requirements/Wants

  • n/a

Screenshots / Files

External Documents / Links

[Bug]Using the env-vars command froze

  • % of customers impacted: [100]%
  • Affected Users: [Engineers / Operators / Customers]
  • Is revenue impacted: [Yes / No]
  • Urgency: [High / Medium / Low]
  • Deadline: [Date]

Description of Bug

I used the env-vars command and it froze.

โฏ ./cloudfox aws env-vars --profile reader-admin-hoge
[๐ŸฆŠ cloudfox v1.7.1 ๐ŸฆŠ ] AWS Caller Identity: arn:aws:iam::364399834359:user/reader-admin
[env-vars] Enumerating environment variables in all regions for account 364399834359.
[env-vars] Supported Services: App Runner, Elastic Container Service, Lambda, Lightsail Containers, Sagemaker
[env-vars] Status: 0/105 tasks complete (0 errors -- For details check /Users/motikan2010/.cloudfox/cloudfox-error.log)
(...freeze..)

What should the expected behavior be

  • Command completed.
  • Result files (table/env-vars.txt, csv/env-vars.csv) are output successfully.

Platform Affected

[ ] Dev
[ ] Preview
[ ] Production

Steps to Reproduce

Run aws env-vars command.

ex. ./cloudfox aws env-vars

Additional context

The Goroutines argument is required, but was not passed.
In my environment, the following modifications made it work correctly.

โฏ git diff
diff --git a/cli/aws.go b/cli/aws.go
index 662485f..2a45ea7 100644
--- a/cli/aws.go
+++ b/cli/aws.go
@@ -480,6 +480,7 @@ var (
                                        Caller:          *caller,
                                        AWSRegions:      AWSRegions,
                                        AWSProfile:      profile,
+                                       Goroutines:      Goroutines,
                                        ECSClient:       ecs.NewFromConfig(AWSConfig),
                                        AppRunnerClient: apprunner.NewFromConfig(AWSConfig),
                                        LambdaClient:    lambda.NewFromConfig(AWSConfig),

Golang version

$ go version
go version go1.17.6 darwin/amd64

Relevant screenshots

If applicable, add screenshots to help explain your problem.

Identify Potentially Accessible EC2 Ports

As a Pentester,
I want to identify potentially accessible EC2 ports
so that I don't have to perform a comprehensive network scan on an entire VPC or even the public/private IPs

Overview

EC2 instances can be subject to security groups and network ACLs within AWS.

It would be really awesome to generate an "ec2-commands.txt" loot file that describes each instance and the potentially open ports. Why potential? A service doesn't have to be running on the defined port, but AWS will allow it to be accessed if the security groups and network ACLs permit it.

My preference would be that the loot file generates a list of nmap commands that could be ran.

This feature would be a huge time-saver as it could process the inventory and tell pentesters the potentially open port ranges on all instances. The time to fully scan each VPC or each instance's public/private IP can add up. Cloud services can have an inventory ran on them, so it'd be a much smarter methodology to just process this info.

I'd like to give it a shot at implementing this. Are there any caveats that I'm missing? Would this be useful?

Acceptance Criteria

  • The security groups and network ACLs are compared against each EC2 instance to determine allowed inbound access
  • The list of ports per instance are formatted into a basic nmap command and placed in a "*-commands.txt" loot file.

Non Functional Requirements/Wants

Screenshots / Files

External Documents / Links

https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html
https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html

Add Terraform Cloud federated trust identification

Terraform Cloud supports OIDC integration with AWS, but these trusts are not reported by CloudFox. Could you please add the logic necessary to identify and report these trusts?

Overview

List Terraform Cloud trusts in federated trusts output, similar to GitHub Actions.

Screenshots / Files

Example trust:

{
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::000000000000:oidc-provider/app.terraform.io"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "app.terraform.io:aud": "aws.workload.identity"
        },
        "StringLike": {
          "app.terraform.io:sub": "organization:org:project:workspacesname:workspace:*:run_phase:*"
        }
      }
    }
  ]
}

External Documents / Links

Terraform Cloud OIDC documentation: https://developer.hashicorp.com/terraform/cloud-docs/workspaces/dynamic-provider-credentials/aws-configuration
AWS Terraform Cloud blog: https://aws.amazon.com/blogs/apn/simplify-and-secure-terraform-workflows-on-aws-with-dynamic-provider-credentials/

Add VPC / VPC peering information to output

As a pentester
I want to be able to have an overview of VPC and VPC peering
so that I can quickly assess the attack surface.

Overview

In my current audit the targets are in a VPC but this VPC has some peering with other VPCs.

I want to be able to quickly see the other VPC linked to the VPC I'm auditing.

The following information would be useful for VPC:

  • Name
  • VPC ID
  • State
  • IPv4 CIDR
  • IPv6 CIDR
  • Owner ID
  • Region
  • Number of instances

The following information would be useful for VPC peering:

  • VPC id requester and accepter
  • VPC name requester and accepter
  • region requester and accepter
  • Requester CIDRs
  • Accepter CIDRs
  • Requester owner ID
  • Requester owner ID
  • Peering connection id
  • Status

Windows binary execution error

  • % of customers impacted: [?]%
  • Affected Users: [Operators / Customers]
  • Is revenue impacted: [No]
  • Urgency: [Low]
  • Deadline: [Date]

Description of Bug

The windows binary has code that seems to be looking for a certificate in a hardcoded location. It then fails to execute:

PS C:\Users\XYZ\Downloads\cloudfox> .\cloudfox.exe aws --profile scanuser all-checks
open C:\Users\UserX\Documents\RootCert.pem: The system cannot find the path specified.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x20bc0a3]

goroutine 1 [running]:
github.com/BishopFox/cloudfox/internal.AWSConfigFileLoader({_, }, {, _})
/home/runner/work/cloudfox/cloudfox/internal/aws.go:41 +0x303
github.com/BishopFox/cloudfox/internal.AWSWhoami({0xc00000a118, 0x8}, {0x5e90f90, 0x6})
/home/runner/work/cloudfox/cloudfox/internal/aws.go:53 +0x45
github.com/BishopFox/cloudfox/cli.awsPreRun(0xc000496b00?, {0x5e8ea79?, 0x4?, 0x5e8ea7d?})
/home/runner/work/cloudfox/cloudfox/cli/aws.go:484 +0x188
github.com/spf13/cobra.(*Command).execute(0x818b280, {0xc0000f2540, 0x2, 0x2})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:929 +0x7d1
github.com/spf13/cobra.(*Command).ExecuteC(0x8185680)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.main()
/home/runner/work/cloudfox/cloudfox/main.go:19 +0x51

The same goes when executing it with the Go version:
PS C:\Windows\system32> cloudfox aws all-checks --profile scanuser
open C:\Users\UserX\Documents\RootCert.pem: The system cannot find the path specified.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x1e6c1a3]

goroutine 1 [running]:
github.com/BishopFox/cloudfox/internal.AWSConfigFileLoader({_, }, {, _})
C:/Users//go/pkg/mod/github.com/!bishop!fox/[email protected]/internal/aws.go:41 +0x303
github.com/BishopFox/cloudfox/internal.AWSWhoami({0xc000184090, 0x8}, {0x5c412b2, 0x6})
C:/Users//go/pkg/mod/github.com/!bishop!fox/[email protected]/internal/aws.go:53 +0x45
github.com/BishopFox/cloudfox/cli.awsPreRun(0xc00028cb00?, {0x5c3ed9b?, 0x4?, 0x5c3ed9f?})
C:/Users//go/pkg/mod/github.com/!bishop!fox/[email protected]/cli/aws.go:484 +0x188
github.com/spf13/cobra.(*Command).execute(0x7f3b1e0, {0xc000187640, 0x2, 0x2})
C:/Users//go/pkg/mod/github.com/spf13/[email protected]/command.go:929 +0x7d1
github.com/spf13/cobra.(*Command).ExecuteC(0x7f355e0)
C:/Users//go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users//go/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.main()
C:/Users//go/pkg/mod/github.com/!bishop!fox/[email protected]/main.go:19 +0x51
PS C:\Windows\system32>

What should the expected behavior be

Platform Affected

[ ] Dev
[ ] Preview
[x ] Production

Steps to Reproduce

Steps to reproduce the behavior
Use the Windows binary in latest version.

Additional context

Powershell window running the cloudfox.exe binary

RDS instances not do not show up in aws databases command

This happened in this commit: 59afbb3

I was trying to remove duplicates where clusters and instances were both showing up, but forgot that you can have an instance WITHOUT a cluster and by moving to only checking for clusters created a situation where instances were missed.

Need to either revert back to using instances only, or grab both clusters AND instances and de-dup them or make it more clear that some are clusters and some are instances.

Go Panic during all-checks

Description of Bug

When running cloudfox aws all-checks the program crashes during the privesc phase with:

[resource-trusts][666412488974-AIDAJBTEDJEDFGHJKLWJU] Supported Services: CodeBuild, ECR, EFS, Glue, Lambda, SecretsManager, S3, SNS, SQS
failed to get shared config profile, 116412344578-AIDAJBTEDJEDFGHJKLWJU
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x101022724]

goroutine 9981 [running]:
github.com/BishopFox/cloudfox/internal.AWSConfigFileLoader({_, _}, {_, _}, {_, _})
	github.com/BishopFox/cloudfox/internal/aws.go:67 +0x3e4
github.com/BishopFox/cloudfox/aws.initCloudFoxS3Client({_, _, _, {_}, {}}, {_, _}, {_, _}, {_, ...})
	github.com/BishopFox/cloudfox/aws/client-initializers.go:48 +0x80
github.com/BishopFox/cloudfox/aws.(*ResourceTrustsModule).getS3Buckets(0x140011a4580, 0x100157644?, 0x14002196660, 0x140006733f0?)
	github.com/BishopFox/cloudfox/aws/resource-trusts.go:371 +0x114
created by github.com/BishopFox/cloudfox/aws.(*ResourceTrustsModule).PrintResources in goroutine 1
	github.com/BishopFox/cloudfox/aws/resource-trusts.go:94 +0x8c8

What should the expected behavior be

Not crash

Platform Affected

macOS Darwin 21.6.0 ARM64 (macOS Monterey)

Steps to Reproduce

  • Install via brew
  • Use aws-vault to start an authenticated shell with STS credentials
  • Run cloudfox aws all-checks

Lambda Arn not included in CSV and table output

Description of Bug

The output files csv/lambda.csv and table/lambda.txt have a header named "Resource Arn", but the function name is included instead of the ARN. For example, the table/lambda.txt file looks as follows:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Service โ”‚  Region   โ”‚    Resource Arn     โ”‚                         Role                         โ”‚ IsAdminRole? โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Lambda  โ”‚ us-east-1 โ”‚ FunctionName1       โ”‚ arn:aws:iam::[REDACTED]:role/[REDACTED]              โ”‚ No           โ”‚
โ”‚ Lambda  โ”‚ us-east-1 โ”‚ FunctionName2       โ”‚ arn:aws:iam::[REDACTED]:role/[REDACTED]              โ”‚ No           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Looking at the code, it seems that this was commented out.

Thanks!

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.