Skip to content

fix: system user group permission error - #7812

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_system_user_group_permission_error
Nov 10, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_system_user_group_permission_error

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: system user group permission error

)
@log(
menu="IAM/System User Group",
operate="Remove members from System User Group",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Confirm has_permissions semantics — OR vs AND — before merging.

  2. Avoid granting WORKSPACE_MANAGE to 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_*_WORKSPACE rather than mixing a workspace role into system IAM endpoints.
  3. Verify RoleConstants.WORKSPACE_MANAGE exists and is imported. If it does not exist, this will fail at import/runtime with AttributeError.

  4. Check the existing SystemUserGroupView decorator. It lists both SYSTEM_USER_GROUP_CREATE and SYSTEM_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.

  5. Add authorization tests for:

    • ADMIN
    • WORKSPACE_MANAGE
    • users with only individual SYSTEM_USER_GROUP_* permissions
    • users with no relevant permissions
    • expected 200/403 results
  6. Fix line length/formatting. The new one-line decorators are likely over 120 characters:

    • Delete line is approximately 123 chars
    • AddMember line is approximately 127 chars
    • RemoveMember line is approximately 130 chars

    Use the project formatter, e.g. Black/Ruff, and keep the decorator arguments consistently multiline.

  7. Consider audit logging. Since membership changes can affect access, ensure the existing @log captures actor, target group, and affected members.

Overall: the formatting changes are minor, but the authorization change needs explicit security review before merge.

@peslyn
peslyn merged commit 3d64f37 into v3 Nov 10, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_system_user_group_permission_error branch November 10, 2026 09:19
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.

2 participants