Repository navigation
fix: system user group permission error - #7812
Conversation
| ) | ||
| @log( | ||
| menu="IAM/System User Group", | ||
| operate="Remove members from System User Group", |
There was a problem hiding this comment.
Main finding
The diff changes only authorization policy, but the added RoleConstants.WORKSPACE_MANAGE is a high-risk change.
If has_permissions(...) uses OR semantics — which is common — then any user with WORKSPACE_MANAGE can now:
- create/edit system user groups
- delete system user groups
- add members to system user groups
- remove members from system user groups
That is a potential vertical privilege escalation, especially because group membership changes can grant or remove access. A workspace-scoped role should not normally grant control over system-level IAM groups unless that is explicitly intended and enforced with object-level scoping.
If has_permissions(...) uses AND semantics, adding WORKSPACE_MANAGE may instead make these endpoints inaccessible to users who have ADMIN but not WORKSPACE_MANAGE. Either way, verify the decorator semantics and the intended policy.
Recommendations
-
Confirm
has_permissionssemantics — OR vs AND — before merging. -
Avoid granting
WORKSPACE_MANAGEto system-level group endpoints unless explicitly intended.- If workspace managers must manage only workspace-scoped groups, add object-level checks and queryset filtering.
- Prefer a dedicated permission such as
SYSTEM_USER_GROUP_*_WORKSPACErather than mixing a workspace role into system IAM endpoints.
-
Verify
RoleConstants.WORKSPACE_MANAGEexists and is imported. If it does not exist, this will fail at import/runtime withAttributeError. -
Check the existing
SystemUserGroupViewdecorator. It lists bothSYSTEM_USER_GROUP_CREATEandSYSTEM_USER_GROUP_EDIT. If the decorator is OR-based, a user with only create permission can edit, and a user with only edit permission can create. Split permissions by HTTP method if possible. -
Add authorization tests for:
ADMINWORKSPACE_MANAGE- users with only individual
SYSTEM_USER_GROUP_*permissions - users with no relevant permissions
- expected
200/403results
-
Fix line length/formatting. The new one-line decorators are likely over 120 characters:
Deleteline is approximately 123 charsAddMemberline is approximately 127 charsRemoveMemberline is approximately 130 chars
Use the project formatter, e.g. Black/Ruff, and keep the decorator arguments consistently multiline.
-
Consider audit logging. Since membership changes can affect access, ensure the existing
@logcaptures actor, target group, and affected members.
Overall: the formatting changes are minor, but the authorization change needs explicit security review before merge.
fix: system user group permission error