Prevent privilege escalation when assigning roles via /authz/roles - #27154
Draft
dennisoelkers wants to merge 1 commit into
Draft
Prevent privilege escalation when assigning roles via /authz/roles#27154dennisoelkers wants to merge 1 commit into
/authz/roles#27154dennisoelkers wants to merge 1 commit into
Conversation
`PUT /authz/roles/{roleId}/assignees` assigned a role to a user without
checking that the caller holds the permissions that role grants. Holding
`users:rolesedit` on the target user plus `roles:assign` on the role was
enough to grant permissions the caller does not have themselves - for
example adding somebody (or oneself) to a role carrying `*`.
`RolesResource` and `UsersResource` already run requested permissions
through `PrivilegeEscalationGuard`; this closes the equivalent gap on the
remaining role-assignment endpoint.
Un-assigning stays unguarded: removing a role reduces privileges, and
gating it would stop a less privileged administrator from demoting an
over-privileged user. Since `addUser` and `removeUser` share
`updateUserRole`, the check is switched by an explicit parameter.
Verified by mutation: dropping the `validatePermissions` call fails 3 of
the 4 new tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Note: This needs a backport to
7.1,7.0&6.3.Description
Motivation and Context
PUT /authz/roles/{roleId}/assigneesassigned a role to a user withoutchecking that the caller holds the permissions that role grants. Holding
users:rolesediton the target user plusroles:assignon the role wasenough to grant permissions the caller does not have themselves - for
example adding somebody (or oneself) to a role carrying
*.RolesResourceandUsersResourcealready run requested permissionsthrough
PrivilegeEscalationGuard; this closes the equivalent gap on theremaining role-assignment endpoint.
Un-assigning stays unguarded: removing a role reduces privileges, and
gating it would stop a less privileged administrator from demoting an
over-privileged user. Since
addUserandremoveUsershareupdateUserRole, the check is switched by an explicit parameter.How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: