CWE-918OWASP A10:2021OWASP API7:2023

CWE-918: Server-Side Request Forgery (SSRF)

The server fetches a URL supplied by the user, letting an attacker aim the server's own privileged network access at internal systems or cloud metadata.

Also known as: SSRF, Server-side request forgery, URL fetch abuse

Risk

Typically high to critical in cloud environments, where SSRF against the instance metadata endpoint can hand over cloud credentials and, from there, the account.

Definition

What it is

CWE-918 occurs when a server makes an outbound request to a destination that a user can influence, without validating that the destination is allowed. Because the request originates from inside the trust boundary, the attacker borrows the server's network position: reaching internal services that are not exposed to the internet, cloud metadata endpoints that return credentials, link-local addresses, or the loopback interface. Features that fetch a URL, webhooks, link previews, image imports, PDF renderers, document converters, are the usual sites.

Use-cases

How it shows up in real code

Cloud metadata credential theft

A link-preview feature fetches any URL the user submits. The attacker points it at the cloud metadata endpoint (169.254.169.254), and the response returns temporary credentials for the server's role, opening the cloud account.

Reaching an internal admin service

A webhook configuration lets the user set the callback URL. The attacker sets it to an internal address, and the server, trusted on the private network, reaches an admin panel that is not exposed externally.

Port scanning from inside

An image-import feature returns different errors or timings for open and closed ports. The attacker uses it to map the internal network from the outside.

Bypassing an allow-list with a redirect

The server checks the submitted host against an allow-list but then follows redirects. The attacker hosts an allowed URL that 302-redirects to an internal target, and the server follows it.

AI risk

Why AI-generated code has increased the exposure

  • Asked to 'fetch the URL the user provides' for a preview, webhook, or import, assistants generate the straight fetch with no destination validation, because the prompt described the happy path.
  • Generated fetch code typically follows redirects and accepts any scheme and host by default, since those are the library defaults and nothing in the prompt said otherwise.
  • SSRF depends on network context the model cannot see, that the server sits next to a metadata endpoint and internal services, so a generically 'correct' fetch is insecure in the real deployment.
  • Integration features (webhooks, importers, converters) are commonly scaffolded by assistants, and these are precisely the URL-fetching features where SSRF lives.
  • More generated integrations means more outbound-fetch sites, each an independent SSRF opportunity.

Vibe coding

How vibe coding amplifies the risk

  • Vibe coding ships the generated fetch as-is. A 'fetch this URL' feature with no allow-list goes to production because the diff, and the missing validation, is never read.
  • The deployment context that makes SSRF dangerous (a reachable metadata endpoint, internal services) is invisible during local vibe-coded testing, so the feature looks safe right up until it is deployed to the cloud.
  • Prompt-and-ship skips the review where someone would ask 'what if the user points this at an internal address?'.
  • Webhooks, link previews, and importers are popular vibe-coded features, and they are the canonical SSRF sinks.
  • Rapid integration growth adds outbound-fetch endpoints faster than anyone validates each destination.

Detection

How to find it

  • Find every place the server makes an outbound request to a destination derived from user input, webhooks, previews, imports, converters, proxies.
  • Confirm each validates the destination against an allow-list before fetching, rather than fetching whatever it is given.
  • Check that redirects are not blindly followed to new hosts, and that non-HTTP schemes and internal, loopback, and link-local address ranges are rejected.
  • Test by submitting internal, loopback, and metadata addresses and confirm the request is refused before it leaves the server.

Remediation

How to fix it

  • Validate the destination against a strict allow-list of permitted hosts or domains, and reject everything else.
  • Block private, loopback, and link-local ranges and the cloud metadata address, and re-validate after every redirect rather than following redirects blindly.
  • Restrict allowed schemes to what the feature needs (usually https only) and disable unexpected protocols.
  • Isolate the fetching component on a network segment with no access to internal services or the metadata endpoint, and require the metadata service's hardened mode where available.
  • Add a review and CI check for user-controlled outbound requests so new fetch sinks are caught before merge.

Frequently asked questions

What is CWE-918 (SSRF)?
CWE-918, server-side request forgery, is when a server makes an outbound request to a user-influenced destination without validating it, letting an attacker aim the server's trusted network access at internal services or the cloud metadata endpoint to steal credentials.
How have AI assistants and vibe coding increased SSRF risk?
Assistants generate straight URL fetches with no destination validation and default to following redirects and accepting any host, because the prompt described the happy path and the model cannot see the deployment's network context. Vibe coding ships those fetches unread, and the danger stays invisible in local testing because the metadata endpoint and internal services only exist in the deployed cloud environment.
How do I fix SSRF?
Validate destinations against a strict allow-list, block private, loopback, and link-local ranges plus the cloud metadata address, re-validate after redirects, restrict allowed schemes to https, isolate the fetching component from internal services and metadata, and add a CI check for user-controlled outbound requests.

Related weaknesses

Catch CWE-918 before you ship

Tethlyn Audit scans your codebase and its git history for CWE-918 and the rest of the injection & code vulnerabilities class, then ranks each finding by real exploitability and data sensitivity.

See Tethlyn Audit