COMMON WEAKNESS ENUMERATIONIncomplete

CWE-918

Server-Side Request Forgery (SSRF)

The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.

Abstraction

Base

Structure

Simple

Likelihood of Exploit

High

Understand the problem

What is the problem?

The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.

Terminology

Alternate terms and usages

XSPA

Cross Site Port Attack

SSRF

Server-Side Request Forgery

Root cause

How and when does the problem arise?

Lifecycle phase

Architecture and Design

Lifecycle phase

Implementation

Risk

What does successful exploitation lead to?

Read Application Data

Affected security scopes: Confidentiality

Execute Unauthorized Code or Commands

Affected security scopes: Integrity

Bypass Protection Mechanism

Affected security scopes: Access Control

By providing URLs to unexpected hosts or ports, attackers can make it appear that the server is sending the request, possibly bypassing access controls such as firewalls that prevent the attackers from accessing the URLs directly. The server can be used as a proxy to conduct port scanning of hosts in internal networks, use other URLs such as that can access documents on the system (using file://), or use other protocols such as gopher:// or tftp://, which may provide greater control over the contents of requests.

Defence

How is it prevented and fixed?

  • Maintain an allowlist of allowed domains/IPs
  • Block requests to local/loopback and metadata IP addresses (169.254.169.254)

Verification

How is it detected?

Automated Static Analysis

High
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

MITRE diagram

Weakness relationships and flow

CWE-918 MITRE diagramı