Removing stale identities: the basics
What does a stale or external Azure identity actually look like?
A role assignment on a subscription is a standing grant: it stays in place until someone removes it, regardless of what happens to the person or the account behind it. Exposure here shows up in a handful of distinct shapes rather than one setting. A blocked account is one that has been disabled from signing in to Microsoft Entra ID, usually because someone left, but whose RBAC grant on your resources was never cleaned up. A deprecated account is Defender for Cloud's name for that same blocked account when it still holds a role on a subscription. An external account is a sign-in from a different domain, an identity that lives in someone else's directory. A guest account is a B2B user provisioned into your tenant from outside it. Each is its own Defender for Cloud recommendation, but the underlying risk is the same: an identity that should not, or no longer should, be able to act on your estate still can.
Microsoft Defender for Cloud turns each of these into its own recommendation, split further by the level of access the identity holds, owner, write, or read, which is why one subscription can fail several identity checks at once. 'Blocked accounts with owner permissions on Azure resources should be removed' and 'Deprecated accounts with owner permissions should be removed from subscriptions' close the door on people who have gone; 'External accounts with owner permissions should be removed from subscriptions' and the guest-account recommendations close the door on identities you do not manage. They read as separate problems on the report, but they are one job: every account that can act on the estate is one you intend, manage, and can hold accountable.
Most of this exposure is drift, not intent. A contractor offboarded in Entra but never removed from the subscription. A partner invited as a guest for one project and forgotten two projects later. An owner grant handed to an external email during a migration that nobody walked back. The work is to find every identity that is blocked, deprecated, external or guest and still carries a role, decide which handful are external collaborators you genuinely rely on, govern those properly, and remove the rest.
In this lesson you will learn how Azure expresses standing access through role assignments, how blocked, deprecated, external and guest identities each become a Defender for Cloud finding, how to find every stale or external grant across a subscription, and how to remove them without locking out the collaborators you genuinely need. The Controls this lesson covers section lists every Defender for Cloud recommendation in this capability, each linking to a deep page with the exact check and a copy-and-paste fix.
The account that left but never logged off
A recurring finding in post-incident reviews is the departed insider whose access outlived their employment. The account is disabled in the directory, so it looks gone, but a role assignment on a subscription is a separate object that nobody removed, and a disabled directory account does not automatically lose its RBAC grants. Defender for Cloud labels these 'deprecated' or 'blocked' accounts precisely because they are the quiet ones: not in active use, easy to overlook, and exactly what an attacker looks for when hunting a way in that nobody is watching. Removing the role assignment, not just disabling the sign-in, is what actually closes the door.
Finding stale and external access across a subscription
Sam is the security lead at a scale-up preparing for its first ISO 27001 audit. Defender for Cloud shows identity findings spread across two subscriptions: blocked and deprecated accounts that were offboarded in Entra but never removed from RBAC, plus a handful of external and guest accounts left over from old partner projects.
Rather than work the findings one by one, Sam starts by listing the role assignments on the subscription and picking out the ones held by external identities, the sign-ins from another domain, so the genuine collaborators can be separated from drift before anything is removed.
Start by listing role assignments held by external identities. Guest and external sign-ins carry '#EXT#' in their principal name, which makes them easy to spot.
An external identity holding Owner is the highest-value target in this group. The level of access sets the priority: owner before write before read.
How Defender for Cloud decides an identity is stale or externaldeep dive
These recommendations resolve to two things: the state of the identity in Microsoft Entra ID, and the role assignments that identity holds on a scope. A blocked or deprecated account is one whose 'accountEnabled' property is false, it has been disabled from signing in, yet a role assignment on a subscription or resource still references its object ID. An external or guest account is one whose home directory is not your tenant: in role-assignment output its 'principalType' is User but its 'principalName' carries the '#EXT#' marker, and in the directory its 'userType' is Guest. Defender then splits each into owner, write and read variants based on the role definition behind the assignment, which is why a single stale identity can raise several findings.
An important distinction sits behind the names. Some of these recommendations have a matching built-in Azure Policy and some do not. The 'Deprecated accounts' and 'External accounts' recommendations each map to a built-in auditIfNotExists policy, so you can assign them to keep the assessment running on a schedule. The 'Blocked accounts' and 'Guest accounts' recommendations carry the note 'No related policy', they are assessed by Defender for Cloud's own identity scanner rather than by an assignable policy, so the remediation for those is operational, removing the assignment, rather than policy enforcement.
Defender for Cloud evaluates these against the Microsoft Cloud Security Benchmark on a periodic cycle, so removing an assignment does not flip the recommendation to Healthy instantly. The RBAC change itself is immediate, the access is gone, but the posture catches up on the next assessment. This matters when you are gathering audit evidence against a deadline. Note too that removing a role assignment removes the access, not the directory object; for a leaver you also disable or delete the account in Entra, and for a guest you can remove the guest object once no scope depends on it.
What is the impact of leaving stale or external access in place?
The direct impact is unmonitored access by an identity you do not control. A blocked or deprecated account belongs to someone who has gone, yet if its credential is ever recovered or the directory account is re-enabled, the standing role assignment springs back to life with whatever it granted. An external or guest account lives in another organisation's directory, governed by their password policy, their multi-factor enforcement and their offboarding, not yours, so an owner grant to an external email is an owner grant to a security posture you cannot see. The overwhelming majority of these grants are accidents: a role left in place after a person left or a project ended.
The second-order impact is accountability and blast radius. Every standing grant to an account you do not manage is access you cannot reliably attribute, monitor or revoke at speed during an incident. Owner is the worst case, because it includes the right to grant access to others, so a single stale owner can quietly widen the door further. Removing stale and external grants shrinks the set of identities that can act on the estate to the ones you employ, manage and can hold accountable, which is the only set you can actually defend.
On the compliance side, every modern framework, ISO 27001, SOC 2, HIPAA, PCI DSS and the UK and EU data-protection regimes, expects evidence of joiner-mover-leaver hygiene and periodic access review: that access is removed when people leave and that third-party access is governed and time-bound. A clean set of identity recommendations across every subscription, backed by an access review for the external collaborators you keep, is the cheapest and most defensible artefact you can hand an auditor.
How do you remove stale access safely?
Work the capability as one loop rather than chasing individual findings. The order matters: identify the external collaborators you genuinely rely on before you start removing things, so you do not cut off an active partner or auditor.
1. Inventory every identity by state and access level
List the role assignments on each subscription and classify the principals: blocked or deprecated (accountEnabled is false in Entra), external or guest (the '#EXT#' marker, userType Guest), and the rest. Record the level of access each holds, owner, write or read. Treat this inventory as the source of truth, not the Defender finding count, because one stale identity can trigger several recommendations at once.
2. Separate genuine external collaborators from drift
Most external and guest access is leftover. For each external or guest identity, decide whether the engagement is still live. A current partner or auditor is legitimate and should move to governed, time-bound access through a Microsoft Entra access review or Privileged Identity Management eligible assignment, never a standing owner grant. Everything else, and every blocked or deprecated account of someone who has left, is drift and can be removed.
3. Remove access, highest impact first
Remove the role assignment for each stale grant, owner before write before read, and for a leaver also disable or delete the Entra account so the identity itself is gone, not just its access. Prioritise production and data-bearing scopes over sandboxes. Each removal is a single command per assignment and takes effect immediately.
4. Keep it shut with policy and process
Assign the built-in auditIfNotExists policies for deprecated and external accounts so the assessment keeps running on a schedule, wire offboarding so disabling a leaver also removes their grants, and put the external collaborators you keep into a recurring Entra access review so their access expires unless re-justified. That turns a one-off cleanup into a lifecycle guarantee.
# Remove the highest-impact stale grants first: external/guest identities holding Owner.
SCOPE="/subscriptions/00000000-0000-0000-0000-000000000000"
az role assignment list --scope "$SCOPE" --all --include-inherited \
--query "[?contains(principalName, '#EXT#') && roleDefinitionName=='Owner'].principalId" -o tsv |
while read -r oid; do
az role assignment delete --assignee-object-id "$oid" --scope "$SCOPE"
echo "$oid: external Owner assignment removed"
done
# Find blocked/deprecated (disabled) accounts that still hold a role on this scope.
for oid in $(az role assignment list --scope "$SCOPE" --all \
--query "[?principalType=='User'].principalId" -o tsv | sort -u); do
enabled=$(az ad user show --id "$oid" --query accountEnabled -o tsv 2>/dev/null)
if [ "$enabled" = "false" ]; then
echo "$oid is disabled in Entra but still holds a role - remove its assignment"
fi
done
# Keep it shut: assign the built-in deprecated-owner policy by its exact display name
# (look the id up at runtime - never hardcode a policy GUID).
pid=$(az policy definition list \
--query "[?displayName=='Deprecated accounts with owner permissions should be removed from your subscription'].name" -o tsv)
az policy assignment create \
--name audit-deprecated-owners \
--policy "$pid" \
--scope "$SCOPE" Quick quiz
Question 1 of 5Defender for Cloud shows findings across blocked, deprecated, external and guest accounts on several subscriptions. What is the most efficient way to think about them?
You scored
0 / 5
Keep learning
Go deeper on how Azure expresses standing access and how to govern the external collaborators you keep across the settings in this capability.
- Remove Azure role assignments How to remove a role assignment with the Azure CLI, portal or PowerShell, the core remediation for a stale grant.
- Assign Azure roles to external guest users How external and guest identities appear in RBAC, including the '#EXT#' principal name and userType Guest.
- What are Microsoft Entra access reviews? The recommended way to govern the external collaborators you keep with time-bound, periodically re-justified access.
You can now treat stale and external identities as one capability rather than a scatter of findings: inventory who holds a role and at what level, separate the external collaborators you genuinely rely on and move them to governed, time-bound access, remove every blocked, deprecated and orphaned external grant highest-impact first, and keep the estate shut by wiring removal into offboarding and access review. The Controls this lesson covers section below links every recommendation in this group to its deep page and fix.
Back to the library