Injectionserversiderequestforgeryssrf

Server-Side Request Forgery (SSRF)

A user-controlled URL turns the backend’s network position and credentials into an attacker-controlled capability.

▶ Run the labFollow the failure

Frame the problem

Security starts with a concrete asset, attacker capability and trust crossing.

Asset
Internal APIs, metadata services, cloud credentials and network trust.
Attacker & capability
A remote user who can ask the backend to fetch a URL.
Trust boundary
Untrusted URL → privileged server network
AssetThreatAttack SurfaceTrust BoundaryVulnerabilityExploit PathImpactMitigationDefense in DepthResidual Risk

Why the system fails

The fetcher accepts arbitrary destinations, follows redirects or resolves names into internal address space without enforcing a destination policy.

The important question is not “what is Server-Side Request Forgery (SSRF)?” but “which assumption let untrusted data or an over-scoped identity cross untrusted url → privileged server network?” Trace the decision at the boundary, then constrain what can happen after the first control fails.

Design the control in layers

Start with the control closest to the interpretation or privilege boundary: Avoid arbitrary fetching; allowlist destinations and protocols Then add a control that reduces blast radius and telemetry that proves the decision was enforced.

The resulting design is not labelled secure. Record the identified controls, the known failure paths, the remaining exposure, and the evidence you would need during an incident.

PreventDetectRecover
Avoid arbitrary fetching; allowlist destinations and protocols · Resolve and validate destination IPs across redirects · Restrict egress and protect metadata servicesConnections to internal, link-local or unusual destinations · Fetcher responses inconsistent with expected mediaContain the affected identity or component, scope impact from audit evidence, and preserve a regression test.

Key points

  • Asset: Internal APIs, metadata services, cloud credentials and network trust.
  • Boundary: Untrusted URL → privileged server network
  • Primary control: Avoid arbitrary fetching; allowlist destinations and protocols
  • Detection signal: Connections to internal, link-local or unusual destinations
  • Always ask what limits damage when the primary control fails.

SSRF Network Boundary

Change the system and observe which assumption moves.

Boundary control check
Untrusted input / identity
Trust boundary
Privileged asset
Prevention may fail silently.

Follow the attack

Safe conceptual simulation: capability → missing control → crossed boundary → asset impact.

  1. 1
    Attacker starts with: A remote user who can ask the backend to fetch a URL.
  2. 2
    The fetcher accepts arbitrary destinations, follows redirects or resolves names into internal address space without enforcing a destination policy.
  3. 3
    The weak or missing boundary control is crossed: Untrusted URL → privileged server network
  4. 4
    Impact: Internal service access, credential exposure, data exfiltration or actions using the server identity.
Blast radius
  • Internal service access, credential exposure, data exfiltration or actions using the server identity.

Defend, detect, recover

One prevention is a single point of security failure. Layer it and make failure observable.

Prevent
  • • Avoid arbitrary fetching; allowlist destinations and protocols
  • • Resolve and validate destination IPs across redirects
  • • Restrict egress and protect metadata services
Detect
  • • Connections to internal, link-local or unusual destinations
  • • Fetcher responses inconsistent with expected media
Respond & recover
  • • Contain the affected identity or component.
  • • Scope access from audit evidence.
  • • Fix the boundary and add a regression test.
Residual risk
  • • Misconfiguration and new access paths can bypass the intended control.
  • • A privileged insider or compromised control plane may still reach the asset.

Misconceptions

Claim
“A single avoid arbitrary fetching; allowlist destinations and protocols control makes this safe.”
Reality
One control changes risk; it does not erase it. Design prevention, detection, recovery, and blast-radius limits together.