Application Security

Prevent Server-Side Request Forgery in Web Applications

Reduce SSRF risk when applications fetch URLs, process webhooks or retrieve remote resources.

Server-side request forgery (SSRF) occurs when an attacker can influence a server-side request to an unintended destination. Features such as URL previews, image importers, webhook testers and document fetchers can create this risk if destination handling is not constrained.

Prefer destination allowlists

If a feature needs only a known set of providers, accept an identifier rather than an arbitrary URL. When arbitrary destinations are essential, parse and validate the URL, restrict schemes and ports, and reject credentials embedded in URLs. A hostname check alone is not enough because DNS resolution can change the destination.

Validate resolved addresses

Block loopback, private, link-local, multicast and other non-public address ranges for both IPv4 and IPv6. Re-check destinations after redirects and limit or disable redirects. Consider DNS rebinding and ensure the address actually connected to is the address that passed policy validation.

Add network-level controls

Application validation should be reinforced by egress firewall rules or a dedicated outbound proxy. Services that fetch public content should not be able to reach cloud metadata endpoints, internal control planes or database networks without a strong operational reason.

Bound the request

Set strict timeouts, response-size limits and content-type validation. Do not trust a remote Content-Type header as proof of file format. Store fetched files safely and scan or parse them with appropriate limits.

Checklist

  • Prefer allowlisted destinations.
  • Restrict schemes, ports, redirects and resolved IP ranges.
  • Enforce outbound network controls.
  • Limit response size and processing time.
  • Test IPv4, IPv6, redirects and DNS rebinding scenarios.
Share this page Help other developers discover this resource.