SyntaxPilot
Courses/Cybersecurity Fundamentals/Lesson 43
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Cybersecurity Fundamentals · Lesson 43 of 90

SSRF and open redirects

server-side request forgery (SSRF)internal services exposurecloud instance metadata service (IMDS)IMDSv2URL parsing pitfallsDNS rebinding (concept)allowlisting destinationsegress controlsblind SSRFopen redirectsafe redirect handling

These are the notes for Cybersecurity Fundamentals (defensive), episode 43. Episode 42 stopped other sites from tricking the user's browser into sending requests. Today someone tricks our server. A harmless "import your photo from a URL" feature can reach admin pages and cloud credentials inside the company network: server-side request forgery (SSRF). We see why blocklists fail, build the fix (allowlist, parse, resolve, check the IP, connect to that IP, no redirects), add network defences, and finish with open redirects. Every term is explained the first time it appears, and the Glossary at the end defines them all again.

Neha, Ravi, the shop and every value are made up. The "internal services" are tiny HTTP servers that each demo starts itself on 127.0.0.1 (this same machine), and the "credentials" are fake (TOYKEY123). Nothing outside the machine is contacted. Python samples run on 11 Nov 2026 with Python 3.13, and every output below is copied from a real run. example.com, shop.example and evil.example are reserved example domains. Never point SSRF tests at systems you don't own or aren't explicitly authorised to test.

The problems you'll solve

Problem Idea it teaches
"Import your photo from a URL" fetches an admin page SSRF, internal networks, loopback, trust by network position
The cloud's special address hands out keys Instance metadata service (IMDS), link-local, temporary credentials, IMDSv2
Block the bad addresses Why blocklists fail: 127.1, decimal, hex, IPv6, DNS names
URLs that fool string checks URL parsing pitfalls: user info @, look-alike hosts
Allow only what we expect Allowlist, parse, resolve, is_global, connect to the checked IP, redirects off
The address changes between check and use DNS rebinding, TTL, TOCTOU
Code checks can have bugs Egress controls, network segmentation, blind SSRF
A real login link that ends on a fake page Open redirects, safe redirect handling

Problem 1: a server that fetches URLs

Basic words first:

  • A URL is a web address: scheme://user:pass@host:port/path?query. The scheme is http, https, file...; the host is a name (images.example.com) or an IP address.
  • An IP address identifies a machine on a network (episode 18). Private addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x) are used inside organisations and aren't reachable from the internet. Loopback (127.0.0.1, ::1) means "this same machine".
  • An internal service is something only reachable from inside the network: admin panels, databases, monitoring dashboards.

The shop's server sits inside the company network. Many internal services trust any request that comes from inside. If a user can choose the URL our server fetches, the user borrows our server's position.

Demo 1: the photo import, as first written

# "Import your profile photo from a URL". The SERVER fetches it.
import threading, urllib.request, http.server
class Internal(http.server.BaseHTTPRequestHandler):    # a toy INTERNAL service
    PAGES = {"/admin": "internal admin panel: 3 users, delete button",
             "/latest/meta-data/iam/security-credentials/shop-role":
             '{"AccessKeyId": "TOYKEY123", "SecretAccessKey": "toy-secret"}'}
    def do_GET(self):
        body = self.PAGES.get(self.path, "not found").encode()
        self.send_response(200); self.end_headers(); self.wfile.write(body)
    def log_message(self, *a): pass
srv = http.server.HTTPServer(("127.0.0.1", 8931), Internal)
threading.Thread(target=srv.serve_forever, daemon=True).start()

def import_photo(url):                         # the feature, as first written
    with urllib.request.urlopen(url, timeout=2) as r:
        return r.read().decode()[:70]

for url in ["http://127.0.0.1:8931/admin",
            "http://127.0.0.1:8931/latest/meta-data/iam/security-credentials/shop-role"]:
    print("user asked for", url[:40] + "...")
    print("   server got:", import_photo(url))
user asked for http://127.0.0.1:8931/admin...
   server got: internal admin panel: 3 users, delete button
user asked for http://127.0.0.1:8931/latest/meta-data/i...
   server got: {"AccessKeyId": "TOYKEY123", "SecretAccessKey": "toy-secret"}

What SSRF is

OWASP: SSRF "abuses an application to interact with the internal/external network or the machine itself". The attacker chooses where your server sends a request.

attacker ──"http://127.0.0.1/admin"──▶ our server (inside) ──▶ internal admin, database, metadata

Where to look for it: photo/file imports from a URL, link previews (chat apps fetching a page to show a card), webhooks (your app calls a URL the customer configured), PDF or screenshot generators that load a page, XML/SVG processors that fetch external files, "test this URL" buttons.

SSRF was A10 in the OWASP Top 10 2021. In 2025 it "was absorbed into 2025's Broken Access Control category" (Fastly's summary of OWASP Top 10:2025), because it is an access-control failure: the server reaches what users can't.

Problem 2: cloud instance metadata

Real-life example: the hotel's internal phone

In a hotel In the cloud
Dial 9 from any room; reception answers without questions The instance metadata service (IMDS) at 169.254.169.254 answers the server itself
"Send up a spare key" It can hand out temporary credentials for the server's cloud role
A guest's friend uses the room phone SSRF to metadata: the attacker asks through our server
  • A cloud instance is a virtual server you rent.
  • 169.254.169.254 is a link-local address: it only works from the machine itself, never across the internet. AWS, Google Cloud and Azure all use it for metadata (OWASP lists it among addresses to block).
  • An instance often has a role (IAM role, episode 34): permissions to use other services, e.g. read a storage bucket. The metadata service hands the instance temporary credentials for that role. Stolen through SSRF, they let the attacker use those permissions.

IMDSv1 vs IMDSv2 (AWS)

From the AWS EC2 documentation, "How Instance Metadata Service Version 2 works":

IMDSv1 IMDSv2
Getting data one simple GET first a PUT to http://169.254.169.254/latest/api/token with header X-aws-ec2-metadata-token-ttl-seconds
Later requests plain GET GET with header X-aws-ec2-metadata-token: <token>
Token lifetime n/a up to six hours (21,600 seconds)
Missing token answers 401 - Unauthorized when tokens are required
Extra guards none PUT requests with an X-Forwarded-For header are rejected; the token reply has a hop limit of 1 by default

Most SSRF bugs can only make a plain GET with no custom headers, so they can't complete the PUT-then-GET dance. X-Forwarded-For is added by proxies, so a misconfigured proxy can't fetch a token. The hop limit (IP time-to-live) of 1 means the reply can't travel past the instance (containers may need 2). OWASP: "IMDSv2 is an additional defense-in-depth mechanism for AWS that mitigates some of the instances of SSRF". Require IMDSv2 on every instance, but still fix the SSRF.

Problem 3: the obvious fix, a blocklist

Demo 2: a string blocklist, and four spellings

# The obvious fix: block "bad" strings. Then try other spellings.
import threading, urllib.request, http.server
class Internal(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200); self.end_headers()
        self.wfile.write(b"internal admin panel")
    def log_message(self, *a): pass
srv = http.server.HTTPServer(("127.0.0.1", 8932), Internal)
threading.Thread(target=srv.serve_forever, daemon=True).start()

BLOCKED = ["127.0.0.1", "localhost", "169.254.169.254"]
def import_photo(url):
    if any(b in url for b in BLOCKED):
        return "rejected by blocklist"
    with urllib.request.urlopen(url, timeout=2) as r:
        return "FETCHED: " + r.read().decode()

for url in ["http://127.0.0.1:8932/admin",        # the plain spelling
            "http://127.1:8932/admin",            # short form of 127.0.0.1
            "http://2130706433:8932/admin",       # the same address as one number
            "http://0x7f000001:8932/admin"]:      # ... in hexadecimal
    print(f"{url:32} -> {import_photo(url)}")
http://127.0.0.1:8932/admin      -> rejected by blocklist
http://127.1:8932/admin          -> FETCHED: internal admin panel
http://2130706433:8932/admin     -> FETCHED: internal admin panel
http://0x7f000001:8932/admin     -> FETCHED: internal admin panel

Why: an IPv4 address is really one 32-bit number. 127.0.0.1 = 127×2²⁴ + 1 = 2130706433 = hexadecimal 0x7f000001, and 127.1 is a legal short form. The operating system accepts all of them. Add IPv6 forms (::ffff:7f00:1 is 127.0.0.1 written as IPv6) and any domain name an attacker points at 127.0.0.1, and the list never ends. OWASP: "Deny-lists are bypass-prone. Prefer allow-lists."

URL parsing pitfalls

http://images.example.com@127.0.0.1/admin

Everything before @ is user info (an old URL feature for user:password). A check like url.startswith("http://images.example.com") passes, but the host is 127.0.0.1.

http://images.example.com.evil.example/a.png

It starts with the right name, but the host is a subdomain of evil.example.

Parse once with a real URL parser (urllib.parse.urlsplit), and compare the parsed hostname exactly. Use the same parsed result for the check and for the request, because different parsers sometimes disagree about tricky URLs.

Problem 4: allowlist, resolve, check

Real-life example: a delivery van with a route sheet

A delivery van Our photo importer
Only stops on the route sheet An allowlist of hosts: images.example.com, cdn.example.com
Checks the real address on arrival Resolve the host, check the IP is public, connect to that IP

OWASP: "The allowlist approach is a viable option" when the application only needs to call known systems. Resolving means asking DNS (episode 20) for the host's IP address.

Demo 3: the check

# The fix: parse, allowlist the host, resolve, check the IP, connect to THAT IP
import ipaddress
from urllib.parse import urlsplit
ALLOWED_HOSTS = {"images.example.com", "cdn.example.com"}
TOY_DNS = {"images.example.com": "34.120.5.17",   # made-up public address
           "cdn.example.com": "10.0.0.5"}         # DNS changed to an internal one!

def check(url):
    u = urlsplit(url)
    if u.scheme not in ("http", "https"):
        return f"reject: scheme {u.scheme!r}"
    if u.hostname not in ALLOWED_HOSTS:            # the parsed host, not a substring
        return "reject: not on allowlist"
    ip = ipaddress.ip_address(TOY_DNS[u.hostname])  # real code: socket.getaddrinfo
    if not ip.is_global:                           # private, loopback, link-local...
        return f"reject: internal {ip}"
    return f"ok: fetch from {ip}"

for url in ["http://127.1:8932/admin",
            "http://images.example.com@127.0.0.1/admin",
            "http://images.example.com.evil.example/a.png",
            "file:///etc/passwd",
            "http://cdn.example.com/a.png",
            "https://images.example.com/neha.png"]:
    print(f"{url:45}{check(url)}")
print()
for ip in ["10.0.0.5", "192.168.1.1", "169.254.169.254", "::1"]:
    print(f"{ip:16} is_global = {ipaddress.ip_address(ip).is_global}")
http://127.1:8932/admin                      reject: not on allowlist
http://images.example.com@127.0.0.1/admin    reject: not on allowlist
http://images.example.com.evil.example/a.png reject: not on allowlist
file:///etc/passwd                           reject: scheme 'file'
http://cdn.example.com/a.png                 reject: internal 10.0.0.5
https://images.example.com/neha.png          ok: fetch from 34.120.5.17
10.0.0.5         is_global = False
192.168.1.1      is_global = False
169.254.169.254  is_global = False
::1              is_global = False

The toy DNS table stands in for real DNS so the demo runs offline. ipaddress.ip_address(...).is_global is False for private, loopback, link-local and other reserved ranges. Check every address a name resolves to.

Two more OWASP rules:

  • Disable redirect following in the HTTP client. Otherwise a fine external URL can answer 302 Location: http://169.254.169.254/... and the client follows it without any check. (If you must follow, re-run the whole check on every hop.)
  • Only http and https: file:, gopher:, ftp:, dict: and others reach things a photo import never needs.

Problem 5: DNS rebinding and network defences

DNS rebinding (a TOCTOU bug)

  1. The check resolves photos.attacker.example → a public address. Fine.
  2. The attacker runs the DNS server for that name and gives answers a TTL (time to live, how long the answer may be cached) of 0 seconds.
  3. The HTTP library resolves the name again to connect, and now gets 127.0.0.1.

That's DNS rebinding, a time-of-check to time-of-use (TOCTOU) bug: the thing checked changed before it was used. OWASP: "Domain allowlisting alone does not prevent DNS rebinding" and "A second, unchecked DNS lookup between validation and connection can bypass these checks." Fix: resolve once, check, and connect to that exact IP (sending the original Host header, and for HTTPS verifying the certificate for the original name). The mini project below does this.

Defence in the network

  • Egress control: rules for where a server may connect out to (episode 24's firewalls, applied to outgoing traffic). The photo fetcher may reach the internet, but no private ranges and no 169.254.169.254. OWASP calls firewall rules and network segregation "highly recommended".
  • Network segmentation: run the fetcher in its own small zone (or a separate service/container with no route inward), so even a bypass reaches nothing valuable.
  • Require IMDSv2, and make internal services authenticate callers instead of trusting "it came from inside" (zero trust, episode 35).

Blind SSRF

In blind SSRF the application never shows the response. The attacker sees nothing, but the request still reaches inside: it can trigger an internal action (GET /admin/delete?id=7 on a badly designed service) or learn which hosts and ports exist from how long requests take or whether they error. "We don't show the reply" is not a defence.

Problem 6: open redirects

After login, many sites go back to where you were: https://shop.example/login?next=/orders. If next can be any URL, an attacker sends Neha a real shop link with next=https://evil.example/login. She checks the domain, sees the real padlock, logs in on the real shop, and is then sent to a fake "session expired, log in again" page. That's an open redirect: a site that sends visitors to any address given in a parameter. It makes phishing links look trustworthy and can help an SSRF slip past an allowlist (an allowed host that redirects anywhere).

Demo 4: unsafe vs safe next

# Open redirect: after login, go to ?next=...
from urllib.parse import urlsplit

def unsafe_next(nxt):
    return nxt                                     # whatever the link says

def safe_next(nxt):
    u = urlsplit(nxt)
    if u.scheme or u.netloc or "\\" in nxt:        # absolute URL, //host, or \ trick
        return "/home"
    if not nxt.startswith("/"):
        return "/home"
    return nxt

for nxt in ["/orders", "https://evil.example/login",
            "//evil.example", "/\\evil.example", "javascript:alert(1)"]:
    print(f"{nxt:26} unsafe -> {unsafe_next(nxt):26} safe -> {safe_next(nxt)}")
/orders                    unsafe -> /orders                    safe -> /orders
https://evil.example/login unsafe -> https://evil.example/login safe -> /home
//evil.example             unsafe -> //evil.example             safe -> /home
/\evil.example             unsafe -> /\evil.example             safe -> /home
javascript:alert(1)        unsafe -> javascript:alert(1)        safe -> /home
  • //evil.example is a scheme-relative URL: browsers treat it as "same scheme, host evil.example".
  • Browsers treat \ like / in many URLs, so /\evil.example can also mean another host.
  • Better still: don't accept URLs at all. Accept a name and map it to a path on the server (Practice 3), or use an exact allowlist of destinations.

The whole chain

  1. A photo import fetched an internal admin page and keys → SSRF.
  2. The cloud's room phone → IMDS; require IMDSv2.
  3. A string blocklist was bypassed by other spellings; URL parsing pitfalls fooled text checks.
  4. Allowlist hosts, parse, resolve, check is_global, no redirects.
  5. DNS rebinding → connect to the checked IP; add egress rules and segmentation; remember blind SSRF.
  6. ?next= to anywhere → open redirect; allow only your own paths, or map names to paths.

Common mistakes (and what they cause)

Mistake What happens (real output) Why Fix
Fetching any URL a user gives server got: internal admin panel: 3 users, delete button the server is inside the network allowlist of hosts
A string blocklist http://127.1:8932/admin -> FETCHED: internal admin panel many spellings of one address resolve, then check every IP (is_global)
startswith() host checks images.example.com@127.0.0.1 passes @ starts the real host parse, compare hostname exactly
Following redirects 302 to http://127.0.0.2:8942/admin would be followed the check saw only the first URL redirects off, or re-check each hop
Resolving twice DNS rebinding time of check ≠ time of use connect to the checked IP
Relying only on code one parser bug = full access no second wall egress firewall, segmentation, IMDSv2
Redirecting to ?next= as given //evil.example -> //evil.example // means another host own paths only, or a name→path map

Mini project: a safe URL fetcher

Parse → scheme and exact host allowlist (no user info) → resolve once → check every IP → connect to that IP with the original Host header → never follow redirects → limit size and time.

# Mini project: a safe URL fetcher for "import from a URL" features.
# parse -> scheme + exact host allowlist -> resolve ONCE -> check every IP -> connect to THAT IP
# -> send the original Host header -> never follow redirects -> limit size and time.
import socket, ipaddress, http.client
from urllib.parse import urlsplit

def safe_fetch(url, allowed_hosts, ip_ok=lambda ip: ip.is_global, max_bytes=1_000_000):
    u = urlsplit(url)
    if u.scheme not in ("http", "https"):
        return "reject: scheme"
    if u.hostname not in allowed_hosts or u.username or u.password:
        return "reject: host not allowed"
    port = u.port or (443 if u.scheme == "https" else 80)
    infos = socket.getaddrinfo(u.hostname, port, proto=socket.IPPROTO_TCP)   # resolve once
    ips = {ipaddress.ip_address(i[4][0]) for i in infos}
    if not all(ip_ok(ip) for ip in ips):
        return f"reject: {u.hostname} resolves to {sorted(map(str, ips))}"
    ip = str(sorted(ips, key=str)[0])
    Conn = http.client.HTTPSConnection if u.scheme == "https" else http.client.HTTPConnection
    conn = Conn(ip, port, timeout=3)               # connect to the CHECKED ip (no 2nd lookup)
    # (for https, real code must also verify the certificate for u.hostname, e.g. with
    #  ssl.create_default_context() and server_hostname=u.hostname)
    conn.request("GET", u.path or "/", headers={"Host": u.hostname})
    r = conn.getresponse()
    if 300 <= r.status < 400:                       # redirects are NOT followed
        return f"reject: redirect {r.status} to {r.getheader('Location')} not followed"
    return f"ok {r.status}: {r.read(max_bytes).decode()[:40]}"

if __name__ == "__main__":
    import threading, http.server
    class Pub(http.server.BaseHTTPRequestHandler):     # stands in for a public image host
        def do_GET(self):
            if self.path == "/go":
                self.send_response(302); self.send_header("Location", "http://127.0.0.2:8942/admin")
                self.end_headers(); return
            self.send_response(200); self.end_headers(); self.wfile.write(b"PNG...neha's photo bytes")
        def log_message(self, *a): pass
    srv = http.server.HTTPServer(("127.0.0.1", 8941), Pub)
    threading.Thread(target=srv.serve_forever, daemon=True).start()
    # Test policy: treat 127.0.0.1 as "the public host"; everything else must be global.
    test_ok = lambda ip: ip.is_global or str(ip) == "127.0.0.1"
    tests = [("http://localhost:8941/neha.png", {"localhost"}, test_ok),
             ("http://localhost:8941/go", {"localhost"}, test_ok),
             ("http://localhost:8941/neha.png", {"localhost"}, lambda ip: ip.is_global),
             ("http://images.example.com@localhost:8941/", {"images.example.com"}, test_ok),
             ("gopher://localhost/", {"localhost"}, test_ok)]
    for url, hosts, ok in tests:
        print(f"{url:42} {safe_fetch(url, hosts, ok)}")
http://localhost:8941/neha.png             ok 200: PNG...neha's photo bytes
http://localhost:8941/go                   reject: redirect 302 to http://127.0.0.2:8942/admin not followed
http://localhost:8941/neha.png             reject: localhost resolves to ['127.0.0.1']
http://images.example.com@localhost:8941/  reject: host not allowed
gopher://localhost/                        reject: scheme

The test treats 127.0.0.1 as "public" only so the demo can run offline; with the real is_global policy (row 3) it is rejected.

Practice

  1. Try IPv6 spellings of 127.0.0.1 against the string blocklist.
  2. Make check() return the IP and fetch it (see the mini project).
  3. Replace ?next= URLs with a name→path map.
  4. Why is blind SSRF still dangerous?
Solution 1
# Practice 1 solution: IPv6 spellings against the string blocklist
import threading, urllib.request, http.server, ipaddress
class Internal(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200); self.end_headers()
        self.wfile.write(b"internal admin panel")
    def log_message(self, *a): pass
srv = http.server.HTTPServer(("127.0.0.1", 8933), Internal)
threading.Thread(target=srv.serve_forever, daemon=True).start()

BLOCKED = ["127.0.0.1", "localhost", "169.254.169.254"]
def import_photo(url):
    if any(b in url for b in BLOCKED):
        return "rejected by blocklist"
    try:
        with urllib.request.urlopen(url, timeout=2) as r:
            return "FETCHED: " + r.read().decode()
    except Exception as e:
        return f"error: {e}"

for url in ["http://[::ffff:127.0.0.1]:8933/admin", "http://[::ffff:7f00:1]:8933/admin"]:
    print(f"{url:36} -> {import_photo(url)}")
print("::ffff:7f00:1 is", ipaddress.ip_address("::ffff:7f00:1").ipv4_mapped,
      "| is_global =", ipaddress.ip_address("::ffff:7f00:1").is_global)
http://[::ffff:127.0.0.1]:8933/admin -> rejected by blocklist
http://[::ffff:7f00:1]:8933/admin    -> error: <urlopen error [Errno 97] Address family not supported by protocol>
::ffff:7f00:1 is 127.0.0.1 | is_global = False

The second spelling passed the blocklist; only this test machine's lack of IPv6 stopped the connection. On an IPv6-enabled server it would reach 127.0.0.1. The ipaddress module sees through it: it's 127.0.0.1, is_global = False.

Solution 2

safe_fetch() in the mini project resolves once with socket.getaddrinfo, checks every IP, then opens http.client.HTTPConnection(ip, port) and sends Host: <original name>. No second DNS lookup happens.

Solution 3
# Practice 3 solution: ?next= takes a NAME, the server maps it to a path
NEXT = {"orders": "/orders", "cart": "/cart", "profile": "/account/profile"}
def after_login(next_name):
    return NEXT.get(next_name, "/home")
for n in ["orders", "profile", "https://evil.example", "//evil.example"]:
    print(f"{n:22} -> {after_login(n)}")
orders                 -> /orders
profile                -> /account/profile
https://evil.example   -> /home
//evil.example         -> /home
Solution 4

The request still reaches internal systems. It can trigger internal actions (anything an internal GET does), and timing or error differences reveal which internal hosts and ports exist, which is reconnaissance for the next attack.

Quick quiz

if url.startswith("https://images.example.com"):
    fetch(url)

Which URLs pass? A: https://images.example.com@10.0.0.5/ B: https://images.example.com.evil.example/ C: https://images.example.com/a.png D: all three

Answer

D. All three start with that text. A's real host is 10.0.0.5 (the part before @ is user info) and B's real host is under evil.example. A text prefix is not a host check: parse the URL and compare hostname exactly.

Interview questions

  1. What is SSRF? Making a server send requests to a destination the attacker chooses, often internal.
  2. Why is cloud metadata a common target? 169.254.169.254 hands temporary role credentials to anything on the instance that asks.
  3. How does IMDSv2 help? Requires a PUT for a session token and a token header on every GET; rejects PUTs with X-Forwarded-For; hop limit 1. Most SSRF bugs can't do that.
  4. Why do blocklists fail? Many encodings of one IP (127.1, decimal, hex, IPv6), DNS names pointing inside, redirects.
  5. How would you implement a safe URL fetch? Allowlist hosts, parse once, http/https only, resolve once, check every IP, connect to that IP, no redirects, size/time limits, egress firewall.
  6. What is DNS rebinding? The name resolves to a public IP at check time and an internal one at connect time.
  7. What is blind SSRF? SSRF where the response isn't shown; still dangerous for actions and probing.
  8. What is an open redirect and why does it matter? Redirecting to any user-given URL; it makes phishing links look legitimate and can chain with SSRF.
  9. How do you fix open redirects? Only relative paths starting with a single / (no // or \), or map names to paths, or an exact allowlist.
  10. Where did SSRF go in the OWASP Top 10 2025? Into A01 Broken Access Control (it was A10 in 2021).

Glossary

Term Meaning, with an example
URL A web address: scheme://user@host:port/path?query.
Scheme The first part of a URL: http, https, file, gopher.
Host The machine part of a URL: a name (images.example.com) or an IP.
User info The user:password@ part before the host; images.example.com@127.0.0.1 has host 127.0.0.1.
IP address A machine's network address: 10.0.0.5, ::1.
Private address Ranges used inside organisations: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
Loopback "This same machine": 127.0.0.1, ::1.
Link-local Addresses that only work on the local link, like 169.254.169.254.
Internal service A system reachable only from inside the network: an admin panel, a database.
SSRF (server-side request forgery) The attacker chooses where your server sends a request.
Link preview A chat app fetching a page to show a title and image; a classic SSRF spot.
Webhook Your app calls a URL a customer configured when something happens.
Instance A rented virtual server in the cloud.
IMDS (instance metadata service) The cloud's per-machine information service at 169.254.169.254.
Temporary credentials Short-lived keys for the instance's role, served by IMDS.
IAM role A set of cloud permissions a machine or user can take on.
IMDSv2 AWS's token-based IMDS: PUT for a token, then GET with X-aws-ec2-metadata-token.
Hop limit (TTL) How many network hops a packet may cross; 1 keeps the IMDSv2 token reply on the machine.
X-Forwarded-For A header proxies add naming the original client; IMDSv2 rejects PUTs carrying it.
Blocklist (deny list) A list of forbidden values; bypass-prone.
Allowlist A list of the only permitted values; the safer default.
Decimal / hex IP 127.0.0.1 written as 2130706433 or 0x7f000001.
IPv4-mapped IPv6 An IPv4 address written as IPv6: ::ffff:7f00:1 = 127.0.0.1.
URL parser Code that splits a URL into parts correctly: urllib.parse.urlsplit.
is_global Python ipaddress flag: False for private, loopback, link-local and reserved addresses.
Resolve Look up a host name's IP address in DNS.
Redirect A 3xx response with a Location header telling the client to go elsewhere.
DNS rebinding A name resolves to a safe IP at check time and an internal one at use time.
TTL (DNS) How long a DNS answer may be cached; 0 forces a fresh lookup.
TOCTOU Time-of-check to time-of-use: what you checked changed before you used it.
Egress control Firewall rules for outgoing connections from a server.
Network segmentation Splitting a network into zones so one breach doesn't reach everything.
Blind SSRF SSRF where the response isn't shown, but the request still happens.
Open redirect A site that redirects to any address given in a parameter.
Scheme-relative URL //evil.example/x: same scheme as the current page, another host.
Phishing Tricking someone into giving secrets on a fake page (episode 6).

Summary

  • SSRF: the attacker steers your server's requests to places only it can reach, like admin panels and cloud metadata.
  • Require IMDSv2, but fix the code: blocklists fail against 127.1, decimal, hex, IPv6 and DNS names.
  • Allowlist hosts, parse URLs properly, allow only http/https, resolve once, check every IP with is_global, connect to that IP, don't follow redirects.
  • Back it up with egress rules and segmentation; blind SSRF is still SSRF.
  • Open redirects: allow only your own paths, or map names to paths.

Next episode: cryptographic failures and sensitive data protection.