Skip to main content
Menu
Advisories

Self-check fix endpoint rewrites live nginx.conf without interactive secure-session step-up

GHSA-CP4H-7PXC-XX3MPublished Updated GitHub

Description

POST /api/self_check/:name/fix triggers a self-check remediation that rewrites the live nginx.conf entry file on disk. The route carries no interactive secure-session (OTP/passkey) step-up, even though every other configuration-to-disk writer in Nginx-UI (settings, config, sites, streams) is gated by RequireSecureSession. A 2FA-enabled administrator session (or a leaked/stolen JWT) can therefore mutate the running nginx configuration without the re-authentication the project enforces on equivalent actions.

Root Cause

The self-check router group is mounted without the step-up middleware:

  • g := r.Group("self_check") at api/system/router.go:37 is reached only through AuthRequired() + Proxy(); it has no RequireSecureSession.
  • Config-writing siblings (POST /settings, POST /config, POST /sites/:name, stream writers) all carry RequireSecureSession.

SelfCheckFix → self_check.AttemptFix(name) → the task's FixFunc → os.WriteFile(nginx.GetConfEntryPath(), ...) in internal/self_check/nginx_conf.go (e.g. FixNginxConfIncludeConfD, FixNginxConfIncludeSites, FixNginxConfIncludeStreams). The write re-serializes the whole nginx.conf via a gonginx parse→dump round-trip and persists it unconditionally when the expected include directive is absent.

Impact

Integrity drift of the live nginx configuration surface without the step-up that guards all other config writes (I:L — content constrained to standard include ...; directives plus a timestamped .bak). A lossy parse/dump round-trip can mangle the existing config so the next reload fails, and .bak.<ts> files accrue (A:L). Via Proxy() + X-Node-ID the same action reaches child cluster nodes.

Proof of Concept

POST /api/self_check/NginxConf-ConfD-Include/fix HTTP/1.1
Host: <controller>
Authorization: Bearer <valid JWT, no fresh X-Secure-Session-ID>

The live nginx.conf entry file is re-dumped and an include .../conf.d/*; directive injected (or a whole http{}/stream{} block appended if absent) with no re-authentication prompt.

Attack Chain

  1. Entry: POST /api/self_check/NginxConf-ConfD-Include/fix with a valid JWT of a 2FA-enabled admin WITHOUT a fresh X-Secure-Session-ID.
  • Guard: AuthRequired() + IPWhiteList() (api/system/router.go bare g group; routers.go:123). Bypass proof: AuthRequired only proves JWT possession (no role gate); IPWhiteList is a no-op when AuthSettings.IPWhiteList is empty (default).
  1. Routing: request reaches SelfCheckFix → AttemptFix("NginxConf-ConfD-Include").
  • Guard: should be RequireSecureSession as on config-writer siblings. Bypass proof: the self_check group at api/system/router.go:37 has no middleware; routers.go:123 mounts InitPrivateRouter on bare g (AuthRequired()+Proxy() only).
  1. Sink: FixNginxConfIncludeConfD() re-serializes and os.WriteFiles the live nginx.conf entry file (internal/self_check/nginx_conf.go), injecting include .../conf.d/*;.
  • Guard: none on this path. Bypass proof: write is unconditional once the task runs; no X-Secure-Session-ID is demanded, unlike the gated siblings.
  1. Impact: live nginx.conf rewritten / conf directories created without the OTP step-up that guards all other config writes.

Bypass Evidence

grep across api/ shows RequireSecureSession present on settings/config/sites/streams writers but absent from both self_check groups. Task registry (internal/self_check/tasks.go) confirms the write sinks are reachable through the fixable task keys. Code verified present on release tag v2.8.4: git show v2.8.4:api/system/router.go shows g := r.Group("self_check") with no step-up.

Affected Versions

<= 2.8.4 (verified byte-identical v2.8.4 → HEAD; no post-release fix).

Suggested Fix

Mount the self_check fix routes under RequireSecureSession (and RejectInDemo) as the other configuration-to-disk writers are, so remediation that rewrites nginx.conf requires a fresh interactive secure session.

--- Reported by zx (Jace) — GitHub: @manus-use

Affected versions

References

GitHub · 0xJacky/nginx-ui