Server-side request forgery (SSRF) is a vulnerability in which an application fetches a URL or connects to an address supplied by the user without restricting the destination. An attacker uses the server as a proxy to reach internal services, cloud metadata endpoints or other systems that are not reachable from the internet. SSRF is listed as CWE-918; it was its own category, A10, in the OWASP Top 10 2021 and appears in the OWASP API Security Top 10 2023. The main defenses are destination allowlists, network egress controls and least privilege for the server's credentials.
What is SSRF?
Server-side request forgery (SSRF) turns a feature into a weapon. Many applications fetch resources on behalf of the user: importing an image from a URL, generating link previews, calling webhooks, rendering PDFs from HTML, or connecting to a user-configured integration. If the application accepts any URL and the server can reach more than the internet, an attacker can point it at targets they cannot reach themselves, such as http://localhost:8080/admin, an internal database API or the cloud provider's metadata service.
The server sends the request from inside the network, with its own network position and often its own credentials. That is why SSRF frequently leads from a harmless-looking parameter to internal systems. It was added to the OWASP Top 10 as its own category, A10:2021, and appears in the OWASP API Security Top 10 2023 as API7. A widely reported case is the 2019 Capital One breach, in which an SSRF weakness was used to obtain cloud credentials from the instance metadata service.
How SSRF works
# vulnerable: fetch whatever URL the user provides
@app.post("/preview")
def preview():
url = request.json["url"]
return requests.get(url, timeout=5).text
# attacker input
{"url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/"}
On a cloud instance with the older metadata service version, this request returns the name of the attached role and, in a second request, temporary access keys. The attacker can then use them from outside to call cloud APIs with the server's permissions.
Common targets of SSRF:
- Cloud metadata endpoints:
169.254.169.254on AWS, Azure and Google Cloud, which expose instance details and, depending on configuration, credentials. - Services bound to localhost: admin interfaces, debug endpoints, caches or databases that trust local connections.
- Internal networks: private address ranges such as
10.0.0.0/8,172.16.0.0/12and192.168.0.0/16, Kubernetes service names and internal APIs without authentication. - Other protocols: depending on the HTTP client, schemes such as
file://orgopher://can read local files or talk to non-HTTP services.
Variants
| Variant | What the attacker sees | Typical use |
|---|---|---|
| Basic SSRF | The response of the internal request is returned | Reading metadata, internal pages or API responses directly. |
| Blind SSRF | Nothing, or only status codes and timing | Port scanning the internal network, triggering actions, confirming reachability through callbacks to an external server. |
| Semi-blind SSRF | Error messages or partial content | Inferring which hosts and ports exist from different errors. |
Why simple filters fail
Blocking the string 169.254.169.254 or localhost is not enough. Attackers use alternative IP notations (decimal, octal, IPv6 forms), DNS names that resolve to internal addresses, open redirects on allowed domains, and DNS rebinding, where a hostname resolves to a public address during validation and to an internal one when the request is sent. URL parsers in different libraries also disagree about edge cases, so a check and the actual request can see different hosts.
Preventing SSRF
- Avoid user-controlled URLs where possible: let users choose from known integrations or upload files instead of providing arbitrary URLs.
- Allowlist destinations: permit only the schemes, hosts and ports the feature needs, typically
httpsto specific domains. - Validate the resolved IP, not the name: resolve DNS, reject private, loopback, link-local and metadata ranges, then connect to exactly that IP so rebinding cannot change it.
- Disable redirects or validate every redirect target with the same rules.
- Restrict egress at the network level: send outbound fetches through a dedicated proxy or isolated network segment, and block internal ranges with firewall rules or Kubernetes network policies. This follows zero trust thinking: internal services should not trust a request just because it comes from inside.
- Harden cloud metadata: on AWS, require IMDSv2, which uses a session token obtained with a PUT request and blocks most simple SSRF requests; similar header requirements exist on other clouds.
- Apply least privilege to instance roles and service accounts, so stolen credentials can do little.
- Do not return raw responses: return only what the feature needs, such as a title for a link preview, and generic error messages.
# safer pattern (simplified)
ip = resolve(host)
if not host in ALLOWED_HOSTS or ip.is_private or ip.is_loopback or ip.is_link_local:
reject()
fetch(ip, host_header=host, allow_redirects=False)
Common mistakes
- Validating the URL string but letting the HTTP client follow redirects to internal addresses.
- Forgetting secondary fetchers such as PDF and image renderers, XML parsers with external entities, or webhook testers.
- Assuming that internal services are safe because they are not exposed to the internet.
- Instance roles with broad permissions, which turn a small SSRF into a cloud account compromise.
Detecting SSRF
SSRF is easiest to see from the network and the cloud side. Signals include outbound connections from web servers to metadata addresses, loopback or private ranges they normally do not contact, request parameters containing internal IPs or unusual schemes, many short-lived connections to different internal ports (a sign of blind scanning), DNS lookups for attacker-controlled domains, and cloud API calls made with instance credentials from an IP address outside your environment. Such signals can become indicators of compromise in a SIEM.
SSRF in Kubernetes and microservices
In a cluster, a single vulnerable service can usually reach many others by DNS name, because the default network model allows pod-to-pod traffic. Internal APIs often skip authentication for that reason. An SSRF in one service then becomes a way to call admin endpoints, metrics or debug interfaces of other services, or the Kubernetes API if a service account token is mounted. Default-deny network policies, mutual TLS between services, authentication on internal endpoints and not mounting service account tokens where they are not needed reduce what an attacker can reach.
The observability perspective
An SSRF request is an outgoing call that should not exist. Distributed tracing records outgoing HTTP calls as spans with their target host, so an import or preview service that suddenly calls an internal address stands out in the trace and on the service map. Network monitoring shows which connections a host makes, and cloud audit logs show what was done with the server's credentials. Together these signals answer the questions that matter in an incident: which endpoint was abused, what was reached and whether credentials were used elsewhere.
How Obseria helps
Obseria makes the traces of SSRF visible; it does not block requests and is not a WAF or firewall. Distributed tracing shows outgoing calls of each service with their targets, and network monitoring helps you discover unexpected connections between hosts and to the outside. Cloud security posture management checks AWS, Azure and Google Cloud accounts against security rules and benchmarks, and IaC security checks Terraform and Kubernetes manifests for insecure configuration before deployment. Access logs and cloud audit logs can be searched together in Security Log Analytics. Restricting destinations stays in your code, proxy and network policies.