SSRF defense library for Node.js with safe URL validation utilities.
npm install dssrfdssrf is a priotized security‑first URL and network validation library designed to eliminate entire classes of SSRF vulnerabilities - from basic bypasses to extremely advanced bypass techniques used in real‑world attacks.
is_url_safe(), your application benefit all of those SSRF protections by default.
bash
npm install dssrf
`
And in your web js app add
`js
import { is_url_safe } from "dssrf";
const url = await is_url_safe("https://example.com");
if (!url) {
throw new Error("SSRF attempt Detected.");
}
`
or for CommonJS style
`js
const dssrf = require("dssrf");
const url = await dssrf.is_url_safe("https://example.com");
if (!url) {
throw new Error("SSRF attempt Detected.");
}
`
Contributions
All contributions are welcome under the MIT license to me.
Warning
- Redirect Safety By default, is_redirect_safe() will not make outbound requests unless you explicitly enable it with the environment variable DSSRF_MAKE_REQUEST=1. - When disabled, You loose redirect safety. - When enabled, dssrf performs controlled HTTP requests (HEAD with followRedirect: false) to inspect Location` headers hop‑by‑hop. - This ensures accurate redirect validation but may expose your server's IP address and timing externally. Use only in environments where outbound validation traffic is acceptable, I recommend disabling it becauses expose your server ip and can cause slowdown and also port scanning/service discovery instead disable following redirects in your http client.