Skip to main content

safeFetch

@forge/monorepo


@forge/monorepo / backend/src / safeFetch

Function: safeFetch()

safeFetch(target, options?): Promise<SafeResponse>

Defined in: backend/src/toolkit/ssrf.ts:323

Fetches a URL with every vector closed, following redirects by re-running the whole check on each hop.

The shared createHttpClient refuses redirects outright, which is the right answer for a vendor API and the wrong one here: a great many real pages are one redirect away from their canonical URL, and a scraper that cannot follow http → https or example.com → www.example.com is a scraper that fails on ordinary input.

So redirects are followed, and the price is that each hop is a fresh, untrusted URL. It gets refuseUrl and resolvePublicly exactly as the first one did. A chain that starts public and ends at 169.254.169.254 is refused at the hop that turns private, which is the only place it can be caught.

Parameters

target

string

options?

SafeFetchOptions = {}

Returns

Promise<SafeResponse>