AWS Elastic Beanstalk
An SSRF vulnerability allowed access to AWS instance metadata, from which temporary credentials for the Elastic Beanstalk EC2 role were obtained. These credentials permitted listing and downloading the application's source code from its S3 bucket, and uploading a web shell that could be deployed via the CI/CD pipeline or environment rebuild, leading to remote code execution.
notsosecure.com
Published on notsosecure.com
In this blog, Sunil Yadav, our lead trainer for "Advanced Web Hacking " training class, will discuss a case study where a Server-Side Request Forgery (SSRF) vulnerability was identified and exploited to gain access to sensitive data such as the source code. Further, the blog discusses the potential areas which could…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application passed user-controlled input to a server-side request function without validating or restricting the destination, allowing access to the cloud metadata service.
Impact
The attacker could read the application's source code and, by uploading a web shell and triggering deployment, execute arbitrary commands on the EC2 instance, achieving remote code execution.
What the attacker needed
SSRF vulnerability in the application; Application deployed on AWS Elastic Beanstalk; Instance role with S3 access to the Elastic Beanstalk bucket
How it was found
- Confirm SSRF by making a DNS call to an external domain.
- Access the localhost-only server-status page through the SSRF.
- Query the AWS instance metadata to retrieve the account ID and region.
- Retrieve the IAM role's access key, secret key, and token from the metadata service.
- Use the credentials to list and download the S3 bucket contents, obtaining the source code.
- Upload a web shell to the S3 bucket and trigger deployment via the CI/CD pipeline or environment rebuild to achieve RCE.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Server-Side Request Forgery (SSRF) is when an attacker can make a server send requests to internal addresses it shouldn't reach. Here, the server could be tricked into reading cloud metadata that contained temporary access keys. Those keys then allowed reading and writing the application's code storage, which could lead to running commands on the server.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.