November 19, 2026
AWS Privilege Escalation via Elastic Beanstalk | CloudGoat Walkthrough Using Pacu
From low-privilege IAM access to administrator credentials and AWS Secrets Manager through exposed Elastic Beanstalk environment variables.

By Hamza Farooqi
4 min read
Introduction
In this walkthrough, I'll demonstrate how I completed the CloudGoat beanstalk_secrets scenario using Pacu, an open-source AWS exploitation framework.
The objective of this lab was to identify security misconfigurations in an AWS environment, discover exposed credentials, escalate privileges, and retrieve a secret stored in AWS Secrets Manager.
I started with a low-privileged IAM user and explored how exposed environment variables and excessive IAM permissions could be chained together to gain higher privileges.
This scenario demonstrates why securely managing AWS credentials and applying the principle of least privilege are essential for cloud security.
Tools and Technologies Used
- CloudGoat โ Vulnerable AWS environment for security training
- Pacu โ AWS exploitation framework
- AWS CLI โ Interacting with AWS services
- Kali Linux โ Penetration testing environment
- AWS IAM โ Identity and access management
- AWS Elastic Beanstalk โ Application deployment service
- AWS Secrets Manager โ Secrets storage and management
Step 1: Deploying the CloudGoat Scenario
First, I deployed the beanstalk_secrets scenario using CloudGoat.
cloudgoat create beanstalk_secrets
After successful deployment, CloudGoat provided the initial low-privileged AWS credentials.
I configured these credentials in AWS CLI and verified access using:
aws sts get-caller-identity --profile beanstalkaws sts get-caller-identity --profile beanstalkThe command confirmed that I was authenticated as the low-privileged IAM user.
Step 2: Importing AWS Credentials into Pacu
Next, I launched Pacu to begin AWS security enumeration.
pacupacu
After creating a new session, I imported the existing AWS CLI profile:
import_keys beanstalkimport_keys beanstalkThis allowed me to interact with AWS services using the permissions assigned to the initial IAM user.
Step 3: Enumerating AWS Elastic Beanstalk
I started by searching for the available Elastic Beanstalk enumeration modules in Pacu.
search beanstalksearch beanstalkI identified the elasticbeanstalk__enum module and ran it against the eu-north-1 region.
run elasticbeanstalk__enum --region eu-north-1run elasticbeanstalk__enum --region eu-north-1The enumeration discovered one Elastic Beanstalk application and one environment.
More importantly, it identified AWS credentials exposed through environment variables.
The configuration contained variables
SECONDARY_ACCESS_KEY
SECONDARY_SECRET_KEYSECONDARY_ACCESS_KEY
SECONDARY_SECRET_KEYThese findings were significant because they exposed another set of AWS credentials that could be used for further enumeration.
Step 4: Enumerating the Secondary IAM User
After discovering the secondary credentials, I configured another AWS CLI profile and verified the identity using AWS STS.
aws configure --profile second
aws sts get-caller-identity --profile secondaws configure --profile second
aws sts get-caller-identity --profile secondThe output confirmed that the credentials belonged to a separate IAM user.
I then imported the secondary profile into Pacu:
import_keys secondimport_keys secondTo investigate its IAM permissions, I executed:
run iam__enum_permissionsrun iam__enum_permissionsThe module encountered permission restrictions while attempting certain enumeration operations.
It reported 14 unconfirmed permissions, so further investigation was required to identify which actions could actually be exploited.
Step 5: Identifying IAM Privilege Escalation Opportunities
Next, I used Pacu's privilege escalation scanner:
run iam__privesc_scan --scan-onlyrun iam__privesc_scan --scan-onlyThe module identified several potential privilege escalation methods.
One particularly interesting result was:
CONFIRMED: CreateAccessKeyCONFIRMED: CreateAccessKeyThis indicated that the iam:CreateAccessKey permission could potentially be abused.
If an IAM identity can create access keys for a more privileged user, an attacker may be able to authenticate as that user using the newly generated credentials.
Step 6: Exploiting CreateAccessKey to Obtain Administrator Access
After identifying the confirmed method, I executed the following module in my CloudGoat lab:
run iam__privesc_scan --user-methods CreateAccessKeyrun iam__privesc_scan --user-methods CreateAccessKeyPacu presented a list of available IAM users.
I selected the administrator user, and the module successfully generated a new access key pair for that identity.
This demonstrated how overly permissive IAM access-key management permissions can lead to privilege escalation.
I configured a new AWS CLI profile using the generated credentials and verified the new identity.
Step 7: Enumerating AWS Secrets Manager
With the administrator credentials available, I imported the new profile into Pacu.
import_keys adminimport_keys adminI then enumerated AWS Secrets Manager using:
run secrets__enum --region eu-north-1run secrets__enum --region eu-north-1Pacu successfully discovered a secret in AWS Secrets Manager associated with the scenario's final flag.
The module saved the retrieved information to the local Pacu downloads directory.
I inspected the downloaded secret and successfully obtained the final flag, completing the CloudGoat beanstalk_secrets challenge.
Conclusion
The CloudGoat beanstalk_secrets scenario provided a practical example of AWS privilege escalation.
By starting with a low-privileged IAM user, I was able to enumerate Elastic Beanstalk, discover exposed credentials, investigate IAM permissions, generate administrator credentials through a misconfiguration, and retrieve the final secret from AWS Secrets Manager.
The most important lesson from this lab is that a single exposed credential, combined with excessive IAM permissions, can create a path to privileged AWS access.
All testing was performed in an intentionally vulnerable CloudGoat lab environment created for security training.
Thanks for reading!