The vulnerability is a missing authentication flaw in the optional HTTP transport of the @agenticmail/mcp package. When the server is started with the --http flag, it exposes a /mcp endpoint that, prior to the patch, had no authentication mechanism.
The root cause is located in packages/mcp/src/index.ts, specifically within the anonymous callback function passed to node:http.createServer. This function is the main entry point for all HTTP requests. Before the fix, it would accept and process any request to the /mcp endpoint without verifying the client's identity.
An attacker could send a JSON-RPC request to call the tools/call method. This request would be processed by the vulnerable request handler, which would then invoke the handleToolCall function. This downstream function is responsible for executing various tools, including highly privileged, "master-key-only" administrative functions such as setup_email_relay, setup_email_domain, and delete_agent. The MCP server would execute these tools using its own configured master key, effectively allowing an unauthenticated remote attacker to perform administrative actions.
The patch mitigates this vulnerability by introducing a mandatory bearer token authentication system. It adds a checkAuth function and invokes it at the very beginning of the createServer request handler. It also changes the default network binding from all interfaces to 127.0.0.1 to reduce the attack surface. If a valid token is not provided, the request is rejected with a 401 Unauthorized error, preventing access to the sensitive tool-handling functions.