# SSRF Cross Protocol Redirect Bypass

The Node.js 'request' library deletes its agent on cross-protocol redirects, dropping the ssrf-req-filter createConnection guard and allowing SSRF to localhost.

- Payout: Research
- Severity: high
- Program: request
- Credited: Doyensec
- Disclosed: 2023-03-15
- CVE: CVE-2023-28155
- Write-up quality: 7/10
- Original: https://blog.doyensec.com/2023/03/16/ssrf-remediation-bypass.html
- Library page: https://bugbountylibrary.com/r/blog%3Ablog-doyensec-com-2023-03-16-ssrf-remediation-bypass-html
- Tags: domain:web impact:internal-access kind:research platform:research sev:high tech:nodejs technique:incomplete-fix technique:source-review vuln:open-redirect vuln:ssrf

**Target:** Node.js HTTP client library (request) with ssrf-req-filter agent
**Root cause:** lib/redirect.js deletes request.agent whenever a redirect switches protocol (https->http), because a native Node agent can't serve both protocols. The SSRF filter's createConnection event handler lives on that agent, so the guard is silently removed.
**Steps:**
1. Set up attacker server with open redirect: `<?php header('Location: '.$_GET["target"]); ?>`
2. Victim code: `request({uri: url, agent: ssrfFilter(url)})`
3. Direct request to `http://localhost/test` is blocked: 'Call to 127.0.0.1 is blocked.'
4. Send `https://attacker/redirect.php?target=http://localhost/test` — protocol switch https->http deletes the agent
5. Redirect to internal target succeeds, statusCode 200
**How found:** During a routine retest of a previously reported SSRF, the client had added ssrf-req-filter. The researcher tested a redirect bypass, saw it blocked, then tried flipping the scheme from http to https and noticed the block disappeared — leading to reading lib/redirect.js and finding the agent deletion on protocol change.
**Exploitation:** Attacker hosts an open redirect on an external domain; victim server's request library follows the redirect across a protocol boundary, discarding the ssrfFilter agent, and the follow-up request to the internal address is made unfiltered.
**Insight:** Anti-SSRF agents hook createConnection; any code path that swaps or deletes the agent (cross-protocol redirects, per-protocol agent options) silently disables the filter. Test redirects that change scheme, not just host, and check whether both httpAgent and httpsAgent are set in axios-style configs.
