Azure and Entra ID Security
Microsoft's cloud has two halves that people often mix up: Entra ID (formerly Azure Active Directory), the identity system behind Microsoft 365 and Azure sign-ins, and Azure itself, where virtual machines, storage and databases live. Most serious Microsoft-cloud breaches start in Entra ID, not in a misconfigured VM. This page explains how the two fit together, the attacks that matter (password spray, consent phishing, device-code phishing, token theft, abused OAuth apps), what to log and how to respond. If you know AWS, the comparison table below is the fastest way in.
Last verified2026-10
How Azure Is Organised
What is this?One tenant is one organisation's instance of Entra ID: its users, groups, applications and policies. Azure resources hang off that tenant in a hierarchy.
Entra ID tenant (contoso.onmicrosoft.com) ← identities, apps, Conditional Access, Entra roles
└── Root management group
├── Management group: Production ← Azure Policy and RBAC set here inherit downwards
│ └── Subscription: prod-payments ← billing and blast-radius boundary (like an AWS account)
│ └── Resource group: rg-api ← lifecycle container
│ └── Resources: VM, Storage account, Key Vault, SQL
└── Management group: SandboxWhy it mattersThere are two separate permission systems, and confusing them is a classic interview trap:
Control the directory: users, apps, policies. Global Administrator, Privileged Role Administrator, Application Administrator
Control resources: Owner, Contributor, Reader, User Access Administrator, assigned at a management group, subscription, resource group or resource
A Global Administrator can switch on "Access management for Azure resources" and give themselves User Access Administrator over every subscription. Entra admin is effectively Azure admin
| Concept | AWS | Azure |
|---|---|---|
| Identity store | IAM (per account) + IAM Identity Center | Entra ID (one per tenant, shared with Microsoft 365) |
| Isolation boundary | Account | Subscription |
| Org guardrails | Organizations + SCPs | Management groups + Azure Policy (deny effects) |
| Workload identity | IAM role on EC2/Lambda | Managed identity (system- or user-assigned) |
| Metadata credentials | IMDS 169.254.169.254 | IMDS 169.254.169.254, requires the Metadata: true header |
| Audit of control plane | CloudTrail | Activity Log (resources) + Entra audit and sign-in logs (identity) |
| Secrets and keys | Secrets Manager, KMS | Key Vault |
| Threat detection | GuardDuty, Security Hub | Defender for Cloud, Microsoft Sentinel |
Identities and How They Get Tokens
What is this?Everything in Entra ID signs in and receives OAuth tokens: an access token for one API (Microsoft Graph, Azure Resource Manager, Exchange), often with a longer-lived refresh token. Four kinds of identity matter:
A person; signs in interactively, ideally with MFA and Conditional Access
An application's definition and its instance in a tenant. Has secrets or certificates, and API permissions granted by consent
A service principal Azure manages for a VM, Function or container: no secret to leak, tokens come from the metadata endpoint
An external workload (GitHub Actions, Kubernetes) swaps its own OIDC token for an Entra token. No stored secret
In practiceOn a VM with a managed identity, any process (or an SSRF bug) can ask the metadata service for a token:
$ curl -s -H "Metadata: true" \
"http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"
{"access_token":"eyJ0eXAiOiJKV1Qi…","expires_in":"86399",
"resource":"https://management.azure.com/","token_type":"Bearer"} ← valid for the identity's RBAC rolesThe required Metadata: true header blocks the simplest SSRF (one that can't set headers), much like AWS IMDSv2's token. It does not help if the attacker can run code on the VM, so keep the identity's roles narrow.
📰Real incident — Microsoft AI research SAS token (2023). Microsoft researchers shared AI training data on GitHub using a link to an Azure Storage account. The link carried a shared access signature (SAS) token that granted full control of the entire storage account, not one folder, and didn't expire until 2051. Wiz found it exposed 38 TB, including workstation backups with secrets and internal Teams messages. SAS tokens are signed outside Entra ID, so they don't show up in identity reviews. Prefer user-delegation SAS with short expiry, or disable account-key access.
Conditional Access, MFA and Privileged Access
What is this?Conditional Access is Entra ID's policy engine: if a sign-in matches conditions (user, app, location, device state, risk), then block it or require something (MFA, a compliant device, phishing-resistant authentication). It is the main control between a stolen password and your data.
How it works
-
User or app requests a tokenSign-inevery sign-in
- Username + first factor, client app, IP, device
-
Conditional Access checks every matching policyEvaluate~ms
- Conditions: who, which app, where from, device compliant?, sign-in risk
-
Require controls, or blockGrantper policy
- MFA, phishing-resistant MFA (FIDO2, Windows Hello), compliant device, terms
-
Token issued with claimsTokenon success
- Continuous access evaluation can revoke it early on critical events
Baseline policies interviewers expect you to name:
- Block legacy authentication (old protocols like IMAP and POP can't do MFA, so password spraying targets them).
- Require MFA for all users; phishing-resistant MFA for admins.
- Require a compliant or hybrid-joined device for admin portals.
- Block or restrict the device code flow where it isn't needed (see Storm-2372 below).
- Two or more break-glass accounts excluded from Conditional Access, with long random passwords or FIDO2 keys, monitored by alerts on any sign-in.
Privileged Identity Management (PIM) makes admin roles eligible rather than permanent: an admin activates Global Administrator for one hour, with a justification and possibly approval, and the activation is logged.
Last verified2026-10
Microsoft now enforces MFA for Azure management. Phase 1 (Azure portal, admin centres) reached all tenants in March 2025. Phase 2 (Azure CLI, PowerShell, infrastructure-as-code tools and REST API create/update/delete calls) began rolling out on 1 October 2025. Managed identities and service principals are excluded, which is one more reason attackers go after workload credentials.
How Entra ID Gets Attacked
-
Get a token or a passwordInitial accessstep 1
- Password spray against accounts without MFA or via legacy protocols
- Adversary-in-the-middle phishing that steals the session cookie after MFA
- Device-code or consent phishing: the user signs in to the real Microsoft page
-
Make access survive a password resetPersistencestep 2
- Register a device, add credentials to an existing app, create an OAuth app
- Add a federated domain or a new MFA method
-
ClimbPrivilegestep 3
- Abuse app permissions (RoleManagement.ReadWrite.Directory), PIM gaps, Entra Connect sync accounts
-
ActObjectivestep 4
- Read mail through Graph or EWS, pivot into Azure subscriptions, exfiltrate SharePoint
Password spray and legacy test tenants
📰Real incident — Midnight Blizzard at Microsoft (2024). Russia's SVR-linked group password-sprayed a legacy, non-production test tenant account that had no MFA. In that tenant they found an old test OAuth application that had elevated access to Microsoft's corporate tenant. They used it to create more malicious apps and grant them the Exchange
full_access_as_approle, which can read every mailbox, then read email of senior leadership and security staff. Lessons: old test tenants and apps are in scope, app permissions are as powerful as admin roles, and they persist through password resets.
Consent phishing (illicit consent grant)
The attacker registers a multi-tenant app called something like "Document Viewer" and sends a link to Microsoft's real consent page. The user clicks Accept, granting it Mail.Read and offline_access. No password is stolen and MFA is satisfied, but the attacker's app now reads the mailbox with a refresh token. Defences: restrict user consent to verified publishers and low-risk permissions, use the admin consent workflow, and review new grants.
Device code phishing
The device code flow exists for TVs and command-line tools: the device shows a code, and you type it at microsoft.com/devicelogin on another device. An attacker starts the flow, sends the victim the code in a fake Teams meeting invite, and the victim signs in to the real Microsoft page, with MFA, on the attacker's behalf.
📰Real incident — Storm-2372 (2025). Microsoft reported in February 2025 a campaign, active since August 2024, that used fake WhatsApp, Signal and Teams invitations to get government, defence, telecom and energy staff to enter attacker-generated device codes. With the captured tokens they read mail, and later switched to a client ID that let them register their own device in Entra ID for lasting access. Microsoft later linked the group to Midnight Blizzard. Defence: a Conditional Access policy blocking device code flow for everyone who doesn't need it.
Token theft and hybrid identity
proxies the real sign-in page and steals the session cookie after MFA. Phishing-resistant MFA (FIDO2, passkeys) and token protection stop it, because the credential is bound to the real domain or device.
theft from a joined Windows device gives single sign-on to everything. Protect with Credential Guard and device compliance checks.
Entra Connect syncs on-premises AD to Entra ID, so its server and sync account are Tier 0. Whoever controls it can reset cloud passwords or extract credentials. With AD FS, stealing the token-signing certificate allows Golden SAML: forging sign-ins for any user, as in the SolarWinds campaign (2020).
Logging and Detection
What is this?Identity attacks show up in identity logs, not in VM logs. Know which log answers which question:
Who signed in, from where, with which app, which MFA method, which Conditional Access policies applied. Interactive, non-interactive, service principal and managed identity variants
Directory changes: new apps, consent grants, role assignments, new credentials on apps, Conditional Access edits, federation changes
Azure control plane: who created, changed or deleted which resource (like CloudTrail management events)
Every Graph API call a user or app made, the key log for mailbox and file access by apps
Data plane per service: Key Vault secret reads, Storage blob access. Off by default; send them to a Log Analytics workspace
Last verified2026-10
Entra keeps sign-in and audit logs for 7 days on the free tier and 30 days with P1 or P2. For investigations, export them to a Log Analytics workspace or a SIEM from day one.
In practiceTwo Microsoft Sentinel (KQL) hunts worth knowing by heart:
// New consent grants to applications: consent phishing and Midnight Blizzard-style persistence
AuditLogs
| where OperationName == "Consent to application"
| extend Who = tostring(InitiatedBy.user.userPrincipalName), App = tostring(TargetResources[0].displayName)
| project TimeGenerated, Who, App, Result
// Successful device-code sign-ins: rare for normal users, Storm-2372's technique
SigninLogs
| where AuthenticationProtocol == "deviceCode" and ResultType == 0
| project TimeGenerated, UserPrincipalName, AppDisplayName, IPAddress, Location ← who really needs this?🎯On the job. In an Entra ID review, check these first:
- Who holds Global Administrator and Privileged Role Administrator, and is it permanent or PIM-eligible?
- Which apps hold high-impact Graph permissions (
RoleManagement.ReadWrite.Directory,AppRoleAssignment.ReadWrite.All,Mail.ReadWrite,full_access_as_app), and who owns them?- Can users consent to apps themselves?
- Is legacy authentication blocked, and is device code flow restricted?
- Are break-glass accounts excluded from Conditional Access and alerting on use?
- Are there forgotten test tenants or test apps with production permissions?
Responding to a Compromised Entra Account or App
-
Cut accessContainminutes
- Disable the user; revoke sessions (Revoke-MgUserSignInSession) so refresh tokens die
- Disable the service principal; remove its secrets and certificates
-
Find what changedScopehours
- Audit logs for new apps, consents, app credentials, role assignments, MFA methods, devices, federated domains
- Sign-in and Graph activity logs for what the identity read
-
Remove persistenceEradicatehours
- Delete malicious apps and consent grants, rogue devices and MFA methods; revert Conditional Access edits
- Rotate secrets the identity could read (Key Vault, app secrets)
-
Harden and watchRecoverdays
- Phishing-resistant MFA, consent restrictions, device code block, PIM; alert on the techniques used
A password reset alone is not enough: refresh tokens, app credentials, registered devices and consent grants all survive it.
Interview Questions
Entra roles control the directory itself: users, groups, applications and policies, with Global Administrator at the top. Azure RBAC roles control resources such as VMs and storage, assigned at a management group, subscription, resource group or resource, with Owner and User Access Administrator as the powerful ones. They're separate systems, but a Global Administrator can turn on "access management for Azure resources" and grant themselves User Access Administrator over every subscription, so Entra admin is effectively Azure admin and must be protected as Tier 0.
Both give a workload credentials without a stored secret: the code asks the metadata endpoint at 169.254.169.254 for a short-lived token. Azure requires a Metadata: true header, which blocks the simplest SSRF the same way IMDSv2's session token does on AWS. The abuse is the same as Capital One: anyone who can run code on the VM, or an SSRF that can set headers, gets a token for every role the identity holds. So the fix is narrow RBAC on the identity, one identity per workload, and monitoring the identity's sign-ins for use from unexpected places.
The attacker registers an app with a convincing name and sends the user a link to Microsoft's real consent page. When the user clicks Accept, the app gets the permissions it asked for, like reading mail, plus a refresh token, without any password being stolen and with MFA fully satisfied. Prevention is restricting user consent to verified publishers and low-risk permissions, routing everything else through an admin consent workflow, and alerting on new consent grants in the audit logs. If it happens, revoking the grant and deleting the service principal removes access, which a password reset would not.
In 2024, Russia's SVR-linked group password-sprayed an account in a legacy test tenant that had no MFA. There they found an old OAuth test app with elevated permissions in Microsoft's corporate tenant, used it to create new apps, and granted those apps full access to Exchange mailboxes, reading senior leadership email. The lessons are that test tenants and forgotten apps are part of your attack surface, that application permissions can be as powerful as Global Administrator, and that app-based access survives password resets, so app inventories and permission reviews matter as much as user MFA.
The device code flow lets a device without a keyboard sign in by showing a code that you enter on another device. The attacker starts the flow and sends the victim the code, for example in a fake Teams invite. The victim then signs in on the genuine Microsoft page and completes MFA, but the tokens go to the attacker's session. MFA doesn't help because the victim really is the one authenticating. Storm-2372 used this against governments in 2024–2025. The fix is a Conditional Access policy that blocks device code flow except for the few users and devices that need it, and hunting for successful device-code sign-ins.
I disable the account and revoke its sessions so existing refresh tokens stop working, because a password reset alone leaves them valid. Then I check the audit logs for persistence: new MFA methods, registered devices, app consent grants, credentials added to applications, role assignments and any federation changes. I remove each one. I use sign-in and Graph activity logs to scope what was read, rotate any secrets the user could reach, and close the entry route, such as moving the user to phishing-resistant MFA or blocking device code flow.
Entra Connect synchronises on-premises Active Directory to Entra ID, so its server and service accounts can write identity data into the cloud tenant and, depending on configuration, read password hashes. An attacker who controls it can reset cloud passwords or harvest credentials, moving from on-premises to cloud. With AD FS federation, stealing the token-signing certificate enables Golden SAML, forging a sign-in as anyone, which happened in the SolarWinds campaign. So those servers get domain-controller-level protection: restricted admins, no internet browsing, and close monitoring.