githubEdit

SRF (Server-Side Request Forgery)

Server-side request forgery (SSRF)

What is it?

Server-Side Request Forgery (SSRF) is a vulnerability that allows an attacker to induce the server-side application to make HTTP requests to an arbitrary domain of the attacker's choosing. It can be used by an attacker to interact with internal systems, possibly bypassing firewalls or accessing unauthorized data.

A simple example

A vulnerable web application uses a parameter to retrieve an image from a URL, i.e., /loadImage?url={imageURL}. An attacker can potentially change the {imageURL} to point to internal resources that should not be exposed, such as http://localhost/admin or http://internal-service/api/secrets.

The impact of an SSRF vulnerability includes:

  • Access to internal services and data

  • Remote code execution

  • Denial of Service (DoS)

Other learning resources:

Checklist

Exploitation

SSRF (Server-Side Request Forgery)

SSRF is a type of exploit where an attacker abuses the functionality of a server causing it to access or manipulate information in the realm of that server that would otherwise not be directly accessibleto the attacker. SSRF is an attack against a server.

SSRF Capture Tools

If we want to capture incoming requests from target website/server, there is a lot of open-source tools available.

Ngrok

https://ngrok.com/arrow-up-right

To start ngrok server, run the following.

Then start your local web server for fetching requests forwarded from the ngrok server.

After starting ngrok and local web server, we can use the URL such as https://abcd-12-3-45-678.ngrok-free.app.

Localhost.run

http://localhost.run/arrow-up-right

As mentioned the official documentation,

After running the command above, copy generated URL such as abcdef123456789.lhr.life. Requests sent to this URL will be forwarded to your localhost:8080.

LocalXpose

LocalXposearrow-up-right is a reverse proxy that enables you to expose your localhostarrow-up-right to the internet. To use it, we need to sign up and Access Token.

  1. Login using Access Token.

  1. Open browser to access GUI version.

Pastebin

https://pastebin.com/arrow-up-right

After writing the content in there, we can easily use the raw page such as https://pastebin.com/raw/abcdefgharrow-up-right.

Interactsh

Interactsharrow-up-right

Other Tools

Local Web Server

Also we can simply open local web server if local machine accepts external requests.

HTTP (http://)

We may be able to use another server in the target machine. For example, pass the localhost URL to the GET parameters. Also These are available in POST params.

Local Port Enumeration

We can find which port is opening by fuzzing port number.

Gopher (gopher://)

We may be able to use gopher:// scheme.

Automation

We can use Gopherusarrow-up-right to create a payload automatically.

SMTP

At first, we need to prepare a payload for sending message to victim user.

The payload above can be URL encoded with tools such as CyberChef. Then the encoded payload is as follow.

We can use it to SSRF.

Images

We might be able to allow a website to load images from our server. First, create Base64 encoded URL:

Then create a payload as below:

Listen HTTP Request

If the website is vulnerable to SSRF, we can fetch sensitive information in HTTP request by sniffing. First off, start a listener in local machine.

Then send request that is affected by SSRF.

See the HTTP request in local machine. We might be able to fetch the sensitive data such as API key, Cookie, etc.

OS Command Injection

Admin Operations

We may be able to operate significant stuff as the admin user via local server.

Whitelisted URL Bypass

If the target website allows only the whitelisted URL, we can use them. Assume only "example.com" is allowed by the target website.

Open Redirect

AWS Instances

Internal Kubernetes Services

Hostname Bypass

1. Add Target Domain to /etc/hosts in Local Machine

Restart the hostname service to apply the configuration imediately.

2. Access to the Domain We Specified**

API Request

We might be able to get information from an API endpoint that is not accessible normally.

Reveal Filtered Websites via Monitoring Tools (Webhook)

Some web apps may have monitoring tools that check the health of external websites. You may be able to reveal hidden contents of the target via the monitor. First off, create a redirect server using Python. Here it’s named “redirect.py”.

After creating, run the following command. Assume that the filtered port is 3000 (nmap will reveal it).

And start listener for receiving the POST request of the webhook from the target website.

Now set the configuration of the webhook. For example:

You can see the contents of the filtered app.

Request Splitting

Reference: https://www.rfk.id.au/blog/entry/security-bugs-ssrf-via-request-splitting/arrow-up-right

It is the vulnerability of the Node.js http.get module, which allows attacker to insert HTTP headers and bodies by splitting request. First off, prepare HTTP headers and body as below:

Then manipulate it for sending to target.

Tools

Summary

circle-info

Server-side request forgery (also known as SSRF) is a web security vulnerability that allows an attacker to induce the server-side application to make HTTP requests to an arbitrary domain of the attacker's choosing. In typical SSRF examples, the attacker might cause the server to make a connection back to itself, or to other web-based services within the organization's infrastructure, or to external third-party systems.

SSRF Attacks

SSRF Bypasses

PDF SSRF

Mindmap

Last updated