Skip to main content
Menu
Advisories

Unauthenticated SSRF via unvalidated baseUrl in convert2doc module

GHSA-QGCM-WF9M-HQWCPublished Updated GitHub

Description

The convert2doc module of @profullstack/mcp-server accepts a baseUrl field from an unauthenticated request body and uses it verbatim as the target of a server-side fetch(), with the response body reflected back to the caller. Because the server has no authentication middleware, any client that can reach the server can coerce it into issuing requests to arbitrary internal hosts/ports and read the responses — a classic Server-Side Request Forgery (SSRF).

Root Cause

baseUrl is a service-endpoint configuration parameter (docs: "API base URL. Defaults to convert2doc.com"), not the operation subject (the subject is the uploaded file). It is never validated: while fromFormat/toFormat are allowlisted (mcp_modules/convert2doc/index.js:45-58), baseUrl flows verbatim into convertDocument, where the endpoint is built as ${baseUrl}/api/1/<from>-to-<to> (index.js:61) and passed to fetch(endpoint, {method:'POST', headers:{Authorization:'Bearer '+apiKey}, body:...}) (index.js:63). No private-IP/loopback/scheme block exists anywhere in the module.

Impact

An unauthenticated attacker redirects the configurable backend URL to an internal host:port. The server issues the request and reflects the response body verbatim as convertedContent (index.js:83 await response.text()), yielding a read-SSRF against internal services. The "credential leak" framing is void — the apiKey is supplied by the attacker's own request.

Proof of Concept

POST /convert2doc/convert
Content-Type: application/json

{"apiKey":"x","fileContent":"...","fromFormat":"pdf","toFormat":"markdown",
 "baseUrl":"http://127.0.0.1:9200"}

The server issues POST http://127.0.0.1:9200/api/1/pdf-to-markdown and returns the response body as convertedContent.

Attack Chain

  1. Entry: POST /convert2doc/convert (index.js:130) or POST /tools/convert2doc (index.js:230) with baseUrl:"http://127.0.0.1:9200". Guard: none. Bypass proof: src/core/middleware.js registers only request-logging, wildcard CORS, an error handler, and optional IP rate-limiting — no authentication layer exists.
  2. Check: fromFormat/toFormat are allowlisted (index.js:45-58); baseUrl is NOT. Guard: none on baseUrl. Bypass proof: grep of the module shows baseUrl passed verbatim to convertDocument with no validator call.
  3. Sink: endpoint = ${baseUrl}/api/1/pdf-to-markdown (index.js:61) → fetch(endpoint, {method:'POST', ...}) (index.js:63). Guard: none. Bypass proof: no private-IP/loopback/scheme filter anywhere in the module.
  4. Impact: server-issued request to attacker-chosen internal host:port; response body reflected verbatim as convertedContent (index.js:83).

Bypass Evidence

convert2doc/index.js contains zero calls to any URL validator. The fromFormat/toFormat allowlists (lines 45-58) demonstrate the author validates other inputs but leaves baseUrl unchecked (lines 61-63).

Affected Versions

<= 1.4.12 (code present on HEAD; package.json = 1.4.12, no tags beyond).

Suggested Fix

Validate baseUrl against an allowlist of permitted hosts (or a fixed configured host), reject loopback/link-local/private IP ranges after DNS resolution, and restrict the scheme to https:.

Honest constraints: POST-only with a fixed `/api/1/<from>-to-<to>` path suffix, so arbitrary paths (e.g. cloud-metadata endpoints) are not directly reachable; but arbitrary internal host:port with full body reflection is a genuine read-SSRF.

--- Reported by zx (Jace) — GitHub: @manus-use

Affected versions

References

GitHub · profullstack/mcp-server