Skip to content

Bugfix 21816 - PIM privileged role assignment check should account for JIT access into role-assignable groups#1208

Draft
ashwinikarke wants to merge 4 commits into
devfrom
bugfix-21816
Draft

Bugfix 21816 - PIM privileged role assignment check should account for JIT access into role-assignable groups#1208
ashwinikarke wants to merge 4 commits into
devfrom
bugfix-21816

Conversation

@ashwinikarke
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates assessment 21816 to better handle privileged role assignments granted via role-assignable groups by detecting whether those groups use PIM for Groups (JIT/eligible membership) and adjusting how “non-PIM” and “permanent GA” findings are calculated.

Changes:

  • Add PIM-for-Groups eligibility schedule checks when privileged role members (and GA members) are groups, to avoid flagging JIT-managed group-based access as non-PIM.
  • Adjust the Global Administrator “permanent assignment” expansion logic to only enumerate group members when the group is not JIT-managed via PIM for Groups.
  • Refine result messaging and simplify CustomStatus assignment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/powershell/tests/Test-Assessment.21816.ps1
Comment thread src/powershell/tests/Test-Assessment.21816.ps1 Outdated
Comment on lines +150 to 172
if ($pimForGroupsSchedules) {
# Group enforces JIT via PIM for Groups - exclude from PermanentGAGroupList, do not add members
$permanentGAGroupList = $permanentGAGroupList | Where-Object { $_.id -ne $member.id }
Write-PSFMessage "Group $($member.displayName) uses PIM for Groups, excluding from permanent GA list" -Level Verbose
} else {
# Group does not use PIM for Groups - get members and add to permanentGAUserList (Q5)
$groupMembers = Invoke-ZtGraphRequest -RelativeUri "groups/$($member.id)/members" -Select 'userPrincipalName,displayName,id,onPremisesSyncEnabled' -ApiVersion beta
foreach ($groupMember in $groupMembers) {
# Only process users, skip service principals
if ($groupMember.'@odata.type' -eq '#microsoft.graph.user') {
$groupMemberInfo = [PSCustomObject]@{
displayName = $groupMember.displayName
userPrincipalName = $groupMember.userPrincipalName
id = $groupMember.id
roleTemplateId = $globalAdminRoleId
roleDefinitionId = $gaDirectoryRole.id
roleName = 'Global Administrator (via group)'
isPrivileged = $true
assignmentType = 'Via Group'
onPremisesSyncEnabled = $groupMember.onPremisesSyncEnabled
}
$permanentGAUserList += $groupMemberInfo
}
@ashwinikarke ashwinikarke marked this pull request as draft May 11, 2026 10:42
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.

PIM privileged role assignment check should account for JIT access into role-assignable groups

2 participants