Server-side request forgery
Last updated
Last updated
Server-side request forgery (SSRF) exploits the trusted relationship between a web server and other backend systems which are not normally accessible to an attacker (e.g. because of firewalls or application rules). They are particularly dangerous in cloud infrastructure like AWS, because SSRF allows an attacker to query internal services like for credentials and other sensitive data.
Generally, you'll be looking for poorly-sanitized parameters which accept URLs, either in GET
or POST
requests. Less well-known locations for SSRF include:
HTTP Referer header
Partial URLs in requests (assembled server-side)
In the examples below, localhost
is used in the URL to access data and services which are only accessible via the local network.
Example GET
request with a vulnerable open redirect:
Example POST
request with a similarly unsanitized URL parameter:
Some SSRF attacks will return a response that you can see on the vulnerable website, but others may be .
You can also test protocols other than HTTP:
There are two metadata standards for the AWS API - the newest one requires you to generate a short-term token before issuing commands. However, the older non-token version does not seem to be going away, so you could simply use curl http://169.254.169.254/whatever
to get the same data.
The top-level metadata items will look something like this:
From there, you can make calls to the API to view each of the metadata items in detail.
For example, the following command lets you view startup scripts for the instance, which may reveal credentials or paths to sensitive S3 buckets:
To view roles for the instance:
Once you have a role name, you can request credentials for that role:
You can also attempt to create a new user, as a proof-of-concept:
Amazon's AWS has an internal metadata service which can be queried from any instance. Attackers can use SSRF vulnerabilities to retrieve instance information and in some cases make changes to the infrastructure. performs a similar function.
The following command from allows you to generate a 6-hour token, save it in a variable and display the top-level metadata items:
At this point you may want to consider automated AWS metadata enumeration tools like to determine the permissions available to a role:
The can be used to poke around connected S3 buckets. Some useful commands: