Knowledge Base · general

SSRF

generaltechnique notetechniquessrf

Server-Side Request Forgery: the application fetches a URL supplied by the attacker, who points it at internal services, cloud metadata, or files.

How it works

  • An input that is used as a URL (?url=, ?fetch=, webhook testers, PDF renderers, previewers).
  • Reach internal endpoints: 127.0.0.1, 169.254.169.254 (cloud IMDS), RFC1918 ranges, Unix sockets.
  • Filter bypasses: alternative IP encodings (2130706433, 0177.0.0.1, 0x7f.0.0.1), 127.1, [::ffff:127.0.0.1], trailing-dot hosts (localhost.), and DNS tricks like nip.io.
  • Chained SSRF → metadata credentials → cloud API takeover.

Detection & defence

  • Allow-list destinations instead of deny-listing localhost.
  • Resolve the hostname and re-check the resulting IP after every redirect; block loopback/link-local/private ranges.
  • Enforce IMDSv2 (token-based) on AWS so a naive GET cannot read credentials.