Unauthenticated SQL Execution and RCE in MySQL MCP Server via SSE Transport
The mysql_mcp_server package (v < 0.4.2) fails to implement security protections in SSE transport mode, enabling unauthenticated attackers to perform arbitrary SQL execution, data exfiltration, and potential remote code execution.
The mysql_mcp_server package (prior to v0.4.2) contains a critical security vulnerability when configured to use the Server-Sent Events (SSE) transport mode. Due to the failure to instantiate SseServerTransport with security_settings, the application lacks essential protections, including DNS-rebinding prevention, CORS middleware, and TrustedHost validation. Furthermore, the application exposes unauthenticated endpoints (/, /sse, and /messages/) and binds to 0.0.0.0 by default.
An unauthenticated remote attacker can exploit this configuration to execute arbitrary SQL commands against the database backend. If the database user is configured with FILE privileges, this vulnerability enables arbitrary file read and write operations, which can be leveraged to achieve remote code execution by dropping a malicious web shell. Instances exposed to the internet are at high risk, as are local instances susceptible to browser-based DNS-rebinding attacks. 25 publicly reachable instances have already been identified.
Attack Chain
- Attacker identifies an exposed MySQL MCP Server instance running with
MCP_TRANSPORT=sseon a public interface (0.0.0.0). - Attacker sends an unauthenticated HTTP POST request to the
/messagesendpoint. - The request includes a JSON payload containing a malicious SQL query within the
execute_sqltool call. - The server receives the request and, lacking authentication middleware, processes the tool call directly.
- The application invokes
cursor.execute(query)using the attacker-supplied, unsanitized SQL. - The database executes the query, returning results to the attacker or performing file system operations (e.g.,
INTO OUTFILE). - Attacker successfully achieves data exfiltration or writes a malicious payload to the host system.
Impact
Successful exploitation allows for full database exfiltration, modification, and potential system compromise. Attackers can leverage MySQL's FILE privileges to read sensitive files or write executable files (web shells) to the underlying server. Evidence suggests 25 publicly exposed instances are currently reachable, posing an immediate risk to environments utilizing this server for LLM-integrated database tasks.
Recommendation
- Upgrade
mysql_mcp_serverto version 0.4.2 or later immediately to enable mandatory security settings. - Configure the server to bind to
127.0.0.1rather than0.0.0.0if remote access is not required. - Ensure the database user assigned to the MCP server follows the principle of least privilege, specifically revoking
FILEaccess if not strictly required. - Implement network-level access control (firewall or VPN) to restrict access to the SSE transport interface.
Immediate actions
Audit external exposure of services listening on ports associated with MCP implementations
Mitigations
Upgrade mysql_mcp_server to v0.4.2 or later
CVE-2026-59971