Summary
An unauthenticated network attacker can claim the initial administrator account on a fresh nginx-ui instance during the first-run setup window. The public /api/install endpoint is reachable without authentication, and the request-encryption flow only protects payload confidentiality in transit; it does not authenticate who is allowed to perform installation. A remote attacker who reaches the service before the legitimate operator can set the admin email, username, and password, causing permanent initial-instance takeover.
Details
The vulnerable route is exposed publicly through the main API router. router/routers.go:61-70 mounts system.InitPublicRouter(root) under /api, and api/system/router.go:16-19 registers both GET /api/install and POST /api/install without AuthRequired().
The install handler only checks whether the instance is already installed and whether more than ten minutes have elapsed since startup. api/system/install.go:26-33 treats the instance as uninstalled when JwtSecret is empty and SkipInstallation is false. api/system/install.go:56-69 rejects requests only if installation has already happened or the ten-minute window has expired.
If those checks pass, the unauthenticated caller controls the initialization flow. api/system/install.go:77-81 generates and saves the JWT secret, node secret, and certificate email from attacker-controlled input, and api/system/install.go:93-97 overwrites user ID 1 with the attacker-chosen username and password hash. internal/kernel/init_user.go:15-22 guarantees that privileged user ID 1 exists ahead of time, so there is always an account to claim.
The public-key bootstrap does not add authentication. api/crypto/router.go:5-9 exposes POST /api/crypto/public_key publicly, api/crypto/crypto.go:12-32 returns a server public key to any caller, internal/crypto/crypto.go:44-61 stores a shared keypair in cache, and internal/middleware/encrypted_params.go:25-50 only decrypts encrypted_params before passing the request to the install handler. No request ID, local-only restriction, bootstrap secret, or prior trust check is enforced.
This was verified locally in an isolated lab instance. A fresh instance returned {"lock":false,"timeout":false}, an unauthenticated POST /api/install returned {"message":"ok"}, the instance then flipped to {"lock":true,"timeout":false}, and the on-disk SQLite database showed user ID 1 renamed to the attacker-controlled username with a non-empty password hash.
PoC
The quickest local verification path is the helper script created during validation:
ATTACKER_EMAIL='[email protected]' ATTACKER_USER='attacker' ATTACKER_PASS='Password12345' \
'/Users/r1zzg0d/Documents/CVE hunting/targets/nginx-ui/output/verify/verify_fresh_install_takeover.sh'
Expected proof points:
[1/6] Fresh-instance status:
{
"lock": false,
"timeout": false
}
[3/6] Claiming the initial administrator account...
{
"message": "ok"
}
[4/6] Verifying install is now locked...
{
"lock": true,
"timeout": false
}
[5/6] Verifying the on-disk admin record was overwritten...
{
"id": 1,
"name": "attacker",
"password_len": 60
}
To confirm the final state manually:
sqlite3 '/Users/r1zzg0d/Documents/CVE hunting/targets/nginx-ui/tmp/poc-install-takeover/database.db' \
'select id,name,length(password) from users where id=1;'
Expected output:
1|attacker|60
Manual HTTP reproduction is also straightforward:
- Request
GET /api/installand confirmlock=falseandtimeout=false. - Request
POST /api/crypto/public_keyto obtain the public RSA key. - Encrypt
{"email":"[email protected]","username":"attacker","password":"Password12345"}with that public key and base64-encode the ciphertext. - Submit the ciphertext to
POST /api/installas{"encrypted_params":"..."}. - Re-request
GET /api/installand observe thatlock=true. - Inspect the backing database and confirm user ID
1now belongs to the attacker-controlled username.
Impact
This is an authentication bypass / initial admin claim vulnerability affecting fresh, uninitialized instances that are reachable over the network during the installation window. Any attacker able to reach the service before the legitimate operator can permanently take ownership of the first administrator account and thereby seize control of the application. Because nginx-ui is an administrative interface for Nginx and related host-management features, compromise of the initial admin account can lead to unauthorized configuration changes, certificate management abuse, backup manipulation, service disruption, and broader operational takeover of the managed environment.
A critical operation is accessible without requiring any authentication. Typical impact: any user can invoke the privileged function.
CVE-2026-42221 has a CVSS score of 8.1 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.3.8); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
- Require a single-use bootstrap secret for installation. Generate the token locally on first start, print it only to the server console or write it to a root-owned local file, and require it on
POST /api/install. - Restrict installation endpoints to loopback by default until setup completes. Remote setup should require an explicit opt-in configuration flag, not be enabled automatically on all interfaces.
- Make installer claim atomic and explicitly stateful. Persist a dedicated installation state record, consume the bootstrap token exactly once, and refuse concurrent or repeated initialization attempts even within the startup window.
Frequently Asked Questions
- What is CVE-2026-42221? CVE-2026-42221 is a high-severity missing authentication for critical function vulnerability in github.com/0xJacky/Nginx-UI (go), affecting versions >= 2.0.0, <= 2.3.5. It is fixed in 2.3.8. A critical operation is accessible without requiring any authentication.
- How severe is CVE-2026-42221? CVE-2026-42221 has a CVSS score of 8.1 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/0xJacky/Nginx-UI are affected by CVE-2026-42221? github.com/0xJacky/Nginx-UI (go) versions >= 2.0.0, <= 2.3.5 is affected.
- Is there a fix for CVE-2026-42221? Yes. CVE-2026-42221 is fixed in 2.3.8. Upgrade to this version or later.
- Is CVE-2026-42221 exploitable, and should I be worried? Whether CVE-2026-42221 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-42221 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-42221? Upgrade
github.com/0xJacky/Nginx-UIto 2.3.8 or later.