Issue
Some applications fetch remote content for features such as image imports, link previews, document processing, and webhooks. Server-side request forgery (SSRF) occurs when a user can influence a request made by the application server to an unintended destination. The server may have network access that the user’s browser does not. OWASP SSRF Prevention Cheat Sheet
The risk depends on what the feature is meant to fetch. If it only needs to contact a small set of services, it should accept only those destinations. If users must supply arbitrary public URLs, the application needs stricter checks on the destination and strong limits on the server’s outbound network access.
Common causes include accepting complete user-supplied URLs, relying on fragile string filters, following redirects without checking their destinations, or validating a hostname separately from the address the client eventually connects to. DNS changes, URL parser differences, and alternate address formats can make simple checks unreliable. SSRF can also arise when a URL is supplied indirectly, such as in an uploaded document or a request header. It is not limited to HTTP when the application or a library supports other protocols. OWASP SSRF Prevention Cheat Sheet
Examples
Replace example URLs with unique endpoints on infrastructure you control.
Request:
POST /api/preview HTTP/1.1Host: app.example.comContent-Type: application/json {"url":"https://callback.example/ssrf-test-7f31"}
Observation: A matching request appears in the controlled endpoint’s logs shortly after the application request. This supports the conclusion that a server-side component fetched the URL; it does not show that the component can reach internal services.
Response:
HTTP/1.1 202 AcceptedContent-Type: application/json {"status":"preview_queued"}
The response alone does not confirm whether a fetch occurred. Check the controlled endpoint’s logs and application behavior.
Impact
The first requirement is a feature that makes a server-side request based on user-controlled input. The possible impact then depends on the server’s network access, credentials, and handling of the response.
If the server can reach a restricted service, SSRF may let a caller trigger an action there or access data that the application returns. Cloud metadata services can be a concern in some deployments; for example, OWASP describes AWS IMDSv2 as an additional defense for AWS environments. OWASP SSRF Prevention Cheat Sheet
A callback to a test-controlled endpoint can confirm that a server-side request occurred. It does not, by itself, show that the request reached internal systems or exposed sensitive data. A blind SSRF, where the application does not return the fetched response, may still trigger an outbound request, but that alone does not establish what the server could access. PortSwigger Web Security Academy: Blind SSRF
Testing
1. Confirm the server makes a request to a supplied URL
Supply a URL on a controlled test host and inspect its access log. Compare the timestamp and request details with the application action.
Example: A response mentioning the URL is only a clue. A matching request at the controlled host shows that a server-side fetch occurred.
POST /api/preview HTTP/1.1
Host: app.example.test
Content-Type: application/json
{"url":"https://marker.example.test/preview"}
2. Check URL restrictions and redirect handling
Compare an allowed destination with a disallowed test destination and a controlled redirect. Check what the application fetches after following the redirect.
Example: An initial allowed URL can redirect elsewhere. Observe the destination actually contacted, not just the initial URL.
POST /api/preview HTTP/1.1
Host: app.example.test
Content-Type: application/json
{"url":"https://marker.example.test/redirect"}
3. Review response exposure and network controls
Check whether the application returns fetched content or only a status. With code or configuration access, review permitted schemes, DNS checks, network boundaries, and logging.
Example: A server-side request does not by itself prove access to internal services. State the destination and response actually observed.
A callback may come from a proxy, URL scanner, or other intermediary rather than the component under review. DNS-only interactions, delayed callbacks, and requests visible only in the browser can also be misread. Correlate timing, request identifiers, and logs before concluding that the application server performed the fetch. A public callback confirms neither internal reachability nor data exposure. These testing distinctions align with the OWASP testing guidance and PortSwigger’s discussion of blind SSRF. OWASP WSTG, PortSwigger: Blind SSRF
Mitigation
Primary fixes
- Use fixed destinations where possible. Replace arbitrary URLs with an approved destination ID or a server-side mapping to a known endpoint. This limits what a caller can make the application contact.
- Apply destination checks at connection time. Parse input with a maintained URL library. Allow only the schemes, hosts, ports, and paths the feature needs. Resolve both IPv4 and IPv6 addresses, reject destinations disallowed by policy, and make the HTTP client connect to a validated address. A separate DNS check is insufficient if the client resolves the hostname again before connecting.
- Control redirects. Disable them when they are not required. If they are required, validate every redirect target with the same policy before following it.
- Restrict outbound network access. Use network rules or an egress proxy so the service can reach only destinations the feature requires. Application checks and network restrictions provide defense in depth. OWASP SSRF Prevention Cheat Sheet
Additional defenses
- Limit response size, request duration, and supported protocols; avoid returning raw remote responses unless the feature requires them.
- Keep sensitive credentials out of outbound requests, and grant the fetching service only the permissions it needs.
- Use cloud metadata protections where available. OWASP identifies IMDSv2 as an additional AWS defense; it does not replace destination validation or network restrictions. OWASP SSRF Prevention Cheat Sheet
Retest the approved destination, a disallowed destination, and redirect behavior. Confirm that permitted fetches still work, prohibited destinations are not contacted, and the client connects only to an address that passed the policy check.