Prevent Privilege Escalation: Add Assignment Restrictions for Roles and Permissions #24775
+1,878
−133
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.
Resolve #24768
Problem Description
The system has privilege escalation issues:
AbpIdentity.Users.Update.ManageRolespermission can add Admin role to themselves or othersAbpIdentity.Users.ManagePermissionsorAbpIdentity.Roles.ManagePermissionspermission can grant others permissions they don't haveSolution
This PR introduces 3 core security mechanisms:
1. Role Assignability Control (for ManageRoles permission)
AssignableRolesconfiguration to each role, specifying which other roles it can assignAssignableRoles: [Sales, Support], can only assign these 2 roles, cannot assign Admin2. Permission Grant Authority Validation (for ManagePermissions permission)
3. Self-Modification Protection (for all management permissions)
AbpIdentity.Users.ManagePermissions)AbpIdentity.Roles.ManagePermissions)AbpIdentity.Users.Update.ManageRoles)New Permission Rules
Role Assignment Rules (
AbpIdentity.Users.Update.ManageRoles):AssignableRolesAssignableRoles, no restriction (backward compatible)Permission Grant Rules (
AbpIdentity.Users.ManagePermissionsandAbpIdentity.Roles.ManagePermissions):Self-Modification Rules:
AbpIdentity.Users.ManagePermissionsto modify their own user permissionsAbpIdentity.Roles.ManagePermissionsto modify permissions of roles they belong toAbpIdentity.Users.Update.ManageRolesto add new roles to themselves (can only remove)Effect Comparison
UI