The security vulnerability is a Server-Side Request Forgery (SSRF) in the HackMD MCP server, identified as GHSA-g5cg-6c7v-mmpw. The root cause is the lack of validation for the hackmdApiUrl parameter, which can be controlled by an attacker through HTTP headers or query parameters.
My analysis of the patch commit 43936c78a5bb3dedc74e8f080607a1125caa8c13 reveals the exact location of the vulnerability and the subsequent fix. The vulnerable code path originates in the main request handler for the HTTP transport, specifically the anonymous function handling app.post("/mcp", ...) in index.ts.
In the vulnerable version, this handler would call the parseConfig function to extract the hackmdApiUrl from the request. This URL was then used to initialize the MCP server's API client without being checked against an allowlist. This allowed an attacker to force the server to make requests to arbitrary internal or external services.
The patch addresses this by introducing an allowlist mechanism. A new environment variable, ALLOWED_HACKMD_API_URLS, is used to define a set of trusted base URLs. The app.post("/mcp") handler was modified to include a validation step using a new function, isAllowedApiUrl, which checks the provided hackmdApiUrl against this list. If the URL is not permitted, the request is rejected with a 400 status code, effectively mitigating the SSRF risk.
Therefore, the key functions that would appear in a runtime profile during exploitation are the app.post("/mcp") handler, which is the entry point for the malicious request, and the parseConfig function, which extracts the malicious payload.