Self-check fix endpoint rewrites live nginx.conf without interactive secure-session step-up
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")atapi/system/router.go:37is reached only throughAuthRequired()+Proxy(); it has noRequireSecureSession.- Config-writing siblings (
POST /settings,POST /config,POST /sites/:name, stream writers) all carryRequireSecureSession.
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
- Entry:
POST /api/self_check/NginxConf-ConfD-Include/fixwith a valid JWT of a 2FA-enabled admin WITHOUT a freshX-Secure-Session-ID.
- Guard:
AuthRequired()+IPWhiteList()(api/system/router.gobareggroup;routers.go:123). Bypass proof:AuthRequiredonly proves JWT possession (no role gate);IPWhiteListis a no-op whenAuthSettings.IPWhiteListis empty (default).
- Routing: request reaches
SelfCheckFix→AttemptFix("NginxConf-ConfD-Include").
- Guard: should be
RequireSecureSessionas on config-writer siblings. Bypass proof: theself_checkgroup atapi/system/router.go:37has no middleware;routers.go:123mountsInitPrivateRouteron bareg(AuthRequired()+Proxy()only).
- Sink:
FixNginxConfIncludeConfD()re-serializes andos.WriteFiles the live nginx.conf entry file (internal/self_check/nginx_conf.go), injectinginclude .../conf.d/*;.
- Guard: none on this path. Bypass proof: write is unconditional once the task runs; no
X-Secure-Session-IDis demanded, unlike the gated siblings.
- 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