The vulnerability described is a cross-site request forgery (CSRF) issue in the github.com/modelcontextprotocol/go-sdk. The root cause is the failure of the HTTP server to validate the Origin and Content-Type headers of incoming requests. This allows a malicious website to make unauthorized POST requests to a local server running the vulnerable SDK.
The analysis of the provided commit a433a831d6e5d5ac3b9e625a8095aa8eaa040dfc reveals that the core changes were made in the mcp/streamable.go file. Specifically, the (*StreamableHTTPHandler).ServeHTTP function was modified to include validation for both the Origin and Content-Type headers.
Before the fix, this function would process any POST request regardless of its origin or content type. An attacker could craft a simple HTML form on a malicious website that sends a POST request with Content-Type: text/plain to the local MCP server. Because this is a CORS-safelisted request, the browser would send it without a preflight OPTIONS request, and the vulnerable server would accept and process it.
The patch introduces explicit checks. It uses h.opts.CrossOriginProtection.Check(req) to validate the Origin header and then checks if the Content-Type header is exactly application/json for POST requests. If either of these checks fails, the request is rejected with an appropriate HTTP error status.
Therefore, the function (*StreamableHTTPHandler).ServeHTTP is the exact location of the vulnerability. During an exploit, this function would be present in the call stack as it's the primary handler for processing the malicious incoming HTTP request.