o365soa / soa

Public SOA modules and information
39 stars 18 forks source link

Microsoft Security Assessment Prerequisites

Introduction

The following Microsoft security assessments have several prerequisites that need to be installed and configured:

The preqrequisites installation script is included in a PowerShell module named SOA.

Prerequisites Breakdown

The latest version of the following PowerShell modules is installed:

Note: For SharePoint Online, if a non-PowerShell Gallery version of the module is installed, it is removed from the PS Module Path to prevent conflicts.

An application, named "Microsoft Security Assessment", is also registered (created) in your tenant. Details are provided below.

Prerequisites Script

Requirements

In order to install the SOA module and run the prerequisites script, you must have the following on the collection machine:

Permissions

Collection machine

The collection machine can be any workstation or server, physical or virtual, that can connect via PowerShell to Microsoft Entra ID, Microsoft Graph, Exchange Online, Security & Compliance Center, SharePoint Online, Microsoft Teams, and Power Platform. It does not need to be AD- or Microsoft Entra-joined unless you have Conditional Access policies requiring it for these connections.

If directory synchronisation is used, a script will need to be executed on a domain-joined machine that has the Active Directory PowerShell module installed (whether the collection machine or a different machine).

Running the prerequisites script

  1. Open a new PowerShell window (not the ISE).

  2. Run the following to install the latest version of the SOA module from the PowerShell Gallery:

    Install-Module SOA

  3. Run the following to install the prerequisites (important: see below for optional parameters that may be applicable):

    Install-SOAPrerequisites

Optional parameters

Custom (vanity) SharePoint Online domain

If you use a custom domain to connect to the SharePoint Online admin endpoint (such as a multi-tenant enhanced organization), you need to specify the domain using -SPOAdminDomain <FQDN> or the connection test to SPO will fail.

Requiring a proxy

If traffic to Microsoft 365 routes via proxy infrastructure and the prerequisites installation fails because of this, try again with -UseProxy.

Sovereign clouds

If the Office 365 tenant is in a sovereign cloud environment, the -CloudEnvironment parameter must be used with one of the values below. (The default value is Commercial, so the parameter is only required for non-commercial clouds):

Active Directory module

If directory synchronisation is used and the Active Directory module is not installed and you cannot run PowerShell as a local admin, you can skip the installation of the module by using -SkipAdModule. A machine with the module installed will be needed on the first day of the engagement to collect information about the AD environment. The module can be installed on a machine using -AdModuleOnly or manually via another method.

Microsoft Entra app registration

An app registration is required to use Microsoft Graph and other APIs. Registration and configuration of this application is performed by the prerequisites script.

The permission scopes used by the app registration: API Scope Type Usage
Graph Application.ReadWrite.OwnedBy Application Update app registrations owned by the application (aka service principal). This allows the application to remove its own client secret when the prerequisites validation and data collection are complete.
Graph AuditLog.Read.All Application Get sign-in activity for user and guest accounts.
Graph DeviceManagementConfiguration.Read Application Get Intune configuration policies, if applicable.
Graph Directory.Read.All Application Get subscriptions in the tenant and sign-in activity for user and guest accounts. (Both this scope and AuditLog.Read.All are required in order to get sign-in activity.)
Graph IdentityRiskEvent.Read.All Application Get identity risk events raised by Microsoft Entra ID Protection.
Graph OnPremDirectorySynchronization.Read.All Application Get Microsoft Entra directory synchronization settings.
Graph Policy.Read.All Application Get various Microsoft Entra policies, such as authorisation, cross-tenant access, and conditional access.
Graph PrivilegedAccess.Read.AzureADGroup Application Get Privileged Identity Management roles assigned to groups, if applicable.
Graph RoleManagement.Read.All Application Get Privileged Identity Management roles assigned to users, if applicable.
Graph SecurityIdentitiesHealth.Read.All Application For organisations with Microsoft Defender for Identity, get health alerts.
Graph SecurityEvents.Read.All Application For organisations with Microsoft Defender for Identity, get configuration details from Secure Score that do not have an API available yet.
Graph ThreatHunting.Read.All Application For organisations with Microsoft Defender for Office 365 P2, get active automated investigations. For organisations with Microsoft Defender for Endpoint, get health alerts.
Dynamics CRM user_impersonation Delegated Get Dataverse settings.

App registration security

As a security-related assessment, we are conscious of the security of the app registration and enterprise application created for it, which is why the following security considerations are made:

Removal of app registration

You may remove the app registration at the conclusion of the engagement. It is not necessary, however, because it cannot be used without a valid client secret, which is removed when the collection script completes. It is important that you do not remove the app registration (or its enterprise application) between the prerequisites installation and the data collection.