Skip to content

fix: refuse to provision a group over an account it does not own - #36

Merged
vitormattos merged 1 commit into
fix/restrict-subadmin-group-additionsfrom
fix/refuse-adopting-foreign-accounts
Nov 14, 2026
Merged

vitormattos merged 1 commit into
fix/restrict-subadmin-group-additionsfrom
fix/refuse-adopting-foreign-accounts

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

Depends on #35.

Purpose

createAdminGroup uses groupid as both the group ID and the user ID of the group admin. When an account with that ID already existed, it was reused as is: its display name, email and quota were overwritten, it was added to the new group and made its subadmin, while keeping its password and its other groups. An account created in advance with the ID of a future customer therefore became that customer's group admin, still controlled by whoever created it. The same applied to existing admin accounts. The email was also validated only after the group, its quota and the apps job were already created, leaving partial state behind on invalid input.

Changes

  • Before any change: validate the email and validate groupid with IUserManager::validateUserId.
  • Refuse with 409, without changing anything, when groupid is admin, or when an account with this ID exists and is not already the subadmin of the group with the same ID, or is an admin or delegated admin. Provisioning an existing group again keeps returning 200.
  • Reorder the creation: group, user, membership and subadmin first; quota and apps only after that.
  • OpenAPI spec and TypeScript types updated for the new 409 response.

Verification

  • Psalm, PHP CS Fixer, PHP lint and composer run openapi pass locally.
  • The repository has no PHPUnit or Behat suite yet, so this was checked against a local Nextcloud 33 with the app installed:
    • an existing account that belongs to another group gets 409 and keeps its email and groups; no group is created;
    • groupid=admin gets 409 and the admin account is unchanged;
    • provisioning an already provisioned group again returns 200;
    • an invalid email no longer leaves a group or a user behind.

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
@YvesCesar
YvesCesar force-pushed the fix/refuse-adopting-foreign-accounts branch from 6e063b4 to 90ab1d3 Compare November 14, 2026 15:20
@vitormattos
vitormattos merged commit 06a2355 into fix/restrict-subadmin-group-additions Nov 14, 2026
25 of 33 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