Glossary · S

Server-Side Request Forgery (SSRF)

Vulnerability in which an attacker makes a server send HTTP or other requests to destinations of the attacker's choice, often internal systems.

By Obseria TeamUpdated

Definition

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.254 on 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/12 and 192.168.0.0/16, Kubernetes service names and internal APIs without authentication.
  • Other protocols: depending on the HTTP client, schemes such as file:// or gopher:// can read local files or talk to non-HTTP services.

Variants

VariantWhat the attacker seesTypical use
Basic SSRFThe response of the internal request is returnedReading metadata, internal pages or API responses directly.
Blind SSRFNothing, or only status codes and timingPort scanning the internal network, triggering actions, confirming reachability through callbacks to an external server.
Semi-blind SSRFError messages or partial contentInferring 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 https to 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.

Frequently asked questions

In cross-site request forgery (CSRF), the victim's browser is tricked into sending a request to a site where the victim is logged in. In SSRF, the server itself is tricked into sending a request to a destination the attacker chooses. CSRF abuses the user's session, SSRF abuses the server's network position and credentials.

Cloud instances can reach a metadata service at a link-local address that may return temporary credentials for the attached role. An SSRF that reaches it can turn into access to cloud APIs. Requiring IMDSv2 on AWS and keeping instance roles minimal reduces this risk considerably.

In blind SSRF the attacker does not see the response of the forged request. They can still scan internal hosts and ports by observing status codes or timing, trigger actions on internal services, or confirm execution through callbacks to a server they control.

No. Alternative IP notations, DNS names that resolve to internal addresses, redirects and DNS rebinding bypass simple denylists. Use an allowlist of destinations, validate the resolved IP, disable redirects and add network egress controls.

URL imports, link previews, webhook configuration, PDF or image generation from HTML, file fetchers, XML parsers that resolve external entities and integrations where users enter a server address.

Look for request parameters with internal addresses or unusual schemes, outgoing connections from web services to metadata, loopback or private ranges, bursts of connections to different internal ports, and cloud API calls made with instance credentials from outside your network.

Put these concepts into practice

Try Obseria free for 14 days, with OpenTelemetry and no proprietary agents.