Server-Side Request Forgery (SSRF) is one of the most reported vulnerability classes in modern web stacks. This post explains what it is, the canonical exploit shape, and three defensive layers you can ship today.
SSRF tricks a server into making an HTTP request it shouldn't — typically to internal infrastructure (RFC1918 networks, link-local cloud metadata, internal service discovery). The attacker controls the destination URL but executes the call from the server's network perspective, bypassing firewalls.
The canonical anti-pattern: a URL parameter is fetched server-side without origin validation.
// BAD — never write code like this in production.
app.get('/fetch', async (req, res) => {
const target = req.query.url;
const upstream = await fetch(target);
res.send(await upstream.text());
});
An attacker calls /fetch?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/ and exfiltrates the EC2 instance role credentials.
Researchers see these patterns in the wild:
http://127.0.0.1:6379/INFO # Redis pivot
http://localhost:9200/_cluster/ # Elasticsearch read
http://[::1]:5984/_all_dbs # CouchDB enumeration
http://169.254.169.254/... # AWS / Azure / GCP metadata
gopher://internal-srv:25/... # SMTP smuggling
file:///etc/passwd # Local file disclosure