-
Notifications
You must be signed in to change notification settings - Fork 40
Add Rego policies for CIS 5.1.4.2, 5.1.4.3, and 5.1.4.4 (Entra device join controls) #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
williamywccc
wants to merge
4
commits into
main
Choose a base branch
from
feature/add-cis-5.1.4.x-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1fb337a
Add Rego policies for CIS 5.1.4.2, 5.1.4.3, and 5.1.4.4
williamywccc 0ceaa45
Fix device registration policy collector to use correct localAdmins key
williamywccc 80d80e3
Fix Rego policies for 5.1.4.3 and 5.1.4.4
williamywccc 17e99fd
Address reviewer feedback for CIS 5.1.4.2 and 5.1.4.4
williamywccc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
52 changes: 52 additions & 0 deletions
52
...olicies/cis/microsoft-365-foundations/v6.0.0/5.1.4.2_limit_device_registration_quota.rego
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # METADATA | ||
| # title: Ensure the maximum number of devices per user is limited | ||
| # description: | | ||
| # Setting an upper bound on device registrations per user reduces the attack | ||
| # surface from compromised accounts and limits lateral movement via registered | ||
| # devices. CIS recommends setting this to 5. | ||
| # related_resources: | ||
| # - ref: https://www.cisecurity.org/benchmark/microsoft_365 | ||
| # description: CIS Microsoft 365 Foundations Benchmark | ||
| # custom: | ||
| # control_id: CIS-5.1.4.2 | ||
| # framework: cis | ||
| # benchmark: microsoft-365-foundations | ||
| # version: v6.0.0 | ||
| # severity: medium | ||
| # service: EntraID | ||
| # requires_permissions: | ||
| # - Policy.Read.DeviceConfiguration | ||
|
|
||
| package cis.microsoft_365_foundations.v6_0_0.control_5_1_4_2 | ||
|
|
||
| import rego.v1 | ||
|
|
||
| default result := { | ||
| "compliant": false, | ||
| "message": "Evaluation failed: unable to retrieve device registration policy", | ||
| "details": {}, | ||
| } | ||
|
|
||
| compliant := true if { | ||
| input.user_device_quota != null | ||
| input.user_device_quota > 0 | ||
| input.user_device_quota <= 20 | ||
| } else := false | ||
|
|
||
| result := output if { | ||
| quota := input.user_device_quota | ||
| output := { | ||
| "compliant": compliant, | ||
| "message": build_message(quota), | ||
| "affected_resources": [], | ||
| "details": {"user_device_quota": quota}, | ||
| } | ||
| } | ||
|
|
||
| build_message(q) := "Device registration quota is not configured" if { | ||
| q == null | ||
| } else := "Device registration quota is set to unlimited (non-compliant; CIS requires 20 or less)" if { | ||
| q == 0 | ||
| } else := sprintf("Device registration quota is set to %d", [q]) if { | ||
| q <= 20 | ||
| } else := sprintf("Device registration quota is %d; CIS requires 20 or less", [q]) | ||
50 changes: 50 additions & 0 deletions
50
engine/policies/cis/microsoft-365-foundations/v6.0.0/5.1.4.3_ga_not_local_admin_on_join.rego
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # METADATA | ||
| # title: Ensure the GA role is not added as a local administrator during Entra join | ||
| # description: | | ||
| # When a device joins Entra ID, automatically granting the Global Administrator | ||
| # role local admin rights on that machine creates unnecessary privilege exposure. | ||
| # The GA role should not be part of the local administrators configuration for | ||
| # joined devices. | ||
| # related_resources: | ||
| # - ref: https://www.cisecurity.org/benchmark/microsoft_365 | ||
| # description: CIS Microsoft 365 Foundations Benchmark | ||
| # custom: | ||
| # control_id: CIS-5.1.4.3 | ||
| # framework: cis | ||
| # benchmark: microsoft-365-foundations | ||
| # version: v6.0.0 | ||
| # severity: medium | ||
| # service: EntraID | ||
| # requires_permissions: | ||
| # - Policy.Read.DeviceConfiguration | ||
|
|
||
| package cis.microsoft_365_foundations.v6_0_0.control_5_1_4_3 | ||
|
|
||
| import rego.v1 | ||
|
|
||
| default result := { | ||
| "compliant": false, | ||
| "message": "Evaluation failed: unable to retrieve device registration policy", | ||
| "details": {}, | ||
| } | ||
|
|
||
| compliant := true if { | ||
| input.global_admins_enabled_on_join == false | ||
| } else := false | ||
|
|
||
| result := output if { | ||
| ga_enabled := input.global_admins_enabled_on_join | ||
| output := { | ||
| "compliant": compliant, | ||
| "message": build_message(ga_enabled), | ||
| "affected_resources": [], | ||
| "details": { | ||
| "global_admins_enabled_on_join": ga_enabled, | ||
| "local_admins_config": object.get(input, "local_admins_config", null), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| build_message(false) := "Global Administrator role is not assigned local admin rights on Entra-joined devices" | ||
| build_message(null) := "Unable to determine whether GA role is granted local admin rights on join; azureADJoin.localAdmins not returned by API" | ||
| build_message(true) := "Global Administrator role is configured as a local administrator on Entra-joined devices" |
52 changes: 52 additions & 0 deletions
52
engine/policies/cis/microsoft-365-foundations/v6.0.0/5.1.4.4_limit_local_admin_on_join.rego
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # METADATA | ||
| # title: Ensure local administrator assignment is limited during Entra join | ||
| # description: | | ||
| # By default, the user registering a device may be granted local administrator | ||
| # rights on that device. Restricting this prevents standard users from gaining | ||
| # local admin access simply by joining a machine to Entra ID. | ||
| # related_resources: | ||
| # - ref: https://www.cisecurity.org/benchmark/microsoft_365 | ||
| # description: CIS Microsoft 365 Foundations Benchmark | ||
| # custom: | ||
| # control_id: CIS-5.1.4.4 | ||
| # framework: cis | ||
| # benchmark: microsoft-365-foundations | ||
| # version: v6.0.0 | ||
| # severity: medium | ||
| # service: EntraID | ||
| # requires_permissions: | ||
| # - Policy.Read.DeviceConfiguration | ||
|
|
||
| package cis.microsoft_365_foundations.v6_0_0.control_5_1_4_4 | ||
|
|
||
| import rego.v1 | ||
|
|
||
| default result := { | ||
| "compliant": false, | ||
| "message": "Evaluation failed: unable to retrieve device registration policy", | ||
| "details": {}, | ||
| } | ||
|
|
||
| compliant := true if { | ||
| input.registering_users_local_admin != null | ||
| lower(input.registering_users_local_admin) == "notallowed" | ||
| } else := false | ||
|
|
||
| result := output if { | ||
| reg_users := input.registering_users_local_admin | ||
| output := { | ||
| "compliant": compliant, | ||
| "message": build_message(reg_users), | ||
| "affected_resources": [], | ||
| "details": { | ||
| "registering_users_local_admin": reg_users, | ||
| "local_admins_config": object.get(input, "local_admins_config", null), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| build_message(val) := "Unable to determine local admin assignment for registering users; azureADJoin.localAdmins not returned by API" if { | ||
| val == null | ||
| } else := "Registering users are not granted local administrator rights on Entra-joined devices" if { | ||
| lower(val) == "notallowed" | ||
| } else := sprintf("Registering users are granted local admin rights on join (registeringUsers=%s)", [val]) |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.