security: add 6.28 Prevent Server-Side Request Forgery (SSRF) #292 Update - #1407
Open
jp-bmn wants to merge 1 commit into
Open
security: add 6.28 Prevent Server-Side Request Forgery (SSRF) #292 Update#1407jp-bmn wants to merge 1 commit into
jp-bmn wants to merge 1 commit into
Conversation
- Add sections/security/prevent-ssrf.md with full best practice doc:
- One Paragraph Explainer covering attack vectors (metadata endpoints,
internal services, file://, DNS rebinding)
- Vulnerable code example with annotated attacker payloads
- Safe code example: WHATWG new URL() parse, protocol + domain
allowlist, ssrf-req-filter DNS resolution, redirect: 'error'
- Node.js 20+ --experimental-permission --allow-net defence-in-depth
- 9-point defence checklist including redirect-bypass and
url.parse() deprecation warnings
- OWASP + Snyk blog quotes
- Update README.md:
- Section 6 count: 25 -> 26
- Add 6.28 ToC entry with #new tag
- Add 6.28 section body with OWASP A10:2021 SSRF badge
Closes open SSRF ticket (originally filed 2018, now addressed for
Node.js 2024 edition using native fetch, WHATWG URL API, and the
Node 20 Permission Model).
This was referenced Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add sections/security/prevent-ssrf.md with full best practice doc:
What The New Section Covers
sections/security/prevent-ssrf.mdfollows the repo template exactly:One Paragraph Explainer — defines SSRF, explains why Node.js is specifically exposed (idiomatic outbound HTTP calls via
fetch/axios/http.request), lists concrete attack vectors (AWS metadata endpoint169.254.169.254, internal services,file:///gopher://protocol abuse), and states the three-layer defence. Warns explicitly against the deprecatedurl.parse()in favour of the WHATWGnew URL()constructor.Code Example – vulnerable — a minimal Express route where
req.query.urlflows directly intofetch(), with four real attacker payloads shown as comments (AWS IAM credentials, internal service,/etc/passwd, Redis via gopher).Code Example – defence in depth — the same route hardened with four sequential guards: WHATWG URL parsing,
https:protocol enforcement, domain allowlist viaSet, and DNS-resolution blocking viassrf-req-filter. Redirects are disabled (redirect: 'error') to prevent open-redirect bypass.Code Example – Node.js 20+ runtime flag — shows
--experimental-permission --allow-net=as a defence-in-depth layer with a clear note that it is experimental and complements, not replaces, application-level validation.Defence checklist — nine actionable items covering: no raw user URLs, allowlist over blocklist,
https:only,new URL()overurl.parse(), DNS resolution before connect, DNS-rebinding mitigation, redirect re-validation,eslint-plugin-securityin CI, and the Node 20+ permission model.Two blog quotes — OWASP SSRF Prevention Cheat Sheet and Snyk Blog (SSRF in Node.js), per the repo's evidence-based writing guideline.
Why This Was Prioritized
SSRF is OWASP A10:2021 — a named, ranked vulnerability class that nodebestpractices currently does not address at all. Any developer following this guide to secure their Node.js application has no guidance on a class of attack that can directly expose cloud credentials, internal services, and running-process secrets. The attack surface is particularly sharp for Node.js because
fetch()andaxiosare idiomatic and the mistake is easy to make without realising it.Although the ticket has been open for 8 years now, there is no issue in verifying the security standards of the current model and improving functionality.
Closes open SSRF ticket (originally filed 2018, now addressed for Node.js 2024 edition using native fetch, WHATWG URL API, and the Node 20 Permission Model).