Skip to content
cloudgrip

$ man server-side-request-forgery

//Attacks and vulnerabilities

What is server-side request forgery (SSRF)?

With server-side request forgery (SSRF), an attacker supplies a URL and the application fetches it on their behalf, from inside your network. The server can reach internal systems and cloud metadata services that the attacker cannot reach directly.

  • Attacks and vulnerabilities
  • 3 min read
  • updated Nov 11, 2026

How it works

Many features need the server to fetch something from an address the user provides: importing an image from a link, calling a webhook, generating a PDF from a web page, reading a feed. Server-side request forgery (SSRF) happens when the server fetches whatever address it is given without checking where that address leads.

The danger comes from the server's position. It sits inside the network, behind the firewall. It can talk to databases, admin panels and internal services that are invisible from the internet. Those services often trust any request that comes from inside. An attacker who controls where the server sends a request borrows that position.

In the cloud the stakes are higher. Virtual machines can query an instance metadata service at the fixed address 169.254.169.254, which can return temporary credentials for the machine's cloud role. An SSRF flaw that reaches it can turn a small web bug into access to the cloud account.

What it looks like

A profile page lets users set an avatar by pasting an image link. The normal request names a public image. An attacker sends an internal address.

output
POST /api/profile/avatar HTTP/1.1
Host: app.acme.test
Content-Type: application/json

{"image_url": "http://10.0.0.12:8080/admin/status"}
output
HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error": "not an image", "received": "{\"service\":\"admin\",\"status\":\"ok\"}"}

The server connected to an internal admin service and echoed part of the reply in its error message. The attacker has read a page that no outside user should reach.

Variants worth knowing:

  • Blind SSRF. The response is not shown. The attacker learns from timing and error differences.
  • DNS tricks. A hostname resolves to a public address when it is checked and to an internal address when it is fetched.

How to test for it

Find every place where the server makes a request on the user's behalf, then check where it can be pointed.

  1. List the candidates. Look for parameters that hold links or hostnames, and for features such as webhooks, importers, link previews and document converters.
  2. Confirm that the server makes the request. Supply the address of a host you control and watch for an incoming connection.
  3. Try internal destinations. Use loopback addresses, private ranges and the metadata address. Compare responses, status codes and timing for clues, even when no content comes back.
  4. Show the impact safely. Reading a harmless internal status page proves the flaw. Do not collect credentials or change internal systems unless the rules of the test explicitly allow it.

How to fix it

Decide where the server is allowed to connect, and enforce that at the moment of connection.

output
import ipaddress, socket
from urllib.parse import urlparse

def check_destination(url):
    parts = urlparse(url)
    if parts.scheme != "https":
        raise ValueError("only https is allowed")
    address = socket.gethostbyname(parts.hostname)
    if not ipaddress.ip_address(address).is_global:
        raise ValueError("internal addresses are not allowed")
    return address  # connect to this exact address, do not resolve again

This sketch shows the three ideas that matter: allow only the expected scheme, resolve the name and reject non-public addresses, and connect to the address you checked so a second lookup cannot return something different.

Around that:

  • Prefer an allowlist. If the feature only needs a few known hosts, accept only those.
  • Do not follow redirects, or validate every hop the same way.
  • Isolate the fetcher. Run it in a network segment with no route to internal services, and block outgoing traffic to the metadata address from workloads that do not need it.
  • Harden the metadata service. Use the version that requires a session token, which a simple forged request cannot obtain.

Blocklists of bad strings fail, because there are too many ways to write the same address.

How it differs from cross-site request forgery

In cross-site request forgery (CSRF), the attacker tricks a victim's browser into sending a request, using the victim's logged-in session. In SSRF, the attacker tricks the server into sending a request, using the server's network position. CSRF abuses a user's identity. SSRF abuses a machine's location.

SSRF had its own entry in the 2021 OWASP Top 10 and is part of broken access control in the 2025 edition.

See what an attacker would find.

Give us a URL and two test logins. If there’s something to find, your first exploited findings land within 24 hours.

You talk to the people who build Hydra and Cerberus. No sales script.

or write to founders@cloudgrip.ai