[WIP] BB-3812 Require ADMIN permission for SecurityAdmin CSV import endpoints#1
Draft
AlexArchiPro wants to merge 1 commit into
Draft
[WIP] BB-3812 Require ADMIN permission for SecurityAdmin CSV import endpoints#1AlexArchiPro wants to merge 1 commit into
AlexArchiPro wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SecurityAdminonly hid the CSV import UI button from non-admins (ingetGridFieldConfig()), but the underlying endpoints remained reachable by any user withCMS_ACCESS_SecurityAdmin. Such a user could POST a crafted CSV to the group import endpoint assigning anADMINPermissionCodeto a group, escalating to full admin.This change gates the actual endpoints, matching the existing UI-level restriction:
ImportForm()now returnsfalse(no form) unlessPermission::check('ADMIN')passes, which blocks both fetching the form and submitting it (the form cannot be re-instantiated for request handling).import()override denies the form action with a 403 unless the user hasADMIN, as defence-in-depth for the CSV import handler inherited fromModelAdmin.Jira: https://archipro.atlassian.net/browse/BB-3812
Testing
php -l code/SecurityAdmin.phpwith PHP 8.1: no syntax errors.^8.3andsilverstripe/framework ^6.1, andSecurityAdminTestis aFunctionalTestrequiring a full CMS install plus a configured database, which is impractical in this environment. There are no existing tests coveringImportForm/importin this module.ImportFormis the only entry in$allowed_actions; theimportform action is dispatched through theImportFormendpoint, so both paths are now gated byPermission::check('ADMIN').