Security rules
NGB076: Server-side request forgery
Traces request data (Express / Node query, params, body, cookies, headers) into the destination of outgoing requests made with Node.js HTTP clients in server code: http.get/request, https.get/request, axios, got, node-fetch, undici, superagent, and needle.
| Property | Value |
|---|---|
| Rule ID | NGB076 |
| Category | Angular SSR security |
| Default severity | high |
| CWE | CWE-918 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Traces request data (Express / Node query, params, body, cookies, headers) into the destination of outgoing requests made with Node.js HTTP clients in server code: http.get/request, https.get/request, axios, got, node-fetch, undici, superagent, and needle. Browser APIs and the global fetch() are covered by NGB026, the Host header by NGB042.
Why it matters
SSR servers and BFFs run inside the network perimeter: they can reach cloud metadata endpoints (169.254.169.254), internal admin APIs and databases. If a client chooses the host of a server-side request it can read those services through your server (SSRF); with only the path chosen it can still call internal endpoints you never meant to expose.
Detection behavior and supported patterns
axios.get(req.query.url),got(${req.body.webhook}),https.get({ host: req.query.host }),fetch(url)imported fromnode-fetch/undici…- Origin control (the request value is first or follows only a scheme) — high; path control after a fixed
https://host/or/— medium - Recognized validation: host allowlists and same-origin checks dominating the call (as NGB011 / NGB026),
encodeURIComponent()on path segments, numeric conversion
Example
const preview = await axios.get(req.query.url as string);Safer alternative
const target = new URL(String(req.query.url));if (!ALLOWED_HOSTS.has(target.hostname)) return res.sendStatus(400);const preview = await axios.get(target.toString());Remediation
Do not let clients choose request destinations. Map an identifier to a configured URL, or parse the value with new URL() and compare hostname against an allowlist (and block private address ranges after DNS resolution). Encode path segments with encodeURIComponent().
False-positive considerations
- Destinations validated by a project function (
if (isAllowed(url))) are reported with lowered confidence; register the check as an inline allowlist comparison or document an exception.
Known limitations
- Client instances (
axios.create({ baseURL })thenapi.get(path)) are not followed; only module-level calls are matched. - DNS rebinding and redirects to internal hosts after an allowlisted host are not assessed.
References
Run it
ngbastion explain NGB076