Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What Is SSRF? How to Secure Server-Side URL Fetching

Understand why link previews and URL imports can expose internal services, and learn how to restrict outbound requests before deployment.

Table of Contents

Server-side request forgery (SSRF) occurs when input lets someone direct an application's server to make unintended network requests. Features such as link previews, file imports, and webhook delivery need explicit rules for what the server may contact. The server can often reach resources that a browser on the public internet cannot.

What is SSRF Attack? How to Prevent SSRF Attack Picture 1

Recognize where SSRF risk enters your application

Identify every place a URL, hostname, or destination from a user or another system reaches an HTTP client or similar library. Review background workers as well as interactive routes. A vulnerable request can expose a response to the user or produce effects even if no response body is returned.

What is SSRF Attack? How to Prevent SSRF Attack Picture 2
The application server makes the outbound request, so its own network access determines what it can reach.

Decide what each feature should be allowed to reach

What is SSRF Attack? How to Prevent SSRF Attack Picture 3
Combine destination validation with network-level limits on outbound connections.
  • Known destinations: Prefer selecting a destination from a server-controlled list. Use a proper URL parser and enforce approved schemes, hosts, and ports. Do not rely on a substring match.
  • Public URL fetching: Place the fetcher behind an egress proxy or equivalent network control. Block access to private networks, loopback, link-local ranges, and cloud metadata from that worker. Apply the policy consistently to IPv4 and IPv6.
  • Redirects and DNS: Disable redirects unless required. If enabled, validate every destination and ensure the actual connection uses an approved address. Checking just the first hostname is insufficient.
  • Limit the fetcher's privileges: Use a separate worker identity, avoid forwarding credentials, and set time and response-size limits. Those limits complement destination checks.

Verify the controls before release

In your own application tests, verify that approved destinations work and that disallowed destinations are rejected before a connection opens. Include the redirect behavior and use controlled test fixtures. Monitor unexpected outbound destinations and review any component that has access to cloud or internal services. See the OWASP SSRF defense guidance for more detail.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.