{"id":"GHSA-v667-gc2r-2xm7","summary":"Qinglong has an incomplete fix for CVE-2026-3965: Improper Authentication","details":"### Summary\n\nThe init guard middleware in Qinglong only checks `/api/user/init` paths but not `/open/user/init`, which is whitelisted from JWT authentication and rewritten to `/api/user/init` after the guard has already passed, allowing unauthenticated admin credential reset on initialized instances.\n\n### Affected Package\n\n- **Ecosystem:** npm\n- **Package:** whyour/qinglong\n- **Affected versions:** \u003c 6bec52dca158\n- **Patched versions:** \u003e= 6bec52dca158\n\n### Severity\n\nMedium\n\n### CWE\n\nCWE-287 — Improper Authentication\n\n### Details\n\nThe Qinglong panel has an initialization endpoint (`/api/user/init`) that allows setting admin credentials. Once the system is initialized, an init guard middleware is supposed to block further calls. The middleware in `back/loaders/express.ts` only checks:\n\n```javascript\n!['/api/user/init', '/api/user/notification/init'].includes(pathLower)\n```\n\nHowever, the application also has a URL rewrite rule: `rewrite('/open/*', '/api/$1')`. The `/open/*` paths are whitelisted from JWT authentication.\n\nThe middleware ordering creates the bypass: first, JWT auth sees `/open/*` paths match the whitelist regex and skips authentication. Second, the init guard only checks for `/api/user/init` -- `/open/user/init` passes through as \"not an init path\". Third, the URL rewrite transforms `/open/user/init` to `/api/user/init` after the guard has already passed.\n\nThis means an unauthenticated attacker can send `PUT /open/user/init` with new credentials to reset the admin account on any Qinglong panel instance, gaining full administrative access.\n\n### PoC\n\n```javascript\n/**\n * CVE-2026-3965 - Qinglong Panel /open/user/init Auth Bypass\n *\n * The init guard middleware only checks /api/user/init paths.\n * But /open/user/init is whitelisted from JWT auth and rewritten\n * to /api/user/init via express-urlrewrite AFTER the guard.\n */\n\n\"use strict\";\n\n// Simulate the init guard middleware exactly as in the source\nfunction initGuardMiddleware(reqPath, authInfo) {\n  const pathLower = reqPath.toLowerCase();\n  // Exact check from the vulnerable source\n  if (!['/api/user/init', '/api/user/notification/init'].includes(pathLower)) {\n    return { action: \"next\" }; // passes through\n  }\n\n  let isInitialized = true;\n  if (\n    Object.keys(authInfo).length === 2 &&\n    authInfo.username === 'admin' &&\n    authInfo.password === 'admin'\n  ) {\n    isInitialized = false;\n  }\n\n  if (isInitialized) {\n    return { action: \"block\", code: 450, message: \"Error\" };\n  } else {\n    return { action: \"next\" };\n  }\n}\n\nconst authInfo = { username: \"realAdmin\", password: \"str0ngP@ss!\" };\nconsole.log(\"System state: initialized (non-default credentials)\");\n\n// Test 1: Direct /api/user/init is blocked\nconst test1 = initGuardMiddleware(\"/api/user/init\", authInfo);\nconsole.log(\"\\n[Test 1] PUT /api/user/init:\");\nconsole.log(\"  Guard result:\", test1.action);\nconsole.log(\"  Blocked:\", test1.action === \"block\");\n\n// Test 2: /open/user/init BYPASSES init guard\nconst test2 = initGuardMiddleware(\"/open/user/init\", authInfo);\nconsole.log(\"\\n[Test 2] PUT /open/user/init:\");\nconsole.log(\"  Guard result:\", test2.action);\nconsole.log(\"  Bypassed guard:\", test2.action === \"next\");\n\nif (test2.action === \"next\") {\n  const rewrittenPath = \"/open/user/init\".replace(/^\\/open\\//, \"/api/\");\n  console.log(\"  After rewrite:\", rewrittenPath);\n  console.log(\"  Reaches init handler: true\");\n}\n\nif (test1.action === \"block\" && test2.action === \"next\") {\n  console.log(\"\\nVULNERABILITY CONFIRMED: /open/user/init bypasses the init guard\");\n  console.log(\"An attacker can reset admin credentials on an initialized instance.\");\n  process.exit(0);\n} else {\n  console.log(\"\\nVULNERABILITY NOT CONFIRMED\");\n  process.exit(1);\n}\n```\n\n**Steps to reproduce:**\n1. `git clone https://github.com/whyour/qinglong /tmp/qinglong_test`\n2. `cd /tmp/qinglong_test && git checkout 6bec52dc~1`\n3. `node poc.js`\n\n**Expected output:**\n```\nVULNERABILITY CONFIRMED\n/open/user/init bypasses the init guard; the guard only checks /api/user/init but /open/ path is whitelisted and rewritten after.\n```\n\n### Impact\n\nAn unauthenticated attacker can send `PUT /open/user/init` with new credentials to reset the admin account on any Qinglong panel instance. This provides full administrative access, enabling the attacker to execute arbitrary cron jobs and scripts on the server.\n\n### Suggested Remediation\n\nAdd `/open/user/init` and `/open/user/notification/init` to the init guard check list. Alternatively, move the URL rewrite middleware to run before the init guard. Consider implementing the init guard at the handler level rather than as path-based middleware.\n\n### References\n\n- Incomplete fix commit: https://github.com/whyour/qinglong/commit/6bec52dca158481258315ba0fc2f11206df7b719\n- Original CVE: CVE-2026-3965","aliases":["CVE-2026-55445"],"modified":"2026-08-20T18:45:45.086013533Z","published":"2026-08-20T18:36:59Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2026-08-20T18:36:59Z","nvd_published_at":"2026-07-15T22:17:26Z","cwe_ids":["CWE-287"],"severity":"CRITICAL"},"references":[{"type":"WEB","url":"https://github.com/whyour/qinglong/security/advisories/GHSA-v667-gc2r-2xm7"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-55445"},{"type":"WEB","url":"https://github.com/whyour/qinglong/pull/2941"},{"type":"WEB","url":"https://github.com/whyour/qinglong/commit/6bec52dca158481258315ba0fc2f11206df7b719"},{"type":"PACKAGE","url":"https://github.com/whyour/qinglong"}],"affected":[{"package":{"name":"@whyour/qinglong","ecosystem":"npm","purl":"pkg:npm/%40whyour/qinglong"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.20.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/08/GHSA-v667-gc2r-2xm7/GHSA-v667-gc2r-2xm7.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N"}]}