Beanstalk (CloudGoat)

Beanstalk

Initial Access

# credentials
initial_low_priv_credentials = Access Key: AKIA4YM7GTDHDNB4GXV7
Secret Key: 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

# configure
aws configure --profile low_level                                                           
AWS Access Key ID [None]: AKIA4YM7GTDHDNB4GXV7
AWS Secret Access Key [None]: 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
Default region name [None]: us-east-1
Default output format [None]: json

#whoami
aws sts get-caller-identity --profile low_level   
{
    "UserId": "AIDA4YM7GTDHOLCJS5VMB",
    "Account": "877044078798",
    "Arn": "arn:aws:iam::877044078798:user/cgidg0l919nvpe_low_priv_user"
}

Enumeration

Given the name beanstalk, we can take a logical guess and assume there is some kind AWS Elastic Beanstalk instance

What is AWS Elastic Beanstalk

  • is a PaaS offering by AWS that simplifies the process, managing and scaling web applications and services

Key concepts

  1. What it does:

    Elastic Beanstalk automatically handles:

    • Provisioning infrastructure (e.e., EC2, Load Balancers, Auto Scaling)

    • Deploying code in supported environments

    • Monitoring application health and metrics

    • Scaling resources based on load

  2. Supported Stacks

    • Languages and frameworks: Java, .NET, Node.js, Python, PHP, Ruby, Go, and Docker

    • Application servers: Apache, Nginx, Passenger, and IIS

  3. Deployment Model

    You just upload your code, and bean stalk handles

    • EC2 provisioning

    • Load balancing

    • Auto-scaling

    • Monitoring/logs via CloudWatch

Enumerating Beanstalk applications and environments

  1. List all Elastic Beanstalk Applications

    As you can see, we have found a beanstalk application, from which we can see the following

    • ApplicationArn: arn:aws:elasticbeanstalk:us-east-1:877044078798:application/cgidg0l919nvpe-app

    • ApplicationName: cgidg0l919nvpe-app

    • etc

  2. We can enumerate the environment

    What we are trying to look for are

    • Environment names

    • CNAMEs

    • Status, health

    • Possible public-facing endpoints or services

  3. Now we want to extract configuration settings (Secrets)

    • Output

    Ive placed the most interesting secret below

  4. We could have speed run this with pacu’s elasticbeanstalk__enum module

  5. From enumerating the beanstalk environment configuration we have found some credentials material

Enumerating as the secondary user

Enumerating users within the AWS account


Listing attached user policies for secondary user


Viewing attached user policy metadata


Viewing the actual attached policy

If we look at the following

This alows the creation of new access keys for any IAM user

Privilege esc to Admin User

  1. From this we can create a new access key for the administrative user

  2. We can now assume the admin

  3. Now we can retrieve the final glab from the AWS secret manager

Last updated