Skip to main content

Triage and Remediation

Remediation

Using Console

The presence of guest users in an Azure Active Directory (AD) can pose a security risk. Here are the steps to remediate the issue of guest users in use in Azure:
  1. Sign in to the Azure portal using your administrator credentials.
  2. In the left-hand menu, click on “Azure Active Directory”.
  3. Under “Manage”, select “Users”.
  4. On the “Users” page, click on the “Guest users” tab.
  5. Review the list of guest users to determine which ones need to be removed.
  6. Select the guest user that you want to remove by clicking on the checkbox next to their name.
  7. Click on the “Remove” button at the top of the screen.
  8. Confirm that you want to remove the guest user by clicking “Yes” in the confirmation dialog box.
Repeat steps 6-8 for each guest user that you want to remove.Note: Before removing a guest user, make sure that they no longer require access to any resources in your Azure environment.

The “Guest Users in Use” misconfiguration in Azure refers to the presence of external users who have access to your Azure Active Directory tenant. To remediate this misconfiguration, you can follow the below steps using Azure CLI:
  1. Run the following command to list all the external/guest users in your Azure Active Directory tenant:
  2. Identify the guest users that should not have access to your Azure resources.
  3. Run the following command to remove a guest user:
    Replace <guest-user-object-id> with the object ID of the guest user you want to remove.
  4. Repeat step 3 for all the guest users that should not have access to your Azure resources.
  5. After removing the guest users, you can also disable external sharing for your Azure Active Directory tenant by running the following command:
    Replace <object-id-of-the-external-users-group> with the object ID of the group that contains all the external users in your Azure Active Directory tenant.
By following these steps, you can remediate the “Guest Users in Use” misconfiguration in Azure using Azure CLI.
The misconfiguration “Guest Users In Use” occurs when guest users are granted access to Azure resources. To remediate this issue, we can use the Azure Python SDK to write a script that will identify the guest users and remove their access.Here are the steps to remediate “Guest Users In Use” for Azure using Python:
  1. Install the Azure Python SDK by running the command pip install azure-mgmt-resource.
  2. Authenticate with Azure using your Azure account credentials. You can do this by using the ServicePrincipalCredentials class from the Azure Python SDK. Here’s an example:
  1. Use the Azure Python SDK to list all the guest users in your Azure AD tenant. You can do this by using the GraphRbacManagementClient class from the Azure Python SDK. Here’s an example:
  1. Use the Azure Python SDK to remove the guest users’ access to Azure resources. You can do this by using the RoleAssignmentsOperations class from the Azure Python SDK. Here’s an example:
This script will remove the guest users’ access to all Azure resources in your subscription. You can schedule this script to run periodically to ensure that guest users do not have access to your Azure resources.
To remediate “Guest Users In Use” with Terraform:
  • Identify any guest accounts you are creating via Terraform, typically with azuread_invitation (or azuread_user resources whose underlying AAD object is a guest) and remove those resources from your configuration so they are no longer managed/created.
  • If you want those identities as regular employees, model them as azuread_user resources like above in your employee onboarding module, and stop using invitations for them.
This change forces replacement of those identities: destroying a guest account and creating a member account is not an in-place change and will break any access tied to the old guest object.Verification with terraform plan:
  • Existing guest users you were managing (e.g. azuread_invitation or guest azuread_user resources you removed from code) should appear in the plan as - destroy.
  • Only azuread_user resources representing internal/member users should be planned for + create or ~ update.