Skip to content

[WIP] BB-3812 Require ADMIN permission for SecurityAdmin CSV import endpoints#1

Draft
AlexArchiPro wants to merge 1 commit into
3from
bugfix/bb-3812-securityadmin-import-admin-check
Draft

[WIP] BB-3812 Require ADMIN permission for SecurityAdmin CSV import endpoints#1
AlexArchiPro wants to merge 1 commit into
3from
bugfix/bb-3812-securityadmin-import-admin-check

Conversation

@AlexArchiPro

Copy link
Copy Markdown

Summary

SecurityAdmin only hid the CSV import UI button from non-admins (in getGridFieldConfig()), but the underlying endpoints remained reachable by any user with CMS_ACCESS_SecurityAdmin. Such a user could POST a crafted CSV to the group import endpoint assigning an ADMIN PermissionCode to a group, escalating to full admin.

This change gates the actual endpoints, matching the existing UI-level restriction:

  • ImportForm() now returns false (no form) unless Permission::check('ADMIN') passes, which blocks both fetching the form and submitting it (the form cannot be re-instantiated for request handling).
  • A new import() override denies the form action with a 403 unless the user has ADMIN, as defence-in-depth for the CSV import handler inherited from ModelAdmin.

Jira: https://archipro.atlassian.net/browse/BB-3812

Testing

  • php -l code/SecurityAdmin.php with PHP 8.1: no syntax errors.
  • PHPUnit was not run: this branch requires PHP ^8.3 and silverstripe/framework ^6.1, and SecurityAdminTest is a FunctionalTest requiring a full CMS install plus a configured database, which is impractical in this environment. There are no existing tests covering ImportForm/import in this module.
  • Manual code trace: ImportForm is the only entry in $allowed_actions; the import form action is dispatched through the ImportForm endpoint, so both paths are now gated by Permission::check('ADMIN').

ImportForm was reachable by any user with CMS_ACCESS_SecurityAdmin even
though the import button is hidden for non-admins in getGridFieldConfig().
A non-admin could POST a CSV assigning an ADMIN PermissionCode to a group
and escalate privileges.

Gate both the ImportForm endpoint and the import form action behind
Permission::check('ADMIN'), matching the existing UI-level restriction.
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.

1 participant