Back to Engineering Blog
Security6 min read•

Anatomy of an SSRF Attack: How Open Redirectors Expose Internal Subnets and How We Block Them

Allowing users to submit arbitrary destination URLs is dangerous if your server checks those URLs without network isolation. Here is how we block loopback probes and RFC 1918 exploitation.

D

David Chen, CISSP

Threat Intelligence Analyst

What Is Server-Side Request Forgery?

URL shorteners are frequent targets for Server-Side Request Forgery (SSRF).

When a short link service checks page titles, generates link previews, or pings destinations for uptime, the backend server makes an outbound HTTP request to the user-supplied URL.

If the server does not inspect the destination IP before making that request, an attacker can use the shortener as a proxy to scan private internal networks, read cloud metadata, and query backend microservices.

The Cloud Metadata Target: 169.254.169.254

On AWS, GCP, and DigitalOcean, virtual machines access instance configuration and temporary IAM credentials through a local metadata address:

http://169.254.169.254/latest/meta-data/iam/security-credentials/

If a user pastes that address into an unprotected shortener:

  • The worker makes an internal request to the link-local IP.
  • The cloud metadata API returns secret IAM access keys and security tokens.
  • The preview worker displays the returned secret keys right on the screen.
  • Common Bypass Tricks Attackers Use

    Naive filters look for simple strings like "localhost" or "127.0.0.1". Attackers bypass string checks easily:

  • **Hexadecimal IPs:** `http://0x7f000001` (decodes directly to 127.0.0.1)
  • **Dotted decimal integers:** `http://2130706433` (decodes to 127.0.0.1)
  • **Octal notation:** `http://0177.0.0.1`
  • **IPv6 loopback:** `http://[::1]` or `http://[::ffff:127.0.0.1]`
  • **DNS Rebinding:** An attacker points a domain to a public IP for the first check, then flips the DNS record to 127.0.0.1 on the second check.
  • How TLink Blocks SSRF at the Edge

    To stop SSRF attacks before any network packet leaves our workers, TLink enforces a three-stage validation pipeline:

    User URL -> Protocol Check -> DNS Resolution -> CIDR Subnet Block -> Approved
                                                           |
                                                      Private IP -> Rejected (HTTP 400)

    1. Strict Protocol Restrictions

    We allow only `http://` and `https://` schemes. Dangerous protocols like `file://`, `gopher://`, `ftp://`, and `ldap://` are rejected immediately.

    2. Synchronous Pre-Flight DNS Resolution

    Before connecting, our worker resolves the hostname to its underlying IPv4 and IPv6 addresses. We evaluate each address against private subnets:

  • **Loopback:** `127.0.0.0/8`, `::1`
  • **Link-Local and Cloud Metadata:** `169.254.0.0/16`, `fe80::/10`
  • **Private RFC 1918 Subnets:** `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`
  • **Carrier-Grade NAT:** `100.64.0.0/10`
  • If the resolved IP matches any private range, the server terminates the request with an HTTP 400 error.

    3. IP Pinning to Stop DNS Rebinding

    When automated health workers ping a target, they connect directly to the verified public IP rather than re-querying the hostname. This eliminates time-of-check to time-of-use (TOCTOU) DNS rebinding bugs.

    Security is built directly into every layer of TLink.

    Tags:#Cybersecurity#SSRF#AppSec#Networking

    Try TLink Free Today

    Sub-100ms redirects, 50/50 A/B split routing, and lossless vector QR codes. 100% free forever.