Nextcloud subadmin → admin takeover when allowed_admin_ranges is set: SubAdmin::isUserAccessible() classifies the admin target via IP-gated isAdmin()
A subadmin could reset the password of an administrator who shared one of their groups, because the admin-target check was skipped when the request came from an IP outside the configured allowed_admin_ranges. The subadmin could then log in as that administrator, gaining full admin control.
- Triaged in 3 hours
- Fixed in 44 days
- Disclosed after 2 months
Summary by the program
A subadmin could reset the password of an administrator who was a member of one of their groups and then log in as that administrator. This was only possible on instances that restrict admin actions to certain IP ranges (allowed_admin_ranges), and only when the subadmin connected from outside those ranges.
Fixed in Nextcloud Server 35.0.2, 34.0.5, 33.0.10, 32.0.16, 31.0.14.12, and 30.0.17.15.
The report
Summary
lib/private/SubAdmin.php::isUserAccessible() decides whether a subadmin may act on a target user. It bars admin / delegated-admin targets, then allows access if they share an administered group. The admin-target guard uses groupManager->isAdmin($user->getUID()) — but Group\Manager::isAdmin() short-circuits to false when admin actions are not allowed from the current request IP (RemoteAddress::allowsAdminActions()), i.e. when allowed_admin_ranges is configured and the requester is outside it. So a subadmin connecting from an IP outside allowed_admin_ranges has the admin-target guard skipped — not because the target isn't an admin, but because of the requester's IP — and the group-intersection then grants the subadmin control of an admin account they share a group with. The subadmin can reset the admin's password and log in as that admin (and likewise disable / enable / delete / wipe the admin). Enabling the allowed_admin_ranges admin-hardening feature is what introduces the escalation.
Lab confirmation (Nextcloud 35.0.0 RC3, own instance, 127.0.0.1 — transcript attached)
Setup: subby = subadmin of group gm; bigadmin = member of the admin group and of gm. All requests from 127.0.0.1.
- Control (
allowed_admin_rangesunset →isAdmin(bigadmin)=true):subbyPUT /ocs/v2.php/cloud/users/bigadminwithkey=password→ failure (ocs 998) — admin protected. ✓ - Exploit (
allowed_admin_ranges=[10.99.0.0/16], request IP 127.0.0.1 is outside →isAdmin(bigadmin)=false): same call → HTTP 200 (ocs 200) — the admin's password is overwritten by the subadmin. ✓ - Verify:
GET /ocs/v2.php/cloud/userasbigadminwith the subadmin-chosen password → HTTP 200,id=bigadmin— full admin takeover. ✓
Only the config (and thus the IP-gate verdict) changes between control and exploit.
Root cause (file:line, verified in 35.0.0 RC3)
lib/private/SubAdmin.php:256—if ($this->groupManager->isAdmin($user->getUID())) return false;(admin-target guard) and:259(delegated-admin guard) — both classify the target via the request-context method.lib/private/Group/Manager.php:324-325isAdmin()→if (!$this->remoteAddress->allowsAdminActions()) return false;— IP gate, not membership;isDelegatedAdmin()(:339) is the same.RemoteAddress::allowsAdminActions()returnsfalsewhenallowed_admin_rangesis set and the request IP is outside it.- The sibling controller paths classify an admin target by IP-independent membership:
apps/provisioning_api/lib/Controller/UsersController.php:1275(editUser),:1533(disable),:1570(enable) useisInGroup($targetUser->getUID(), 'admin').isUserAccessibleis the outlier.
Steps to reproduce
Instance with subadmin S administering group G, and admin A who is also a member of G.
- Control (default config): as S,
PUT /ocs/v2.php/cloud/users/Akey=password&value=<new>→ failure (admin protected). - Exploit: admin sets
'allowed_admin_ranges' => ['10.0.0.0/8']; S connects from an IP outside that range. Same request → 200, A's password is overwritten. S logs in as A.
The only variables changed are the config and the source IP, isolating the IP-gated classification as the cause.
Recommendation
In isUserAccessible(), classify admin / delegated-admin targets by IP-independent membership (groupManager->isInGroup($user->getUID(), 'admin') and the delegated-admin membership check), as the sibling controller paths do. The request-IP gate should restrict what the actor may do, never decide what the target is.
Scope / honest limits
- Conditional: requires the non-default
allowed_admin_rangeshardening to be configured and the subadmin to be outside the range (a natural situation for a remote subadmin when admin logins are IP-restricted to an office range). Where it is not configured,allowsAdminActions()is alwaystrueand the guard works. - Impact when the condition holds is a full subadmin→admin takeover (reset/disable/enable/delete/wipe of admin accounts the subadmin shares a group with).
- No matching public disclosure found on the Nextcloud security-advisories repo or H1 hacktivity; prior-art check advisable.
AI tooling disclosure
AI assistance: Yes — substantial (Claude via the Claude Code harness; source review + drafting). Every file:line read in the running 35.0.0 RC3 code and the escalation dynamically confirmed on a self-hosted instance bound to 127.0.0.1 (transcript attached) — nothing tested against any third-party/production host. The reporter reviews and takes responsibility before submission.
Impact
On an instance that has enabled the allowed_admin_ranges admin-hardening feature, a subadmin connecting from an IP outside the configured range can reset the password of an administrator account they share a group with, and log in as that administrator — a full vertical privilege escalation from subadmin to instance administrator. The same isUserAccessible gate governs disable, enable, delete and remote-wipe, so the subadmin can also disable, delete or wipe admin accounts. Lab-confirmed on Nextcloud 35.0.0 RC3: with allowed_admin_ranges=[10.99.0.0/16], subadmin subby reset admin bigadmin's password via PUT /ocs/v2.php/cloud/users/bigadmin (HTTP 200) and then authenticated as bigadmin — while the same request is blocked (ocs 998) when the config is unset. Ironically, enabling the admin-IP hardening is precisely what introduces the escalation. Conditional (non-default config) but high impact when the condition holds.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The admin-target guard in isUserAccessible() used Group\Manager::isAdmin(), which returns false based on the requester's IP rather than the target's group membership, so the guard was skipped for requests outside allowed_admin_ranges.
Impact
A subadmin outside the allowed range could reset, disable, enable, delete or wipe administrator accounts they share a group with, leading to full admin takeover; this only applies when the non-default allowed_admin_ranges setting is configured.
What the attacker needed
Allowed_admin_ranges is configured; subadmin shares a group with an admin; subadmin connects from outside the range
The fix
The admin and delegated-admin target checks in isUserAccessible() should use IP-independent group membership, as the sibling controller paths do; the text says it was fixed in several Nextcloud Server releases.
How it was found
- As the subadmin, send a password-change request for the admin user while allowed_admin_ranges is unset; it fails because the admin is protected.
- Configure allowed_admin_ranges so the subadmin's source IP is outside the range.
- Send the same password-change request again; it succeeds and overwrites the admin's password.
- Log in as the admin using the new password to confirm takeover.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A subadmin is a helper who can manage some groups but should never control a full administrator. The software has a setting that only lets admin actions happen from certain network addresses. A mistake meant that when a subadmin connected from elsewhere, the software forgot the target was an administrator and let the subadmin change that administrator's password.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.