Skip to content

fix: stop subadmins from adding users of other groups to their groups - #35

Merged
YvesCesar merged 4 commits into
mainfrom
fix/restrict-subadmin-group-additions
Nov 16, 2026
Merged

YvesCesar merged 4 commits into
mainfrom
fix/restrict-subadmin-group-additions

Conversation

@YvesCesar

@YvesCesar YvesCesar commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Purpose

createAdminGroup makes the group admin a subadmin of the group. In Nextcloud, a subadmin can add any existing user to a group they manage, with no check on the user being added. Once the user is in that group, the subadmin can edit them (email, password, display name, quota). This let the admin of one group take over users of another group, including the admin of another group. It also exposed those users, and Nextcloud admins, to users-of-group/set-enabled, which enabled or disabled every member of the group.

Changes

  • New BeforeUserAddedListener on BeforeUserAddedEvent. When the author is a signed in user that is neither an admin nor a delegated admin, the addition is only allowed if every group of the target user is managed by the author as subadmin, or if the target is a new account (no group, never logged in, not a subadmin). Otherwise it fails with 403. Requests without a user session (occ, cron) and admins are not affected.
  • users-of-group/set-enabled and the re-provisioning path of admin-group skip admins and delegated admins.

Verification

  • Psalm, PHP CS Fixer and PHP lint pass locally.
  • The repository has no PHPUnit or Behat suite yet, so this was checked against a local Nextcloud 33 with the app installed:
    • a subadmin adding a member of another group to their group gets 403 and can no longer edit that user (before: 200);
    • a subadmin creating a new user in their group still works;
    • an admin adding any user to a group still works;
    • set-enabled with enabled=0 on a group that contains an admin no longer disables the admin.

Depends on #41 for the Psalm and php-cs jobs to pass on PHP 8.5.

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@YvesCesar
YvesCesar force-pushed the fix/restrict-subadmin-group-additions branch from 0677ca9 to b902842 Compare November 14, 2026 15:20
vitormattos
vitormattos previously approved these changes Nov 14, 2026
…ounts

fix: refuse to provision a group over an account it does not own
@YvesCesar
YvesCesar merged commit 826b04a into main Nov 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants