Node Secret Leaked in nginx Access Logs via Query String Authentication
Description
isTrustedNodeRequest() in internal/middleware/websocket_origin.go accepts the cluster node secret via the URL query string parameter node_secret. Because nginx-ui is the application that manages nginx — and nginx logs all requests including query strings to its access log by default — the secret is written in plaintext to a log file that nginx-ui itself exposes via its own log-reading API endpoints. Any authenticated user with log-read access can retrieve the node secret and use it to bypass all WebSocket authentication.
Details
The vulnerable code in isTrustedNodeRequest():
func isTrustedNodeRequest(r *http.Request) bool { secret := strings.TrimSpace(r.Header.Get("X-Node-Secret")) if secret == "" { secret = strings.TrimSpace(r.URL.Query().Get("node_secret")) // ← written to nginx logs } return secret != "" && secret == settings.NodeSettings.Secret }
When a child node connects to the master via WebSocket, it may authenticate using a URL such as:
ws://master:9000/api/cluster/ws?node_secret=s3cr3t-cluster-key
nginx (acting as a reverse proxy in front of nginx-ui, per the official deployment documentation) logs this request to its access log:
192.168.1.10 - - [02/May/2026:10:00:00 +0000] "GET /api/cluster/ws?node_secret=s3cr3t-cluster-key HTTP/1.1" 101 0 ...
nginx-ui then exposes these logs through two endpoints registered in router/routers.go:
// HTTP polling nginxLog.InitRouter(g) // GET /api/nginx_log — AuthRequired only
// Real-time streaming nginxLog.InitWebSocketRouter(w) // WS /api/nginx_log — AuthRequiredWS only
Both endpoints require only a valid user token — there is no additional role-based access control restricting log access to administrators only.
Attack Scenario — Privilege Escalation
- Attacker authenticates as any valid nginx-ui user (e.g. a read-only user).
- Attacker calls GET /api/nginx_log or opens the WebSocket log stream.
- Attacker searches the nginx access log for requests containing
node_secret=. - Attacker extracts the plaintext secret.
- Attacker uses the secret in
X-Node-Secretheader or?node_secret=query parameter on any WebSocket endpoint:
GET /api/analytic HTTP/1.1 Upgrade: websocket X-Node-Secret: s3cr3t-cluster-key
isTrustedNodeRequest()returns true.CheckWebSocketOrigin()returns true — Origin check is completely skipped.AuthRequiredWS()grants full access as the cluster init user.
The attacker has escalated from a low-privilege user to full cluster-level access without knowing any admin credentials.
Secondary Exposure Vectors
Beyond nginx access logs, node_secret in the query string is also exposed via:
- nginx-ui's own internal audit log (audit.LoggingMiddleware is applied globally in router/routers.go: r.Use(audit.LoggingMiddleware()))
- Any intermediate HTTP proxy or load balancer between nodes
- Browser history if the WebSocket URL is ever constructed client-side
- Referrer headers if the page performs any redirect before the upgrade
Root Cause
The fallback to query string authentication was added to support WebSocket connections from child nodes in cluster mode, where setting custom headers may be inconvenient. However, query string secrets are inherently unsafe because HTTP infrastructure (proxies, loggers, CDNs) treats query parameters as part of the URL and logs them by default.
Recommended Fix
Remove the query string fallback entirely. The X-Node-Secret header is already supported and is not logged by default:
func isTrustedNodeRequest(r *http.Request) bool { secret := strings.TrimSpace(r.Header.Get("X-Node-Secret")) // Do NOT fall back to r.URL.Query().Get("node_secret") return secret != "" && secret == settings.NodeSettings.Secret }
If query string support is required for legacy clients, at minimum:
- Exclude requests containing
node_secretfrom nginx access log using log_format with a conditional, and document