SSRF via non-enforcing private-IP check in link-shortener validate endpoint
Description
The link-shortener module of @profullstack/mcp-server has an explicit private-IP/loopback detection control in validateUrl, but the control is broken: on a private-IP match it only calls console.warn and never throws, so control falls through and the URL is accepted. An unauthenticated attacker can therefore drive a server-side fetch(url,{method:'HEAD'}) to arbitrary internal hosts, obtaining a blind port/reachability/redirect oracle (SSRF).
Root Cause
validateUrl (utils.js:12-66) builds privatePatterns for localhost/127./192.168./10./172.16-31/::1/fe80: (utils.js:43-51) with the comment "Check for localhost/private IPs in production" — but the match handler is if (isPrivate) { console.warn(...) } (utils.js:53-56) with no throw/return false; control falls through to return true (utils.js:65). Notably, the same function DOES throw for file:/ftp:/javascript: schemes (utils.js:59-63), proving the author intended to reject dangerous inputs and simply failed to enforce the private-IP block — a genuine broken security control, not works-as-designed.
Impact
Blind SSRF via HEAD requests: an unauthenticated attacker learns internal host reachability, open ports, and redirect targets (status, statusText, redirected, finalUrl). HEAD-only with no body reflection bounds the impact to a reachability/redirect oracle.
Proof of Concept
POST /link-shortener/validate
Content-Type: application/json
{"url":"http://internal-host/","checkAccess":true}Attack Chain
- Entry:
POST /link-shortener/validate(index.js:32->controller.js:168) with an internal-hosturlandcheckAccess:true. Guard: none (no auth). Bypass proof:src/core/middleware.jshas no authentication layer. - Check:
validateUrl(url)(utils.js:12-66). Guard: private-IP patterns exist (utils.js:43-51). Bypass proof: a match only triggersconsole.warn(...)(utils.js:55) with NOthrow/return; control falls through toreturn true(utils.js:65). - Sink:
if (checkAccess) linkService.validateUrlAccess(url)(controller.js:193) ->fetch(url,{method:'HEAD'})(service.js:166). Guard: none blocking. Bypass proof: reached only after the non-blocking warn. - Impact:
{status,statusText,redirected,finalUrl}returned (service.js:174-182) — internal reachability + redirect oracle.
Bypass Evidence
utils.js:53-56: const isPrivate = ...; if (isPrivate) { console.warn(...) } with no throw; control reaches return true at utils.js:65. The scheme block at utils.js:59-63 DOES throw, demonstrating the private-IP path is a broken (non-enforcing) control.
Affected Versions
<= 1.4.12 (code present on HEAD; package.json = 1.4.12, no tags beyond).
Suggested Fix
Make the private-IP detection enforcing: throw (or return false) when isPrivate is true, mirroring the existing scheme rejection. Resolve DNS and re-check the resolved address to prevent DNS-rebinding, and reject redirects to private ranges in validateUrlAccess.
--- Reported by zx (Jace) — GitHub: @manus-use