Before we get started I have started a slack group dedicated to hacking. We welcome everyone from beginner to advanced to join. I will be on everyday answer questions, doing CTFs, and talking about cool hacks. If you enjoy hacking and are looking for like minded people join below:
Server Side Request Forgery(SSRF) is an interesting attack which involves forcing a target server to send HTTP requests to a specified host on your behalf. The HTTP response will then be shown to the attacker, unless your dealing with blind SSRF. If you get SSRF on a server hosted on Amazon Web Services(AWS) you can turn this finding into a critical severity issue.
Im not going to going over how to perform SSRF here but if you don’t know what SSRF is ill explain it a little. SSRF allows an attacker to force an application to send requests on their behalf. This is often used to access resources on the internal network or resources that are behind a firewall.
Portswigger has a good blog post on SSRF if you want to learn more technical details on how to exploit this vulnerability:
Amazon Web Services(AWS) is the top dog in cloud computing. There are other cloud providers such as Microsoft Azure and Google Cloud but the vast majority of people use AWS.
AWS allows companies to get rid of all their self hosted infrastructure and servers and move them to the cloud. Cloud providers basically rent out servers and other infrastructure while taking care of the maintenance , updates, scaling and a lot more. You can host your web applications, firewalls, storage, databases, and virtual private server(VPS)s without having to deal with all the infrastructure headaches.
With AWS you can also control authentication through the Identity and Access Management(IAM) system. This will allow you to create users, services, and roles whole controlling what they have access to.
AWS has something called an EC2 instance, basically this acts as a VPS. A lot of people use these systems to host their web applications applications. EC2 instances use something called Instance Metadata Service documented below:
This metadata server can be accessed through the REST API located at “http:/169.254.169.254” . This REST API is hosted on a local IP which is only accessible to the local machine, but if accessed by an attacker it could be used to do all kinds of bad things.
SSRF on AWS
SSRF is used to force an application to make HTTP requests while showing the response to the attacker. Note the attacker must be able to view the response other wise it is considered blind SSRF which wont work here.
If an application is hosted on an AWS EC2 instance the meta data API located at “http:/169.254.169.254” can be used in combination with SSRF to steal AWS credentials. These credentials could then be used to do all kinds of things depending on their permissions.
Sending a GET requests to the following endpoint will dump a list of roles that are attached to the current EC2 instance:
If you want to access your S3 bucket you would normally hardcard your API keys into your application. Hardcoding clear text passwords is a bad idea. This is why you can assign your EC2 instance a role which can be used to access your S3 bucket. These credentials are automatically rotated by AWS and can be access thought the metadata API.
Once you get a list of roles attached to the EC2 instance you can dump their credentials by making a GET requests to the following url:
The response should look something like this:
You can then take those credentials and use them with the AWS CLI. This will allow you to do anything that role has permissions to do. If the role has improper permissions set(Most likely) you will be able to do all kinds of things, you might even be able to take over their entire cloud network.
If you find SSRF on an application hosted on AWS you might be able to steal AWS credentials. This could significantly increase the severity of your finding from low to critical. If the credentials you steal arnt scoped properly you may find yourself with the permissions to take over the entire cloud network.