Skip to content

feat(entra): add MT.1273 - open Entra ID Protection user risk detections, one result per detection type - #2732

Draft
merill wants to merge 1 commit into
mainfrom
feat/mt1273-user-risk-detections
Draft

merill wants to merge 1 commit into
mainfrom
feat/mt1273-user-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.1273, a family check that reports open Entra ID Protection user risk detections, with one result per detection type (MT.1273.<riskEventType>). This is the user half of the design in #2730. Workload identities are in a separate PR (MT.1274).

A row fails when at least one detection of its type is still atRisk or confirmedCompromised (the same open states MT.1260 uses). The row lists those detections with high risk first, then by date, and opens with a count by level. Rows for remediated, dismissed or confirmed-safe detections pass, so the report also shows which signals are clean. The recommendation, aimed at the security operations team: review each detection, then dismiss it if benign, or confirm compromised and remediate, including removing any authentication method the attacker added.

Part of #2730.

How it works

Instances The 27 sign-in and user riskEventType values documented in What are risk detections?, plus a row for any undocumented type that has open detections, so new Microsoft detections are not dropped
Data identityProtection/riskDetections (v1.0), two cached reads (riskState eq 'atRisk', riskState eq 'confirmedCompromised') through the new powershell/internal/services/entra/Get-MtUserRiskDetection.ps1
Per-row severity High for strong compromise signals (leaked credentials, AitM, password spray, PRT access, verified threat actor IP, suspicious MFA approval, suspicious credential addition, token issuer anomaly, threat intelligence, admin-confirmed compromise); Low for anonymous IP and new country; Medium for the rest
Per-row text One-line explanation of the detection type, with a link to Microsoft's investigation tips for that type
Licence License = 'AAD_PREMIUM' (the API needs P1 or P2). Premium detection types are skipped with NotLicensedEntraIDP2 in tenants without P2, because those tenants only see them as generic. That is why MT.1273 joins MT.1024 on the licence-check allow-list in NativeTestLint.Tests.ps1
Permission IdentityRiskEvent.Read.All, already a default scope; no new consent
Size Table capped at 100 rows per type, with a pointer to the portal for the rest

Duplicate review

MT.1260 (and the planned MT.1261) report risky users by level from riskyUsers. This check reports the detections behind that risk, split by signal. The endpoint, granularity and question are different, so it's not a shim. The guide links the two. #2705 (MT.1253) checks the Conditional Access response to risk, not the backlog.

Attributes

entra / identity-protection, Area logging-and-detection and Severity Medium (matching MT.1260), ResourceType User (instance type), UserImpact Low, ImplementationCost Low. Mitre T1078.004, T1110.003, T1557, T1098.005, T1114.003, each named in the guide. 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.1273 is valid. 11 new unit tests in powershell/tests/functions/Test-MtEntraUserRiskDetection.Tests.ps1.
  • Golden fixtures regenerated with ./build/golden/Export-MtGoldenFixture.ps1 (one more selected test).
  • Not yet run against a live tenant. Worth a run on a P2 tenant with open detections before marking ready, and one on a P1 tenant to see the premium rows skip.

🤖 Generated with Claude Code

…ons, one result per detection type

A family check with one row per documented sign-in and user riskEventType
(plus any undocumented type with open detections). A row fails when a
detection of its type is still atRisk or confirmedCompromised and lists
them 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: 01M6X8CMR457WNSZ1TZGV4DGSM
@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

@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.

$script:Severity = $null

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

@earbona23 earbona23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read MT.1273 and MT.1274 together. Three observations, one of which is a loose end I measured on another PR this morning and found two more instances of here.

The shape is the one I have been recommending elsewhere

One instance per detection type with the severity carried on the instance — MT.1273.<riskEventType>, each type's severity set in the instance source — is exactly right for this data, and worth pointing at: I spent this morning arguing for it on #2704, where MT.1262 and MT.1263 are 125 of 161 lines identical and differ only by a risk level and a severity. This PR is the maintainer's own precedent for the alternative, so I will cross-reference it there.

Three more things I checked rather than assumed:

  • The gates skip, they do not pass. $type.Premium without P2 returns $null with NotLicensedEntraIDP2, and a 403 returns $null with NotAuthorized while anything else rethrows. A premium detection type in a P1 tenant therefore cannot read as "no open detections".
  • The discovered instance ID is validated against the engine's own grammar before it becomes an instance: $type -notmatch '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$' and it is dropped. That matters more than it looks — Invoke-MtNativePlan.ps1:330 turns one invalid suffix into a single Error row for the whole family, so validating at the source is what stops an unexpected riskEventType from Microsoft taking out all the other rows. I raised the same point on #2746 about Target.Id; here it is already done.
  • Get-MtSafeMarkdown on the detection name, and the relationship to MT.1260 stated in the guide ("MT.1260 reports the users that are high risk and unremediated; the two complement each other") — which answers the overlap question I came in with.

1. The one thing that degrades quietly is the part nobody would notice

The instance source enumerates documented types from the table, then asks the tenant for any type Microsoft has added since:

try {
    $openTypes = @(Get-MtUserRiskDetection | ForEach-Object { [string]$_.riskEventType } | ... )
} catch {
    Write-Verbose "MT.1273: could not read open risk detections for undocumented types. $($_.Exception.Message)"
    $openTypes = @()
}

If that read fails, the documented types still produce their rows, so the check looks healthy — and the only thing lost is the one thing the code exists to catch: an undocumented type with open detections. There is no row for it, nothing in the report says enumeration did not happen, and the evidence is a verbose line nobody runs with.

The failure is also not unlikely: that call is the same read the results use, so a transient throttle or a permission that covers one path and not another lands here first.

It is a thin fix given the shape you already have — the discovery outcome could ride along on Data and each result's detail could end with one line when it failed ("new detection types could not be enumerated this run"), or the family could carry a single extra instance for it. What I would avoid is letting the catch rethrow: a transient failure should not cost all 40-odd rows.

2. -Severity on Add-MtTestResultDetail is dead here, four times in MT.1273 and three in MT.1274

$severity = $Instance.Severity, then Add-MtTestResultDetail -Severity $severity. The engine's own chain at Invoke-MtNativePlan.ps1:467-472 reads:

# Severity: config row (instance, then parent), the instance's, the attribute's, then the helper's.
elseif ($isInstance -and (Get-MtInstanceValue -Instance $Instance -Name 'Severity')) { ... }   # :470
elseif ($test.Severity) { ... }                                                                # :471
elseif ($detail -and $detail.Severity) { ... }                                                 # :472

The instance's severity wins at :470, two lines before the helper's value is ever considered, so passing the same figure to the helper cannot change anything.

Harmless here because it is the same value by both routes. I raise it only because I measured the class this morning for #2757: 50 call sites pass -Severity to that helper and all 50 are dead, and in 7 of them the literal passed contradicts what the report shows — MT.1208 asks for High and reports Medium, and six others like it. These seven calls would make 57. I offered on #2757 to write a general test that fails when a native test passes -Severity to the helper, in the shape of TestParameterNames.Tests.ps1; if that lands, this is two files to touch, and better before the pattern is copied from a maintainer's PR.

@julien-ly

Copy link
Copy Markdown
Contributor

Ran this at 08df3b7 on a tenant with Entra ID P2, with -IncludePreview.

  • No open detections: 27 rows, one per detection type, all Passed.
  • After confirmCompromised on a test user, riskDetections returned an adminConfirmedUserCompromised detection (high, confirmedCompromised). MT.1273.adminConfirmedUserCompromised failed with the user listed, with risk level, state and detection time. The other 26 passed.

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