SSRF: when your server makes requests for the attacker

Server-side request forgery (SSRF) is an attack in which an application fetches a URL supplied by the user, and the attacker supplies one that points somewhere the application should never go: an internal admin page, a database, or a cloud provider's metadata service that hands out credentials. The request comes from your own server, so it passes firewalls that would stop the attacker directly.

Section Web attacks Updated Weakness CWE-918

Quick facts

Weakness
CWE-918: server-side request forgery
OWASP category
A01:2025 Broken Access Control, merged in from a separate 2021 category (A01 page)
Typical feature
Link previews, image fetch by URL, webhooks, PDF rendering, import from URL
Typical target
Internal services, admin interfaces and cloud metadata endpoints
Does a WAF stop it?
Partly. Internal addresses in a parameter are recognisable; redirects and DNS tricks are not

Definitions follow OWASP and CWE-918. Not to be confused with CSRF, which forges requests from the victim's browser.

How an SSRF attack works

  1. The application fetches a URL from input. To show a preview, download an image or call a webhook.
  2. The attacker supplies an internal address. A private range, localhost, or a name that resolves to one.
  3. The server makes the request. From inside the network, with whatever access the server has.
  4. The response comes back, or its effect does. The attacker reads the result directly, or infers it from timing and errors.

The server becomes a proxy into places the attacker cannot reach. In cloud environments, the most damaging target is usually the metadata service, which can return temporary credentials for the server's role. The browser can be used the same way through DNS rebinding.

Basic and blind SSRF

In basic SSRF the application returns the fetched content, so the attacker reads internal pages directly. In blind SSRF nothing is returned; the attacker learns from response times and error messages which addresses answer, or triggers actions on internal services that do not need a reply.

Blind SSRF is easy to dismiss and still dangerous: an internal endpoint that changes state on a simple request can be triggered without the attacker ever seeing the result.

WAYS AN INTERNAL TARGET SLIPS THROUGH VISIBLE IN THE REQUEST CAUGHT BY A HOST LIST CAUGHT BY CHECKING THE IP URL IN A PARAMETER REDIRECT FROM AN ALLOWED HOST NAME RESOLVING TO PRIVATE ADDRESS ALTERNATE IP NOTATION // check the address actually connected to, not the text
// four delivery tricks, and the one check that catches them all

SSRF vs CSRF

The names are close and the attacks are not. CSRF forges a request from the victim's browser, using the user's cookies against your site. SSRF forges a request from your server, using the server's network position against your own internal systems.

So the victims differ too. CSRF harms a user who is signed in; SSRF exposes systems that were never meant to be reachable from outside, such as internal admin tools and cloud metadata. A site can have one flaw without the other, and the fixes have nothing in common.

SSRF examples in ordinary features

Link previews fetch a page to show its title and image; given an internal address, they fetch an internal page instead. Image import by URL downloads whatever the address returns. Webhooks call a URL the customer configured, which may be an internal one.

Document converters that render HTML into PDF are a quieter case: the HTML can include references the renderer fetches while drawing the page. Any feature that turns user-supplied addresses into server-side requests belongs on the list to review.

What a WAF catches, and what it misses

A filter can match obvious internal targets in a parameter: loopback, private ranges, metadata addresses. That catches careless attempts.

Where the address travels matters as much as the address. A URL can reach the server in a query string, in a form or JSON body, or in a header the application reads. A metadata address inside a JSON field is the same attempt as one in a query string, so a check that covers only one of these places leaves the others open.

It misses what only becomes internal later: a public name that resolves to a private address, an allowed host that redirects inward, or an address written in an unusual notation. The decision has to be made at the moment the server connects, which is inside the application. As with SQL injection, the fix is to treat the value as data and decide in code. An allowed host that redirects elsewhere is the pattern behind an open redirect. Host header handling is another route to internal systems: host header injection.

How to prevent SSRF

  1. Do not fetch arbitrary URLs. Where possible, allow only a fixed list of hosts the feature needs; the OWASP SSRF Prevention Cheat Sheet starts here.
  2. Check the resolved address before connecting. Refuse private, loopback, link-local and other special-purpose ranges listed in RFC 6890.
  3. Do not follow redirects blindly. Re-check every hop, or turn redirects off.
  4. Isolate the fetcher. Run URL fetching from a network segment that cannot reach internal services.
  5. Protect the metadata service. Use the cloud provider's hardened mode that requires a session token.

Testing for SSRF

Find every feature that fetches a URL or a host name from input, including ones that do it indirectly, such as document converters that load images referenced inside a file. For each one, try internal targets: loopback, private ranges, the metadata address of your cloud, and names that resolve to them.

For blind SSRF, where nothing comes back in the response, point the feature at a server you control and watch for the incoming request. Then try the bypasses: a redirect from an allowed host to an internal one, alternative ways of writing the same address, and a name whose DNS answer changes between the check and the fetch.

Questions

What is SSRF?

Server-side request forgery is an attack in which an application fetches a URL supplied by the user, and the attacker makes the server request internal systems or cloud metadata it should not reach.

What is the difference between SSRF and CSRF?

SSRF makes your server send requests the attacker chooses. CSRF makes a victim's browser send requests to your site the victim did not intend.

How do you prevent SSRF?

Allow only the hosts a feature needs, check the resolved address against private and special-purpose ranges before connecting, re-check redirects, isolate the fetching service, and harden the metadata service.

Which OWASP category is SSRF in?

In the OWASP Top 10:2025, server-side request forgery is part of A01 Broken Access Control; in 2021 it was a separate category.