Toutes les vulnérabilités
CRITICALAppSec

APPSEC-API-SSRF

API · API Server-Side Request Forgery

Résumé

Server-Side Request Forgery occurs when an API fetches a remote resource using a user-supplied URL without validating it, so the server is coerced into issuing requests to attacker-chosen destinations (OWASP API7:2023). The vulnerable pattern appears wherever an API accepts a URL it will dereference server-side: webhook targets, link preview/unfurl, import-from-URL, PDF or image rendering, and profile-picture fetch. Because the request originates from inside the trust boundary, an attacker can reach internal-only services, perform port scanning via response-timing differences, or hit the cloud instance metadata endpoint at 169.254.169.254 to exfiltrate the instance role's temporary credentials. The canonical impact is the July 2019 Capital One breach, where an SSRF flaw in a WAF component was used to query the EC2 IMDSv1 metadata service, steal the WAF role credentials, and read about 106 million records from S3; AWS shipped IMDSv2 in November 2019 partly in response. Modern bug-bounty SSRF-to-metadata cases follow the same mechanism.

Comment l’éviter dans votre code

  • Validate user-supplied URLs against an allowlist of hosts, schemes, ports and media types.
  • Block RFC1918, loopback, link-local and 169.254.169.254 ranges after DNS resolution.
  • Disable HTTP redirect following on the fetching client.
  • Enforce IMDSv2 (token-required) and least-privilege instance roles so stolen metadata is limited.
  • Isolate the fetcher on an egress-restricted network and never return the raw upstream response.

Références

Vulnérabilités liées

Tout AppSec →