Skip to content

feat(entra): add MT.1274 - open Entra ID Protection workload identity risk detections, one result per detection type - #2731

Draft
merill wants to merge 1 commit into
mainfrom
feat/mt1274-workload-risk-detections
Draft

merill wants to merge 1 commit into
mainfrom
feat/mt1274-workload-risk-detections

Conversation

@merill

@merill merill commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

Opened during the Maester 3.0 code freeze as a draft, for review after the release.

📑 Description

Adds MT.1274, a family check that reports open Entra ID Protection workload identity (service principal) risk detections, with one result per detection type (MT.1274.<riskEventType>). This is the workload identity half of the design in #2730. Users are in a separate PR (MT.1273, see #2730), and the two PRs are independent.

A row fails when at least one detection of its type is still atRisk or confirmedCompromised. It lists the service principals, high risk first, and opens with a count by level. Rows for remediated or dismissed detections pass. The recommendation, aimed at the security operations team: review each detection, then dismiss it if benign, or confirm compromised, replace every credential, rotate Key Vault secrets the app can read, and remove anything an attacker added.

Part of #2730.

How it works

Instances The 8 riskEventType values documented in Securing workload identities, plus a row for any undocumented type that has open detections
Data identityProtection/servicePrincipalRiskDetections (v1.0), two cached reads (atRisk, confirmedCompromised) through the new powershell/internal/services/entra/Get-MtServicePrincipalRiskDetection.ps1
Per-row severity High for threat intelligence, admin-confirmed compromise, leaked credentials and malicious application; Medium for the rest
Licence License = ('AAD_WRKLDID_P1', 'AAD_WRKLDID_P2'), because the API needs Workload ID Premium. This matches MT.1262 (#2689)
Permission IdentityRiskEvent.Read.All, already a default scope; no new consent
Size Table capped at 100 rows per type

Duplicate review

MT.1262 and MT.1263 (#2689, #2704) report risky service principals by level from riskyServicePrincipals. This check reports the detections behind that risk, split by signal, so it's not a shim. The guide links them.

Attributes

entra / identity-protection, Area applications, ResourceType ServicePrincipal, Severity Medium and ImplementationCost Medium (matching MT.1262), UserImpact Low. Mitre T1078.004, T1098.001, T1552. Control nist-800-53-r5:IR-4, nist-800-53-r5:AC-2(12). Lifecycle Preview.

✅ Checks

  • My pull request adheres to the code style of this project.
  • My code requires changes to the documentation.
  • I have updated the documentation as required.
  • The build and unit tests pass after running /powershell/tests/pester.ps1 locally.

ℹ️ Additional Information

  • Get-MtTest MT.1274 is valid. 9 new unit tests in powershell/tests/functions/Test-MtEntraServicePrincipalRiskDetection.Tests.ps1.
  • Golden fixtures regenerated. If MT.1273 merges first, this PR needs the fixtures regenerated again; that's a mechanical conflict.
  • The guide refers to MT.1262/MT.1263, which are still open PRs.
  • Not yet run against a live tenant with Workload ID Premium.

🤖 Generated with Claude Code

… risk detections, one result per detection type

A family check with one row per documented workload identity riskEventType
(plus any undocumented type with open detections). A row fails when a
detection of its type is still atRisk or confirmedCompromised and lists the
service principals high risk first, so SecOps can review and dismiss or
remediate them.

Part of #2730.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M6X8CVGXWW9F5J6Y0CVN94RF
@merill merill added enhancement A new feature or an improvement to an existing one product: entra Entra ID new test Adds a new check, or asks for one labels Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

$script:Severity = $null

Mock -ModuleName Maester Add-MtTestResultDetail {
param($Result, $SkippedBecause, $SkippedError, $Severity)
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@earbona23

Copy link
Copy Markdown
Contributor

Reviewed this with MT.1273; the full comment is here on #2732, and all of it applies to MT.1274 with the counts changed.

The two specific to this file:

  • the undocumented-type discovery degrades to $openTypes = @() behind a Write-Verbose, so a risk event type Microsoft adds after this list was written produces no row and nothing visible says the enumeration failed — the one case the code exists to catch;
  • Add-MtTestResultDetail -Severity $severity is dead in three places here (four in MT.1273): the instance severity already wins at Invoke-MtNativePlan.ps1:470, two lines before the helper's value is considered.

The parts worth keeping as they are: the P2 and 403 gates return $null with a reason rather than passing, and the discovered instance ID is validated against ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$ before it becomes an instance, which is what stops one unexpected type from turning the whole family into a single Error row.

@julien-ly

Copy link
Copy Markdown
Contributor

Ran this at da9da1b on a tenant with Workload ID Premium, with -IncludePreview.

  • No open detections: 8 rows, one per detection type, all Passed.
  • After confirmCompromised on a test service principal, servicePrincipalRiskDetections returned an adminConfirmedServicePrincipalCompromised detection (high, confirmedCompromised). MT.1274.adminConfirmedServicePrincipalCompromised failed with the service principal and its app ID listed. The other 7 passed.
  • confirmCompromised rejected the service principal with "Invalid service principal ids" two seconds after it was created, and accepted it a minute or two later. Worth knowing if you script a reproduction.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new feature or an improvement to an existing one new test Adds a new check, or asks for one product: entra Entra ID

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants