Skip to content

🪲 MT.1005 fails for Conditional Access policies that target agent users #2834

Open

Description

@Dfrank77

Describe the bug

MT.1005 skips policies that target service principals or agent identities (added for #1385), but not policies that target agent users (conditions.agents.includeAgentUsers). So an agent-user policy gets reported as not excluding the emergency access account, and the exclusion can't be added: Graph rejected a user exclusion on both agent-user policies I tried (errors below), and Microsoft documents that Users-assignment scoping doesn't apply to agent user accounts.

In my lab tenant MT.1005 auto-detected breakglass1 and listed my agent-user policy, MSOBB-CA-AgentRisk-AgentUser, as missing the exclusion. That policy has users.includeUsers: ["None"] and agents.includeAgentUsers: ["All"], so it can't apply to a human break glass account. My agent-identity policy (clientApplications.includeAgentIdServicePrincipals: ["All"]) was left out, as expected.

The filter is here:

# Remove policies that are scoped to service principals or agent identities
$policies = $policies | Where-Object {
-not $_.conditions.clientApplications.includeServicePrincipals -and
-not $_.conditions.clientApplications.includeAgentIdServicePrincipals
}

I tried adding breakglass1 as an excluded user with a beta PATCH, on two policies:

  • The agent-user policy above, which uses the agent risk condition: 1260: The specified condition(s) 'AgentIdRiskLevels' are not supported for user-based policies.
  • A report-only policy that targets all agent users with no agent risk condition (made for the test): 1263: The specified condition(s) 'Users' are not supported for agent user policies.

Microsoft's docs say the same thing from the other side: policies scoped through the Users assignment don't apply to agent user accounts (Conditional Access for agents, boundaries and limitations).

Steps to reproduce

  1. Create a Conditional Access policy that targets agent users (Users, agents or workload identities > What does this policy apply to? > Agents > Include > All agent users (Preview)), for example Microsoft's block risky agent user accounts policy.
  2. Run Invoke-MtTest -Id MT.1005 with no EmergencyAccessAccounts set, in a tenant where the other policies exclude a break glass user.
  3. The agent-user policy is listed under "These Conditional Access policies don't have the emergency access user excluded".

Expected behavior

Policies that target agent users are skipped, the same way agent-identity policies are now, for example by also leaving out policies where conditions.agents.includeAgentUsers is set.

Additional context

Tested from a local branch on main at 512a076 (3.0.0-rc83 plus one commit), in my lab tenant with Entra ID P2 and Agent 365 and E5 trials. The branch only adds MT.1284 (check, unit tests, guide), one Graph scope with its docs, and the matching test fixture; it doesn't change MT.1005 or Get-MtConditionalAccessPolicy. The same filter is unchanged in 2.3.0 (Test-MtCaEmergencyAccessExists.ps1), but I haven't run 2.3.0.

#2811 also changes MT.1005. It doesn't touch the filter above, but it edits the auto-detection block a few lines below it. Happy to open a PR for this once that one lands, or fold it in wherever is easiest.

Module version

PASTE Get-Module -Name Maester OUTPUT HERE

Environment data

PASTE $PSVersionTable OUTPUT HERE

Activity

  1. julien-ly commented on Nov 19, 2026

    @julien-ly
    Contributor

    Thanks for the clear repro.

    On #2811: no need to wait for it. Since it doesn't touch the filter, your fix should merge cleanly on its own, and I'd keep it as a separate PR: it's your find. If yours lands first, I'll rebase #2811.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions