Unauthenticated Remote Takeover of Nginx-UI via MCP Endpoint
Nginx-UI is vulnerable to unauthenticated remote takeover due to a missing authentication check on the `/mcp_message` endpoint, allowing attackers to invoke MCP tools without authentication, leading to arbitrary nginx configuration modification, traffic interception, service disruption, configuration exfiltration, and credential harvesting; the default empty IP whitelist allows access from any network attacker.
The nginx-ui MCP (Model Context Protocol) integration exposes two HTTP endpoints: /mcp and /mcp_message. While /mcp requires authentication, the /mcp_message endpoint only applies IP whitelisting - and the default IP whitelist is empty, which the middleware treats as "allow all". This vulnerability, affecting nginx-ui versions 1.99 and earlier, allows any network attacker to invoke all MCP tools without authentication via the /mcp_message endpoint. This includes restarting nginx, creating/modifying/deleting nginx configuration files, and triggering automatic config reloads. Successful exploitation leads to complete nginx service takeover. This is critical for defenders as it provides an unauthenticated pathway to control a critical piece of infrastructure typically fronting web applications.
Attack Chain
- Attacker sends an HTTP POST request to
http://target:9000/mcp_messagewith a JSON payload. - The request bypasses authentication checks due to the missing
AuthRequired()middleware on the/mcp_messageendpoint. - The
IPWhiteList()middleware allows all requests because the default IP whitelist is empty. - The request is routed to the
mcp.ServeHTTP()handler. - The attacker invokes the
nginx_config_addMCP tool to create a malicious nginx configuration file, for example in/etc/nginx/conf.d/. - The
nginx_config_addtool writes the malicious configuration file to disk. - After the config is written,
nginx_config_addattempts to reload nginx configuration vianginx.Control(nginx.Reload). - The attacker now controls the Nginx webserver and can intercept traffic, redirect users, and exfiltrate data.
Impact
Successful exploitation of this vulnerability grants an unauthenticated attacker complete control over the nginx service. This allows the attacker to intercept traffic, rewrite server blocks, capture credentials and session tokens, and disrupt service by writing invalid configurations. All existing nginx configurations are readable via nginx_config_get, potentially revealing backend topology and authentication headers. This poses a significant risk to organizations relying on nginx-ui to manage their web servers.
Recommendation
- Apply the patch suggested in the advisory by adding
middleware.AuthRequired()to the/mcp_messageroute to prevent unauthenticated access (reference: GitHub advisory). - Deploy the Sigma rule "Detect Nginx-UI MCP Message Endpoint Usage" to identify potential exploit attempts in your environment (reference: Sigma rule below).
- Monitor network connections to port 9000 (default nginx-ui port) for suspicious POST requests to
/mcp_message(reference: IOC). - Consider changing the default IP whitelist behavior to deny-all when unconfigured (reference: GitHub advisory).
Detection coverage 2
Detect Nginx-UI MCP Message Endpoint Usage
highDetects requests to the /mcp_message endpoint in Nginx-UI, which is vulnerable to unauthenticated command execution.
Detect Nginx-UI Config Modification via MCP Message
criticalDetects requests to the /mcp_message endpoint that include 'nginx_config_add' or 'nginx_config_modify' in the request body.
Detection queries are available on the platform. Get full rules →
Indicators of compromise
1
url
| Type | Value |
|---|---|
| url | http://target:9000/mcp_message |