Skip to content

[2.x] feat(groups)!: the admin, guest and member groups can't be deleted - #5394

Merged
imorland merged 2 commits into
flarum:2.xfrom
glowingblue:sh/protect-core-groups
Nov 3, 2026
Merged

imorland merged 2 commits into
flarum:2.xfrom
glowingblue:sh/protect-core-groups

Conversation

@novacuum

@novacuum novacuum commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Breaking change: DELETE /api/groups/1, /api/groups/2 and /api/groups/3 now answer 403 Forbidden for every actor, administrators included.

Summary

The administrator (1), guest (2) and member (3) groups are built in, and core depends on them:

  • guests are given the guest group (Guest);
  • every registered user is in the member group (User::groups());
  • administrators are identified by the admin group.

Deleting one of them leaves the forum in an inconsistent state. Until now nothing stopped it: an administrator, or anyone granted group.delete, could delete groups 2 and 3, and the API also accepted deleting group 1.

Changes

  • GroupPolicy::delete() force-denies deleting groups 1–3. Because it uses forceDeny(), the denial also applies to administrators, who otherwise pass every ability.
  • EditGroupModal hid the Delete button only for the admin group. It now hides it for the guest and member groups too.

The moderator group (4) and custom groups can still be deleted, by administrators and by users with the group.delete permission.

Breaking change

Any client, script or extension that deletes the admin, guest or member group now gets a 403. There is no supported way to delete these groups.

Tests

  • tests/integration/api/groups/DeleteTest.php (new):
    • nobody can delete groups 1–3, neither an administrator nor a user with group.delete, and the groups still exist afterwards;
    • administrators can delete the moderator group and custom groups;
    • a user with group.delete can delete a custom group;
    • a member without the permission can't delete a group.
  • js/tests/integration/admin/components/EditGroupModal.test.ts (new): Delete is hidden for groups 1–3 and shown for the moderator group and a custom group.

Run on SQLite and on MariaDB with a table prefix, together with the unit suite, PHPStan, yarn test and yarn check-typings.

GroupPolicy now force-denies `delete` for groups 1-3 (administrator,
guest, member), so DELETE /api/groups/{1,2,3} answers 403 for every actor,
administrators included. Core depends on these groups: guests are given the
guest group, every registered user the member group, and administrators
are identified by the admin group. The moderator group and custom groups
can still be deleted.

EditGroupModal hid Delete only for the admin group; it now hides it for
the guest and member groups too.

BREAKING CHANGE: deleting the administrator, guest or member group is
refused with a 403, including for administrators.
@novacuum
novacuum marked this pull request as ready for review November 2, 2026 20:07
@novacuum
novacuum requested a review from a team as a code owner November 2, 2026 20:07
@imorland

imorland commented Nov 3, 2026

Copy link
Copy Markdown
Member

Note

Automated review for @novacuum. Multiple AI models with Flarum-specific knowledge reviewed this pull request for me, and a further agent verified their findings; I haven't read it myself yet. I'll look at this pull request personally as soon as I can.

No actionable findings in #5394 ([2.x] feat(groups)!: the admin, guest and member groups can't be deleted).

The change merges cleanly into 2.x. Claude, Codex and the security reviewer all completed without findings. My independent pass over all four changed files and the authorization call path found no additional issues: forceDeny() takes precedence over administrator access, and other groups retain their existing permission checks.

This assessment is based on reading the code; tests were not run during this review.

@imorland imorland added this to the 2.1 milestone Nov 3, 2026
@imorland
imorland merged commit a1690fd into flarum:2.x Nov 3, 2026
29 checks passed
@imorland
imorland deleted the sh/protect-core-groups branch November 3, 2026 17:53
novacuum added a commit to glowingblue/flarum-framework that referenced this pull request Nov 5, 2026
The groups page's form uploads or removes a group's icon image through core's
IconImageInput and IconImageState, once the group is saved, as the group modal
does. A form whose only change is saved through its own request does not save
the record again.

The built-in groups can't be deleted (flarum#5394), so deletion follows canDelete
alone; the groups descriptor fixture now has the icon image fields, read-only
and without a column.
imorland added a commit to flarum/docs that referenced this pull request Nov 23, 2026
Since flarum/framework#5394, GroupPolicy refuses to delete the admin, guest
and member groups, so DELETE answers 403 even for administrators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants