Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

Description

Fixes the issue where Protected Actions with Authentication Contexts assigned may not actually be protected if the context isn't referenced by any Conditional Access policy. Without a CA policy enforcing the auth context, users aren't prompted for step-up authentication.

Fixes #997

Changes:

  • Test-MtCaAuthContextProtectedActionsExist.ps1 - New test function that:
    • Fetches auth contexts from identity/conditionalAccess/authenticationContextClassReferences
    • Checks PIM role management policies for unifiedRoleManagementPolicyAuthenticationContextRule rules (with isEnabled check)
    • Compares against enabled CA policies' includeAuthenticationContextClassReferences
    • Fails if any auth context used in Protected Actions lacks a CA policy reference
    • Detects deleted auth contexts by iterating over protected action contexts and showing "(Deleted or not found)" for missing contexts
  • Test-MtCaAuthContextProtectedActionsExist.md - Function documentation
  • Test-ConditionalAccessBaseline.Tests.ps1 - Added MT.1106 test case
  • MT.1106.md - Website documentation
# Example usage
Test-MtCaAuthContextProtectedActionsExist
# Returns $true if all Protected Action auth contexts have CA policies
# Returns $false with details table if any are unprotected

Contribution Checklist

Before submitting this PR, please confirm you have completed the following:

  • 📖 Read the guidelines for contributing to this repository.
  • 🧪 Ensure the build and unit tests pass by running /powershell/tests/pester.ps1 on your local system.

 

Join us at the Maester repository discussions 💬 or Entra Discord 🧑‍💻 for more help and conversations!

Original prompt

This section details on the original issue you should resolve

<issue_title>🙏Maester Test to Ensure all Protected Actions Auth Context have a conditional access referenced.</issue_title>
<issue_description>Maester Test to Ensure all Protected Actions Auth Context have a conditional access referenced.

Maester Test to Ensure all Protected Actions Auth Context have a conditional access referenced. There is a potential for an auth context to get deleted while still being referenced in a CA

If no Conditional access Policy is referenced by the authentication context then the protected action is not well protecting anything

Image

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 2, 2025

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 550d061
Status: ✅  Deploy successful!
Preview URL: https://acf90e9f.maester.pages.dev
Branch Preview URL: https://copilot-add-maester-test-con.maester.pages.dev

View logs

Copilot AI changed the title [WIP] Add Maester test for protected actions auth context Add test MT.1090 to verify Protected Actions Auth Contexts have CA policies Dec 2, 2025
Copilot AI requested a review from SamErde December 2, 2025 16:53
Copilot finished work on behalf of SamErde December 2, 2025 16:53
@SamErde SamErde requested a review from Copilot December 2, 2025 17:37
Copilot finished reviewing on behalf of SamErde December 2, 2025 17:41
@SamErde SamErde added enhancement New feature or request help wanted Extra attention is needed maester-test Related to a Maester test work started entra Microsoft Entra labels Dec 2, 2025
Copy link
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

Adds a new validation test to ensure that protected actions using Authentication Contexts are actually enforced by Conditional Access policies, plus associated documentation and baseline test wiring.

  • Introduces Test-MtCaAuthContextProtectedActionsExist to detect Authentication Contexts used by Protected Actions but not referenced by any CA policy.
  • Wires the test into the Conditional Access baseline suite (MT.1090).
  • Adds user-facing documentation for the test and website page.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
website/docs/tests/maester/MT.1090.md New website doc explaining MT.1090 test purpose, remediation steps, and links.
tests/Maester/Entra/Test-ConditionalAccessBaseline.Tests.ps1 Adds the MT.1090 test case to the Entra Conditional Access baseline suite.
powershell/public/maester/entra/Test-MtCaAuthContextProtectedActionsExist.ps1 Implements the test logic to correlate protected actions’ Authentication Contexts with CA policies.
powershell/public/maester/entra/Test-MtCaAuthContextProtectedActionsExist.md Adds command documentation with remediation steps and related links.

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

Comment on lines 69 to 79
$caPolicies = Get-MtConditionalAccessPolicy

# Collect all auth context IDs referenced in CA policies
$authContextsInCAPolicies = [System.Collections.Generic.HashSet[string]]::new()
foreach ($policy in $caPolicies) {
if ($policy.conditions.applications.includeAuthenticationContextClassReferences) {
foreach ($context in $policy.conditions.applications.includeAuthenticationContextClassReferences) {
[void]$authContextsInCAPolicies.Add($context)
}
}
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

CA policy state is not considered when determining protection. Disabled policies do not enforce Authentication Contexts, so counting them can yield false positives. Please filter to enabled policies before collecting includeAuthenticationContextClassReferences, e.g.: $caPolicies = Get-MtConditionalAccessPolicy | Where-Object { $_.state -eq 'enabled' }.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

A 'Disabled' or 'ReportOnly' policy might still be in development. Should we still alert on these? I lean very slightly towards 'yes' because the ultimate goal is to have them in effect and not create a false sense of security with regards to the protected action configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to filter only enabled CA policies in commit 550d061: $caPolicies = Get-MtConditionalAccessPolicy | Where-Object { $_.state -eq 'enabled' }. Regarding @SamErde's point about disabled/report-only policies - the current implementation alerts if the auth context is only in disabled policies, since those don't provide actual protection.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's right, the test should still fail if the policy is not enabled.

Copy link
Contributor

@SamErde SamErde left a comment

Choose a reason for hiding this comment

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

The test ID 'MT.1090' is already taken. 'MT.1106' should be used for this test. References within this PR need to be changed accordingly.

…s, check isEnabled for rules, detect deleted contexts

Co-authored-by: SamErde <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

The test ID 'MT.1090' is already taken. 'MT.1106' should be used for this test. References within this PR need to be changed accordingly.

Renamed to MT.1106 in commit 550d061. Updated the website doc, test file reference, title, and slug accordingly.

Copilot AI changed the title Add test MT.1090 to verify Protected Actions Auth Contexts have CA policies Add test MT.1106 to verify Protected Actions Auth Contexts have CA policies Dec 2, 2025
Copilot AI requested a review from SamErde December 2, 2025 18:16
Copilot finished work on behalf of SamErde December 2, 2025 18:16
@SamErde SamErde marked this pull request as ready for review December 2, 2025 18:34
@SamErde SamErde requested review from a team as code owners December 2, 2025 18:34
@SamErde SamErde removed help wanted Extra attention is needed work started labels Dec 4, 2025
@SamErde SamErde requested a review from Copilot December 4, 2025 13:27
Copilot finished reviewing on behalf of SamErde December 4, 2025 13:30
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


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

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

Labels

enhancement New feature or request entra Microsoft Entra maester-test Related to a Maester test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🙏Maester Test to Ensure all Protected Actions Auth Context have a conditional access referenced.

2 participants