feat(m365): add entra_service_principal_privileged_role_no_owners check#11093
Open
asraym wants to merge 2 commits into
Open
feat(m365): add entra_service_principal_privileged_role_no_owners check#11093asraym wants to merge 2 commits into
asraym wants to merge 2 commits into
Conversation
Contributor
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
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.
Context
Fix #11070
Service principals that hold privileged Microsoft Entra directory roles (Global Administrator, Privileged Role Administrator, etc.) and have owners represent a known privilege escalation path. An owner can rotate credentials, sign in as the service principal, and inherit its privileges — entirely outside PIM approval flows and Conditional Access policies targeting user accounts. Microsoft documents this as a known attack vector.
Description
Adds a new M365 check entra_service_principal_privileged_role_no_owners that detects service principals holding privileged Entra directory roles that have at least one owner on either the service principal itself or its parent app registration.
Check behavior:
PASS — privileged service principal has zero owners on both the SP and parent app registration
FAIL — privileged service principal has at least one owner on either surface
MANUAL — Directory.Read.All permissions are missing and role assignments could not be fetched
Implementation details:
Extends entra_service.py with a new ServicePrincipal model and _get_service_principals() method
Uses a static hardcoded list of 9 privileged role IDs (reuses existing AdminRoles enum) — avoids runtime scope drift
Skips Microsoft first-party service principals (filtered by appOwnerOrganizationId)
Skips disabled service principals (accountEnabled = false)
No additional Graph API permissions required — Directory.Read.All is already in Prowler's M365 baseline
Follows the same patterns as entra_app_registration_no_unused_privileged_permissions
Steps to review
Review entra_service.py — check ServicePrincipal model fields and _get_service_principals() method logic
Review the check file — verify PASS/FAIL/MANUAL conditions match the issue spec
Review the metadata JSON — severity is high, provider is m365, category is identity-access
Review the 6 test cases — empty tenant, permissions error, no owners, SP owners only, app owners only, both owners
Checklist
Community Checklist
SDK/CLI
UI
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.