-
Notifications
You must be signed in to change notification settings - Fork 146
Add Azure test for User Access Administrator #803
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5fc121e
Add Azure test for User Access Administrator
Oppedijk ede397f
enhance wording
Oppedijk 872c32c
move files to correct location
Oppedijk 2035ee6
Change to Get-AzRoleAssignment
Oppedijk b2508e9
add BOM
Oppedijk 4f47e92
export public function Test-MtUserAccessAdmin
Oppedijk 309c6a5
Add Advanced Function support for PS
Oppedijk a88fb42
cleanup results
Oppedijk e73bb0d
Fix texts and links
Oppedijk 0c90df7
Switched to rest api
merill 0d3e2d9
Merge branch 'main' into pr/803
merill 665efb3
Switched to use Rest api for Azure
merill fcdafb8
Fixed pester issues
merill 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
merill marked this conversation as resolved.
Show resolved
Hide resolved
|
Submodule maester
added at
7ee2cd
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Ensure that no person has permanent access to Azure Subscriptions. | ||
|
||
User Access Administrator is a role that allows an Administrator to perform everything on an Azure Subscription. Global Administrators can gain this permission on the Root Scope in Entra ID, in the properties of the Entra ID tenant. These permissions should only be used in case of emergency and should not be assigned permanently. | ||
|
||
Ensure that no User Access Administrator permissions at the Root Scope are applied. | ||
|
||
#### Remediation action: | ||
|
||
To remove all Admins with Root Scope permissions, as a Global Admin: | ||
1. Navigate to Microsoft Azure Portal [https://portal.azure.com](https://portal.azure.com). | ||
2. Search for **Microsoft Entra ID** and select **Microsoft Entra ID**. | ||
3. Expand the **Manage** menu and select **Properties**. | ||
3. On the **Properties** page, go to the **Access management for Azure resources** section. | ||
merill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. In the information bar, click **Manage elevated access users**. | ||
merill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
5. Select all User Access Administrators and click **Remove**. | ||
|
||
To remove the admins through CLI: | ||
```powershell | ||
az role assignment delete --role "User Access Administrator" --assignee adminname@yourdomain.com --scope "/" | ||
``` | ||
|
||
#### Related links | ||
|
||
* [Manage who can create Microsoft 365 Groups](https://learn.microsoft.com/en-us/microsoft-365/solutions/manage-creation-of-groups?view=o365-worldwide) | ||
|
||
|
||
<!--- Results ---> | ||
%TestResult% |
75 changes: 75 additions & 0 deletions
75
powershell/public/maester/azure/Test-MtUserAccessAdmin.ps1
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,75 @@ | ||
<# | ||
.SYNOPSIS | ||
Checks if any Global Admins have User Access Control permissions at the Root Scope | ||
|
||
.DESCRIPTION | ||
Ensure that no one has permanent access to all subscriptions through the Root Scope. | ||
|
||
.EXAMPLE | ||
Test-MtUserAccessAdmin | ||
|
||
Returns true if no User Access Control permissions are assigned at the root scope | ||
|
||
.LINK | ||
https://maester.dev/docs/commands/Test-MtUserAccessAdmin | ||
#> | ||
function Test-MtUserAccessAdmin { | ||
[CmdletBinding()] | ||
[OutputType([bool])] | ||
param() | ||
|
||
Write-Verbose "Checking if connected to Graph" | ||
if (!(Test-MtConnection Graph)) { | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedGraph | ||
return $null | ||
} | ||
|
||
if(!(Test-MtConnection Azure)){ | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedAzure | ||
return $null | ||
} | ||
|
||
Write-Verbose "Getting all User Access Administrators at Root Scope" | ||
try { | ||
$roles = Get-AzRoleAssignment -Scope "/" -RoleDefinitionName 'User Access Administrator' -ErrorAction Stop | ||
merill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch { | ||
Write-Error "Failed to retrieve role assignments at root scope" | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedAzure | ||
return $null | ||
} | ||
|
||
# Get the count of role assignments | ||
$roleAssignmentCount = $roles.Count | ||
|
||
$testResult = $roleAssignmentCount -eq 0 | ||
|
||
if ($testResult) { | ||
$testResultMarkdown = "Well done. Your tenant has no User Access Administrators:`n`n%TestResult%" | ||
} | ||
else { | ||
$testResultMarkdown = "Your tenant has $roleAssignmentCount User Access Administrators:`n`n%TestResult%" | ||
} | ||
|
||
# $itemCount is used to limit the number of returned results shown in the table | ||
$itemCount = 0 | ||
$resultMd = "| Display Name | User Access |`n" | ||
$resultMd += "| --- | --- |`n" | ||
foreach ($item in $resultObject) { | ||
$itemCount += 1 | ||
$itemResult = "❌ Fail" | ||
# We are restricting the table output to 50 below as it could be extremely large | ||
if ($itemCount -lt 51) { | ||
$resultMd += "| $($item.SignInName) | $($itemResult) |`n" | ||
} | ||
} | ||
# Add a limited results message if more than 6 results are returned | ||
if ($itemCount -gt 50) { | ||
$resultMd += "Results limited to 50`n" | ||
} | ||
|
||
$testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $resultMd | ||
|
||
Add-MtTestResultDetail -Result $testResultMarkdown | ||
|
||
return $testResult | ||
} |
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,10 @@ | ||
BeforeAll { | ||
. $PSScriptRoot/Test-MtUserAccessAdmin.ps1 | ||
} | ||
Describe "AzureConfig" -Tag "Privilege", "Azure" { | ||
It "MT. Check 'User Access Administrators' at root scope" { | ||
|
||
$result = Test-MtUserAccessAdmin | ||
|
||
$result | Should -Be $true -Because "No User Access Administrators at root scope"} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: MT.1056 - User Access Administrator permission should not be permanently assigned on the root scope | ||
description: Global Admins should not have permanent access to Azure Subscriptions at the root scope | ||
slug: /tests/MT.1056 | ||
sidebar_class_name: hidden | ||
--- | ||
|
||
# User Access Administrator permission should not be permanently assigned on the root scope | ||
|
||
## Description | ||
Ensure that no person has permanent access to Azure Subscriptions. | ||
|
||
User Access Administrator is a role that allows an Administrator to perform everything on an Azure Subscription. Global Administrators can gain this permission on the Root Scope in Entra ID, in the properties of Entra ID. These permissions should only be used in case of emergency and should not be assigned permanently. | ||
|
||
Ensure that no User Access Administrator permissions at the Root Scope are applied. | ||
|
||
## How to fix | ||
|
||
To remove all Admins with Root Scope permissions, as a Global Admin: | ||
1. Navigate to Microsoft 365 admin center [https://portal.microsoft.com](https://portal.microsoft.com). | ||
2. Search for **Microsoft Entra ID** select **Microsoft Entra ID**. | ||
3. Expand the **Manage** menu, select **Properties** | ||
3. On the **Properties** page, go to the **Access management for Azure resources** section. | ||
4. In the information bar, click: **Manage elevated access users**. | ||
5. Select all User Access Administrators, and click **Remove** | ||
|
||
To remove the admins through CLI: | ||
```powershell | ||
az role assignment delete --role "User Access Administrator" --assignee adminname@yourdomain.com --scope "/" | ||
``` | ||
|
||
## Learn more | ||
|
||
* [Elevate access to manage all Azure subscriptions and management groups](https://learn.microsoft.com/en-us/azure/role-based-access-control/elevate-access-global-admin) | ||
|
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.