Use this when a server fetches URLs and could be misused.
SSRF · Web Security
SSRF (server-side request forgery) tricks a web server into making requests to internal services or cloud metadata, such as 169.254.169.254. Validate and allow-list URLs and block internal addresses at the network.
1. SSRF makes servers request attacker-chosen URLs (internal services, cloud metadata).
2. Allowlist destinations.
3. Block internal ranges and metadata IPs.
4. IMDSv2/hop limits.
5. Network egress controls.
user URL → validation/allowlist → outbound request
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Metadata services (169.254.169.254) reachable from the app.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Block internal ranges and metadata IPs.
- Allow-list destinations.
- Add network egress controls.
- Outbound request allowlist — destinations
curl -s 'https://<app>/fetch?url=http://169.254.169.254/'— SSRF test (authorised)- IMDSv2 required (AWS) — metadata protection
ReferenceWhy it matters1 section · depth on demand
Defences
- Validate destination URLs against an allowlist of hosts and schemes.
- Resolve DNS and block private, loopback, link-local (169.254.169.254) and IPv6 equivalents; re-validate after redirects.
- Fetch from an isolated network segment with egress filtering.
- Use IMDSv2 on AWS and equivalent protections on other clouds.
- Do not return raw responses from fetched URLs to the user.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Server-Side Request Forgery (SSRF) makes a server send requests to destinations chosen by the attacker — typically internal services or cloud metadata endpoints that are not reachable from outside. Features that fetch URLs (webhooks, previews, imports) are common entry points.
Defences:
| Control | Purpose |
|---|---|
| Allow-list destinations | Only fetch from approved hosts |
| Resolve and validate IPs | Block private, loopback, link-local and metadata addresses, re-check after redirects |
| Disable unneeded URL schemes | Only http/https |
| IMDSv2 / metadata protections | Cloud metadata requires tokens |
| Egress filtering | Servers cannot reach arbitrary internal hosts |
Network segmentation limits what an SSRF can reach even when application controls fail.
Common SSRF targets
| Target | Why |
|---|---|
169.254.169.254 | Cloud metadata — credentials (use IMDSv2 on AWS) |
localhost / 127.0.0.1 | Admin interfaces |
| Internal IP ranges | Databases, internal APIs |
file://, gopher:// | Local files, raw protocols |
Bypass tricks include DNS names resolving to internal IPs, decimal IPs (2130706433), IPv6 ([::1]) and redirects — validate the resolved IP at connection time.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Web Security → SSRF. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://owasp.org/www-project-application-security-verification-standard/ · confidence 94%