Back to Blog
Application Security

SSRF Attacks Explained: How Attackers Pivot Through Your Server

5 min read
SSRFCloud SecurityOWASP

What is Server-Side Request Forgery?

Server-Side Request Forgery (SSRF) occurs when an attacker can make a server-side application send HTTP requests to an arbitrary destination chosen by the attacker. The server acts as a proxy, allowing attackers to reach internal services, cloud metadata endpoints, and other resources that should be inaccessible from the outside.

SSRF has risen to the OWASP Top 10 (A10:2021) due to the explosion of cloud-based architectures where metadata services and internal APIs are just one HTTP request away.

How SSRF Attacks Work

Basic SSRF

The simplest form targets URL parameters that the server fetches:

POST /api/fetch-url
{"url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/"}

If the server fetches this URL without validation, the attacker retrieves AWS IAM credentials from the instance metadata service.

Blind SSRF

In blind SSRF, the attacker doesn't see the response directly but can infer information through:

  • Response timing differences
  • DNS lookups to attacker-controlled domains
  • Error message variations
  • Out-of-band data exfiltration

SSRF via Redirects

Even with URL validation, attackers can bypass filters using HTTP redirects:

Allowed: https://trusted-domain.com
Redirect: https://trusted-domain.com/redirect?to=http://169.254.169.254/

Cloud Metadata Attacks

Cloud providers expose instance metadata via well-known internal IPs:

ProviderMetadata URL
AWShttp://169.254.169.254/latest/meta-data/
GCPhttp://metadata.google.internal/computeMetadata/v1/
Azurehttp://169.254.169.254/metadata/instance

What Attackers Extract

  • IAM Credentials: Temporary access keys for cloud API calls
  • Instance Identity: Region, account ID, instance type
  • User Data: Startup scripts that may contain secrets
  • Network Configuration: VPC, subnet, security group details

Advanced SSRF Techniques

Protocol Smuggling

Attackers abuse URL scheme handlers:

  • file:///etc/passwd - Local file read
  • gopher://internal-redis:6379/ - Redis command injection
  • dict://internal-service:11211/ - Memcached interaction

DNS Rebinding

Bypasses host-based allowlists by making DNS resolve to an allowed IP first, then switching to an internal IP:

  1. Attacker domain resolves to 93.184.216.34 (passes validation)
  2. TTL expires, re-resolves to 169.254.169.254 (hits metadata)

IPv6 Bypass

Some filters only check IPv4 addresses, allowing IPv6 equivalents:

  • http://[::ffff:169.254.169.254]/
  • http://0x7f000001/ (hex encoding of 127.0.0.1)

Prevention Strategies

1. URL Validation and Allowlisting

import ipaddress
from urllib.parse import urlparse

ALLOWED_HOSTS = {"api.trusted.com", "cdn.partner.com"}

def validate_url(url):
    parsed = urlparse(url)
    if parsed.hostname not in ALLOWED_HOSTS:
        raise ValueError("Host not in allowlist")
    # Resolve and check for internal IPs
    ip = ipaddress.ip_address(socket.gethostbyname(parsed.hostname))
    if ip.is_private or ip.is_loopback or ip.is_link_local:
        raise ValueError("Internal IP not allowed")

2. Network Segmentation

  • Block metadata endpoints at the network level
  • Use IMDSv2 (AWS) which requires session tokens
  • Deploy VPC endpoints to avoid metadata exposure

3. Disable Unnecessary Protocols

Only allow http and https schemes. Block file://, gopher://, dict://, and others.

4. Response Filtering

Don't return raw responses from server-side requests. Parse and validate the response before returning it to the user.

Testing for SSRF with SuperClue

SuperClue's SSRF detection modules include:

  • Cloud metadata probing against the AWS and GCP metadata endpoints
  • Protocol handler testing for the file and gopher schemes
  • Open redirect detection, since attackers chain open redirects with SSRF

Protect your cloud infrastructure from SSRF attacks before they expose your credentials.

Ready to Test Your Applications?

Start your comprehensive security scan with SuperClue's security modules.

Request access