GHSA-h4hf-v6w5-897x Poweradmin: API user-update endpoint leads to a non-admin reset any user's password and take over the superuser account
SummaryThe REST API user-update endpoint (`PUT/PATCH /api/v2/users/{id}` and the V1 equivalent) does not enforce two authorization rules that the web interface enforces. A user who holds the `user_edit_others` permission but is not a superuser can:edit user accounts that belong to a superuser, andset the password of any account, even without the `user_passwd_edit_others` permission.Because of this, a non-admin "user manager" role can send a single API request that changes the administrator's password, then log in as the administrator. This is a full privilege escalation and account takeover. The same actions are explicitly blocked in the web UI, so the API is inconsistent with the application's own permission model.DetailsPoweradmin's permission model treats these as three distinct permissions:`user_edit_others` (id 57): "User is allowed to edit other users."`user_passwd_edit_others` (id 58): "User is allowed to edit the password of other users."`user_is_ueberuser` (id 53): full admin.The existence of a separate `user_passwd_edit_others` permission means that "edit other users" is not supposed to include changing their passwords. The web UI enforces this, and it additionally forbids any non-superuser from editing a superuser account at all. The API skips both rules.**Where the API is missing the superuser check.**
`lib/Domain/Service/ApiPermissionService.php`, `canEditUser()`:There is no check on whether the target is a superuser. Compare this with the web controller `lib/Application/Controller/EditUserController.php` (lines 237 to 243), which explicitly refuses:The comment in the maintainers' own code calls this "privilege escalation protection." The API has no equivalent.**Where the API is missing the password permission check.**
`lib/Domain/Service/UserManagementService.php`, `updateUser()` (lines 393 to 413) writes the password whenever one is supplied, with no permission check at all (it only refuses when the target is an external-auth user):Compare the web path `lib/Domain/Model/UserManager.php`, `editUser()`, which only writes the password column when the caller has the right permission:**The call path.** `lib/Application/Controller/Api/V2/UsersController.php`, `updateUser()` (lines 701 to 727):So `canEditUser` returns true for any `user_edit_others` holder against any target, and `updateUser` then writes the password with no further check. The V1 controller (`lib/Application/Controller/Api/V1/UsersController.php`) has the same shape.Note: `perm_templ` is separately protected (a `PermissionTemplateAssignmentGuard` rejects it unless the caller has `user_edit_templ_perm`), so an attacker cannot elevate their own template through the API. They do not need to. Resetting the administrator's password and logging in as the administrator achieves full control directly.PoCTested on Poweradmin master (commit 7f28c3a97) and the code path is present in the 4.0.x, 4.1.x, 4.2.x and 4.3.x release branches.**Configuration required (both are common in real deployments, neither is the default):**The REST API must be enabled (`api.enabled = true` in `config/settings.php`). The API is intended for automation such as the Terraform provider, so it is frequently turned on.A delegated "user manager" role must exist: a permission template that grants `user_edit_others` (and typically `user_view_others`) but not `user_is_ueberuser` and not `user_passwd_edit_others`. This is a normal way to let a helpdesk or team lead manage user accounts.**Setup (performed once by the administrator to create the delegated role and the attacker):**As admin, create a permission template named "UserMgr" of type "user" with the permissions "User is allowed to edit other users" and "User is allowed to see other users and their details" only.Create a normal user, for example `umgr`, and assign it the UserMgr template.As `umgr`, create an API key from the user's API keys page. Call it, for example, `pwa_umgr_key`. `umgr` is now the attacker: a non-admin user with a self-scoped API key.**Exploit request (Burp Suite Repeater).** Send this single request. `id` 1 is the administrator account.Expected response (HTTP 200):now we can login to admin user with a new password!The page refuses with "You do not have permission to edit a superuser account." So the same user with the same permission is denied on the web but allowed on the API.Record ids are the normal sequential user ids, and the administrator is usually id 1, so no guessing is required. The attacker can also change `username`, `email`, `active` and `use_ldap` on any account through the same request.ImpactThis is a broken access control and privilege escalation issue (CWE-285 Improper Authorization, CWE-266 Incorrect Privilege Assignment).Who is impacted: any Poweradmin installation that has the REST API enabled and that has created at least one non-admin role holding `user_edit_others` (a delegated user-manager or helpdesk role). On such an installation, any holder of that role, using nothing more than their own API key, can reset the superuser's password and take over the administrator account. From there they control every zone, record, user and setting in Poweradmin, and, through the PowerDNS backend, the DNS data itself.The severity is high because the outcome is full administrative takeover from a low-privilege authenticated position, over the network, with a single request and no user interaction. The reason it is not rated critical outright is the precondition that a delegated `user_edit_others` role exists and the API is enabled. The underlying defect is real regardless of configuration: the API does not enforce the superuser-edit protection or the `user_passwd_edit_others` permission that the web interface enforces, so the API grants more authority than the permission model intends.Suggested fix: mirror the web guards in the API. In `ApiPermissionService::canEditUser`, reject a non-superuser editing a superuser target. In `UserManagementService::updateUser`, only write the password when the caller is editing their own account or holds `user_passwd_edit_others`. Apply the same to both V1 and V2 controllers.DisclosureCredit: Found by Saif Salah (https://saifsalah.github.io/)
Found during a security review of Poweradmin. Happy to coordinate a fix timeline and CVE before any public write-up.
CVSS v3.1 score: 8.8