01 / 13Identity and access
Microsoft Entra ID security hardening
Harden a Microsoft Entra ID tenant: Conditional Access, consent and guest settings, PIM, emergency access accounts and secretless workload identities.
- Service
- Entra ID
- Category
- Identity and access
- Baseline
- 12 controls
- Updated
On this page
Every Azure subscription trusts exactly one Microsoft Entra ID tenant, so whoever controls a privileged identity there controls your subscriptions, data and logs. Left at defaults, any member can register apps and consent to them, invite guests, and admins often hold permanent Global Administrator. The 2024 Midnight Blizzard intrusion at Microsoft followed that path: a password spray hit a legacy test tenant account without MFA, then the attackers abused an over-privileged OAuth app to read corporate mail. This page maps to the Microsoft cloud security benchmark (MCSB) Identity Management (IM) and Privileged Access (PA) controls and to the identity section of the CIS Microsoft Azure Foundations Benchmark.
Baseline controls
CIS numbers refer to the CIS Microsoft Azure Foundations Benchmark v7.0.0. That release moved Conditional Access and licensed Entra ID settings to the CIS Microsoft 365 Foundations Benchmark, so most identity rows carry no CIS number.
| Control | Why | How to check | ID |
|---|---|---|---|
| MFA for all users | Stops password spray and credential stuffing | az rest --url .../identity/conditionalAccess/policies | MCSB IM-6 |
| Phishing-resistant MFA for admins and admin portals | Admin sessions are the main target of AiTM phishing | Policy grant uses strength ...0004 | MCSB IM-6 |
| Block legacy authentication | IMAP, POP and SMTP AUTH cannot do MFA | SigninLogs by ClientAppUsed | MCSB IM-7 |
| Authentication methods policy | Weak methods (SMS, voice) stay usable otherwise | az rest --url .../policies/authenticationMethodsPolicy | MCSB IM-6 |
| Restrict default user permissions | Users create apps and tenants unseen | authorizationPolicy defaultUserRolePermissions | MCSB IM-2 |
| Restrict user consent | Illicit consent grants survive password resets | defaultUserRolePermissions.permissionGrantPoliciesAssigned | MCSB IM-2 |
| Restrict guest invites and access | Guests enumerate the directory | allowInvitesFrom, guestUserRoleId | CIS 5.3.2 |
| No standing privileged roles (PIM) | Any phished admin session becomes tenant takeover | Active assignments without end date | MCSB PA-2 |
| Access reviews of privileged roles | Eligible assignments accumulate | Identity Governance > Access reviews | MCSB PA-4 / CIS 5.3.4 |
| Emergency access accounts | Recover from CA or MFA outages | Two cloud-only GAs on FIDO2, alerted | MCSB PA-5 / CIS 5.10 |
| Managed identities instead of secrets | Client secrets leak through repos and CI | az ad app list with passwordCredentials | MCSB IM-3 / CIS 5.11 |
| Federated credentials for CI/CD | No secret to steal from the pipeline | az identity federated-credential list | MCSB IM-8 / CIS 5.11 |
Conditional Access baseline
Security defaults (one switch, any licence tier) enforces MFA registration, MFA for admins and blocks legacy authentication. As soon as you have Microsoft Entra ID P1, replace it with Conditional Access: security defaults cannot exclude your emergency accounts and has no report-only mode. The two are mutually exclusive.
az rest --method GET \
--url https://graph.microsoft.com/v1.0/policies/identitySecurityDefaultsEnforcementPolicy \
--query isEnabled
Microsoft now enforces MFA on its side for the Azure portal and admin centers (phase 1, rolled out from October 2024), and for create, update and delete operations from Azure CLI, Azure PowerShell, the Azure mobile app, infrastructure-as-code tools and REST endpoints (phase 2, rolling out gradually since 1 October 2025; read operations are not covered). Workload identities are not affected. Treat that as a safety net: it does not cover Microsoft 365, your own apps or legacy protocols.
Start from this set, each policy created in report-only mode (enabledForReportingButNotEnforced), reviewed for a week in the sign-in logs and the Conditional Access insights workbook, then switched to enabled:
| Policy | Users | Target resources | Grant |
|---|---|---|---|
| CA001 Admins | Privileged directory roles | All resources | Authentication strength: phishing-resistant MFA |
| CA002 Admin portals | All users | Microsoft Admin Portals | Require MFA |
| CA003 All users | All users | All resources | Require MFA (or the Multifactor authentication strength) |
| CA004 Legacy auth | All users | All resources, client apps Exchange ActiveSync and Other | Block |
| CA005 Azure management | All users | Windows Azure Service Management API | Require MFA |
| CA006 Security info | All users | User action: Register security information | Require MFA or trusted location |
Microsoft recommends the all-users policy target All resources with no resource exclusions. The Windows Azure Service Management API target covers Azure Resource Manager, the Azure portal and therefore Azure CLI and Azure PowerShell. Microsoft Admin Portals covers the Azure portal, Microsoft 365 admin center, Exchange admin center and Defender portal.
Every policy excludes the two emergency access accounts, and nothing else by default. "Temporary" exclusion groups with dozens of members are a common audit finding.
The admin policy as code, targeting roles by template ID (Global Administrator, Privileged Role Administrator, Security Administrator; add Conditional Access, Authentication, Application, Cloud Application, User, Exchange and SharePoint administrators):
{
"displayName": "CA001 Require phishing-resistant MFA for admins",
"state": "enabledForReportingButNotEnforced",
"conditions": {
"users": {
"includeRoles": [
"62e90394-69f5-4237-9190-012177145e10",
"e8611ab8-c189-46e8-94e1-60213ab1f814",
"194ae4cb-b126-40b2-bd5b-6091b380977d"
],
"excludeUsers": ["<breakglass-1-object-id>", "<breakglass-2-object-id>"]
},
"applications": { "includeApplications": ["All"] },
"clientAppTypes": ["all"]
},
"grantControls": {
"operator": "OR",
"authenticationStrength": { "id": "00000000-0000-0000-0000-000000000004" }
}
}
az rest --method POST \
--url https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies \
--headers Content-Type=application/json --body @ca001-admins.json
Before enforcing CA001, check that every admin has a FIDO2 key, a passkey in Microsoft Authenticator, Windows Hello for Business or a certificate registered, or they are locked out. Use the What If tool to prove the emergency accounts are excluded.
Block legacy authentication
Legacy protocols send a password and cannot answer an MFA challenge, which makes them the standard target of password spraying (MITRE ATT&CK T1110.003). Find who still uses them before CA004 goes live:
SigninLogs
| where TimeGenerated > ago(30d)
| where ClientAppUsed !in ("Browser", "Mobile Apps and Desktop clients")
| summarize Attempts = count(), Successes = countif(ResultType == "0")
by UserPrincipalName, ClientAppUsed, AppDisplayName
| order by Successes desc
The CA004 body differs from CA001 only in "clientAppTypes": ["exchangeActiveSync", "other"], "includeUsers": ["All"] and "grantControls": { "operator": "OR", "builtInControls": ["block"] }. Accounts with successes need a modern client first; devices sending mail through SMTP AUTH should move to OAuth or a dedicated relay.
Authentication methods and strengths
Under Entra ID > Authentication methods > Policies, enable Microsoft Authenticator, passkeys (FIDO2) and Temporary Access Pass, and disable SMS and voice except for groups that truly need them. Confirm the migration from the legacy per-user MFA and SSPR method settings shows as complete, otherwise the old settings still apply.
az rest --method GET \
--url https://graph.microsoft.com/v1.0/policies/authenticationMethodsPolicy \
--query "authenticationMethodConfigurations[].{method:id, state:state}" -o table
Authentication strengths let a policy demand a specific method set instead of "any MFA". Use the built-in phishing-resistant strength for admins and PIM activation (see below), and the Multifactor authentication strength for everyone else. Also add a custom banned password list (company name, products, cities) under Password protection, and in hybrid tenants keep the Entra smart lockout threshold below the AD DS threshold.
User settings and app consent
By default any member can register applications, create tenants and security groups, and consent to apps. Read and tighten the authorization policy:
az rest --method PATCH \
--url https://graph.microsoft.com/v1.0/policies/authorizationPolicy \
--headers Content-Type=application/json \
--body '{
"defaultUserRolePermissions": {
"allowedToCreateApps": false,
"allowedToCreateTenants": false,
"allowedToCreateSecurityGroups": false,
"permissionGrantPoliciesAssigned": []
}
}'
An empty permissionGrantPoliciesAssigned list means Do not allow user consent. An illicit consent grant, where a user approves an attacker's app for Mail.Read or Files.ReadWrite.All, hands over a refresh token that MFA and password resets do not revoke. Pair it with the admin consent workflow under Enterprise applications > Consent and permissions > Admin consent settings so users can request apps. If that is too strict, assign ManagePermissionGrantsForSelf.microsoft-user-default-low, which allows consent only to verified publishers for permissions you classify as low impact (User.Read, openid, profile, email, offline_access).
Then review what is already granted: GET /v1.0/oauth2PermissionGrants and app role assignments for unknown apps with mail, files or directory write scopes. Setting Restrict access to Microsoft Entra admin center to Yes hides the portal from non-admins but does not block Graph, so do not count it as a control.
Guest access
Guests come from partners whose security you do not control. In the same authorization policy set:
| Setting | Graph property | Target |
|---|---|---|
| Guest invite settings | allowInvitesFrom | adminsAndGuestInviters |
| Guest user access restrictions | guestUserRoleId | 2af84b1e-32c8-42b7-82bc-daa82404023b (most restrictive) |
Under External Identities > External collaboration settings, restrict collaboration to an allow list of partner domains where you can, and in Cross-tenant access settings decide whether to trust MFA from partner tenants instead of making guests register a second method. Include guests in the all-users MFA policy, and run a recurring access review on guest accounts with "remove access" when reviewers do not respond.
PIM for Entra and Azure roles
Privileged Identity Management (Microsoft Entra ID P2 or Entra ID Governance) replaces permanent assignments with eligible ones that a user activates for a few hours. It covers Entra roles, Azure resource roles (Owner, User Access Administrator, Contributor at any scope) and PIM for Groups.
Inventory standing privilege first. Entra roles:
az rest --method GET \
--url "https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?\$expand=principal" \
--query "value[].{role:roleDefinitionId, principal:principal.displayName}" -o table
Azure roles across subscriptions (Owner and User Access Administrator), with az graph query:
authorizationresources
| where type =~ "microsoft.authorization/roleassignments"
| extend roleId = tostring(split(properties.roleDefinitionId, "/")[-1])
| where roleId in ("8e3af657-a8ff-443c-a75c-2fe8c4bcb635", "18d7d88d-d35e-4fb5-a5c3-7773c20a72d9")
| project scope = tostring(properties.scope), principalType = tostring(properties.principalType),
principalId = tostring(properties.principalId)
Look hard at scope /: it usually comes from a Global Administrator who toggled Access management for Azure resources and never turned it off, which grants User Access Administrator over every subscription. Keep fewer than five Global Administrators (Microsoft's recommendation), ideally two named admins on separate cloud-only admin accounts without a mailbox (MCSB PA-1).
Role settings before conversion
Edit settings first under ID Governance > Privileged Identity Management > Microsoft Entra roles > Settings (and Azure resources for Owner and User Access Administrator on management groups and production subscriptions), or you convert assignments with permissive defaults:
| Setting | Value for the most privileged roles |
|---|---|
| Activation maximum duration | 1 to 4 hours (default 8) |
| On activation, require | Conditional Access authentication context with phishing-resistant MFA |
| Justification and ticket | Required |
| Approval | Required for Global Administrator and Privileged Role Administrator |
| Permanent eligible or active assignment | Not allowed, eligibility expires after 6 to 12 months |
| Activation notifications | Security team mailbox |
For the authentication context, create one (for example c1, "Privileged activation") under Conditional Access > Authentication context, target it with a policy requiring the phishing-resistant strength, and select it in the role setting. Then convert assignments by posting an adminAssign request to roleManagement/directory/roleEligibilityScheduleRequests with an afterDuration expiration, and remove the old active assignment. The Azure side and custom roles are covered on Azure RBAC.
Access reviews
Create recurring reviews in ID Governance > Access reviews for each privileged Entra role and for Owner at management group scope: quarterly for Global Administrator and Privileged Role Administrator, semi-annually for the rest, "remove access" if reviewers do not respond, and auto apply results enabled.
Emergency access accounts
Break-glass accounts exist for the day Conditional Access is misconfigured, federation is down or every admin loses their MFA device. Build two:
- Cloud-only on the
*.onmicrosoft.comdomain, so they do not depend on federation or custom domain DNS. - Permanent active Global Administrator, the one exception to PIM, because PIM itself may be what is broken.
- Not tied to a person: no mailbox, generic names.
- FIDO2 security keys (or certificate-based authentication), at least two per account, stored in separate safes. Platform MFA enforcement means an account without MFA can no longer reach the Azure portal.
- Excluded from Conditional Access policies that could lock everyone out (device, location, session), from PIM, auto-removing access reviews and inactivity cleanup. Keep one policy that requires phishing-resistant MFA for them, so excluded does not mean unprotected.
Document where the keys are, and test sign-in with each account every quarter.
Workload identities
A service principal with a client secret is a password that lives in repositories, CI variables and laptops (MITRE ATT&CK T1552.001). A managed identity is a service principal whose credentials Azure creates and rotates; code asks a local endpoint for a token and nobody sees a secret.
- System-assigned: lifecycle tied to one resource.
- User-assigned: standalone, attachable to several resources, and its role assignments exist before the compute does. Prefer it for production deployed with infrastructure as code.
az identity create -g rg-app1 -n id-app1-prod
az webapp identity assign -g rg-app1 -n app1-prod \
--identities "$(az identity show -g rg-app1 -n id-app1-prod --query id -o tsv)"
az role assignment create \
--assignee-object-id "$(az identity show -g rg-app1 -n id-app1-prod --query principalId -o tsv)" \
--assignee-principal-type ServicePrincipal --role "Storage Blob Data Reader" \
--scope "<storage-account-id>/blobServices/default/containers/invoices"
Any code on the resource can request the token (on a VM, 169.254.169.254; on App Service and Functions, IDENTITY_ENDPOINT), so an RCE or SSRF bug inherits the identity's roles. Grant data plane roles at container, secret or database scope, never Owner, Contributor or User Access Administrator at subscription scope, and use one identity per app and environment. Once clients use tokens, turn off key-based access on Storage accounts, SQL Database and other services, and keep unavoidable third-party secrets in Key Vault.
Hunt the remaining secrets and remove them:
az ad app list --all \
--query "[?passwordCredentials[0] != null].{app:displayName, appId:appId, ends:passwordCredentials[].endDateTime}" -o json
az ad app credential delete --id <appId> --key-id <keyId>
Tenant-wide app management policies (/policies/defaultAppManagementPolicy) can block new password credentials or cap their lifetime. Microsoft lists them as a free Workload ID capability, so no Workload ID Premium license is needed; they are configured only through Microsoft Graph or Graph PowerShell. Enforce managed identity use on compute with built-in policies such as App Service apps should use managed identity through Azure Policy.
Federated credentials
Workloads outside Azure (GitHub Actions, Azure DevOps, GitLab, Kubernetes, other clouds) exchange their own OIDC token for an Entra token through a federated identity credential that trusts one issuer and one subject:
az identity federated-credential create \
--name github-prod --identity-name id-deploy-app1 --resource-group rg-app1 \
--issuer https://token.actions.githubusercontent.com \
--subject repo:contoso/app1:environment:production \
--audiences api://AzureADTokenExchange
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
The subject is the security boundary. environment:production only accepts jobs in that GitHub environment, which can require reviewers; ref:refs/heads/main accepts anyone who can push to main. Avoid wildcard (flexible) credentials unless you know exactly what matches. App registrations work the same way with az ad app federated-credential create, and new Azure DevOps Azure Resource Manager service connections default to workload identity federation. Keep the deployment identity separate from the runtime identity.
Logging and detection
Send Entra logs to Log Analytics with a diagnostic setting under Entra ID > Monitoring & health > Diagnostic settings: SignInLogs, NonInteractiveUserSignInLogs, ServicePrincipalSignInLogs, ManagedIdentitySignInLogs, AuditLogs, RiskyUsers, UserRiskEvents and MicrosoftGraphActivityLogs. Retention and routing are covered on Azure Monitor. Create these as log search alerts that page a human through an action group.
Any emergency account sign-in or change (run every 5 minutes):
union SigninLogs, AuditLogs
| where UserId in ("<bg1-id>", "<bg2-id>")
or tostring(TargetResources) has_any ("<bg1-id>", "<bg2-id>")
| project TimeGenerated, Type, UserPrincipalName, OperationName, IPAddress, ResultType
Role assignments that bypass PIM (T1098.003):
AuditLogs
| where Category == "RoleManagement"
| where OperationName == "Add member to role" and LoggedByService != "PIM"
| project TimeGenerated, InitiatedBy, TargetResources
New credentials on apps and service principals, a classic persistence step (T1098.001), and new consent grants:
AuditLogs
| where OperationName has "Certificates and secrets management"
or OperationName in ("Add service principal credentials", "Consent to application")
| project TimeGenerated, OperationName, InitiatedBy, TargetResources
Also alert on PIM activations outside business hours followed by Conditional Access or authentication method changes, and baseline ManagedIdentitySignInLogs per identity to flag new target resources. Microsoft Entra ID Protection risk detections and Defender for Cloud identity recommendations feed Defender for Cloud.
Common mistakes
- Keeping security defaults on a P1 tenant: emergency accounts cannot be excluded, so a lockout has no way back.
- A broad "CA exclusions" group that nobody reviews, quietly exempting service accounts and executives from MFA.
- Enforcing the phishing-resistant admin policy before admins register FIDO2 keys or passkeys, locking them out.
- Leaving user consent on: one click by a user on a malicious app grants mailbox access that a password reset does not revoke.
- Emergency accounts on the same Authenticator phone as the daily admin, or never tested, or not alerted on.
- Workload identities with Contributor at subscription scope, or a client secret with a two-year expiry stored in a pipeline variable.
References
- Security defaults in Microsoft Entra ID (Microsoft Learn)
- Targeting resources in Conditional Access policies (Microsoft Learn)
- Block legacy authentication with Conditional Access (Microsoft Learn)
- What is Microsoft Entra Privileged Identity Management? (Microsoft Learn)
- Manage emergency access accounts in Microsoft Entra ID (Microsoft Learn)
- Managed identity best practice recommendations (Microsoft Learn)
- Workload identity federation (Microsoft Learn)
- Microsoft cloud security benchmark: Identity Management (Microsoft Learn)
- Microsoft cloud security benchmark: Privileged Access (Microsoft Learn)
- Midnight Blizzard: Guidance for responders on nation-state attack (Microsoft Security Blog)
- CIS Microsoft Azure Foundations Benchmark (Center for Internet Security)
- Configuring OpenID Connect in Azure (GitHub Docs)
Frequently asked questions
Should I use security defaults or Conditional Access?
Use security defaults only if the tenant has no Microsoft Entra ID P1 licences. With P1, switch to Conditional Access: it gives the same protections plus exclusions for emergency access accounts, report-only testing and authentication strengths. The two cannot run at the same time.
Does blocking legacy authentication break anything?
It can break old mail clients, scanners and scripts that send a password over IMAP, POP or SMTP AUTH. Run the policy in report-only mode first and query the sign-in logs by client app to find them before you enforce.
Filed under entra-id, identity, privileged-access, cis-benchmark
Written by
Florian Amette, Cloud Security Engineer & EditorSecurity engineer writing practical hardening pages for Microsoft Azure tenants and subscriptions, aligned with the CIS Microsoft Azure Foundations Benchmark.