Lesson 3 of 3 Azure Role-Based Access Control

Evaluating and Remediating Overprivileged Access

This lesson gives a method for finding excess privilege and reducing it safely.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how privilege creep happens.
  • Find broad and orphaned role assignments.
  • Compare granted access with used access.
  • Reduce a role assignment without breaking a process.

How privilege creep happens

Nobody designs an environment in which forty people are subscription Owners. It happens gradually: someone needs temporary access during an incident, a contractor's account is left behind after a project, a person changes team and keeps old rights, or a deployment identity is given Contributor because it was quick. The result is privilege creep, and every excess right is available to an attacker who compromises that identity.

The aim of a review is to compare the access that is granted with the access that is used, and then to reduce the gap. A review needs evidence, and Azure provides several sources of it.

Finding what is assigned

The Access control (IAM) page shows role assignments at a scope, including inherited ones, and Check access shows what a named principal has. The Azure CLI can export the list for analysis, as follows.

az role assignment list --all --include-inherited --include-groups \
  --query "[?roleDefinitionName=='Owner'].{who:principalName,type:principalType,scope:scope}" -o table

Begin with the broadest combination of role and scope. Owner or Contributor at management group or subscription level has the greatest effect, so examine those first, and then look at other roles at those scopes. Pay attention to the following items.

  • Direct user assignments, which should normally be groups.
  • Orphaned assignments, which show as Unknown or as an identity not found, because the principal was deleted.
  • Permanent assignments of privileged roles, which should be eligible through PIM.
  • Service principals with broad roles, which often have more than their job needs.
  • Guests with privileged roles, whose accounts are controlled by another organization.
Select all that apply

Red flags in a review

Exam skills 1.3.7

Identify the assignments that deserve attention in an access review.

Log in to try this activity Interactive activities are free with an account.

Finding what is used

A role that a person has not used in six months is a strong candidate for removal. The Azure Activity log records control plane operations, so querying it shows what a principal has actually done. Sending the log to a Log Analytics workspace extends the default retention of 90 days. The following query counts operations by caller over a period.

AzureActivity
| where TimeGenerated > ago(90d)
| where CategoryValue == "Administrative"
| summarize Operations = count() by Caller
| order by Operations desc

Defender for Cloud also helps. Its recommendations include limits on the number of subscription owners and the removal of external accounts with owner permissions, and its permissions management recommendations, available through Defender CSPM with cloud infrastructure entitlement management, report unused identities and excessive permissions across clouds. Microsoft Entra access reviews put the decision in front of a manager or resource owner.

True or false

Evidence of use

Exam skills 1.3.7

Check the sources that show what access is actually used.

Log in to try this activity Interactive activities are free with an account.

Remediating safely

Removing access without care can break a production process, so reduce in stages. The following sequence is a sound approach.

  1. Identify the task

    Establish what the principal really needs to do, using logs and its owner.

  2. Choose a narrower grant

    Replace the broad role with a job-specific role, at a narrower scope.

  3. Add before removing

    Assign the narrower role, and test that the process still works.

  4. Remove the broad role

    Delete the old assignment, and monitor for failures.

  5. Move what remains to PIM

    Make any remaining privileged role eligible, so that it is not standing access.

  6. Schedule a review

    Create a recurring access review so that the same problem does not return.

Maintain a small, justified set of exceptions. Microsoft recommends no more than three subscription Owners, for example, while keeping more than one so that a single departure cannot lock the organization out.

Put in order

Reducing access safely

Exam skills 1.3.7

Put the steps of a safe privilege reduction in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Reducing a deployment identity

A service principal used by a pipeline holds Owner on a production subscription. Logs show that in 90 days it has only deployed App Service apps into two resource groups. You must reduce its access with minimum risk. What should you do?

The logs reveal the true need: web app deployment in two resource groups. Assign Website Contributor at each of those resource groups, run a test deployment, and only then remove Owner. Check whether the pipeline also creates role assignments, because Owner would have hidden that dependency; if it does, add a conditioned Role Based Access Control Administrator assignment.

Removing Owner first risks a failed deployment during the change. Moving Owner to PIM would not help a pipeline, since it cannot activate a role interactively, and Owner at subscription scope would remain far too broad. A resource lock would stop deletion, but it would not reduce the identity's access.

Check yourself

A role assignment appears as Unknown on the IAM page. What does this mean?

Show answer

The principal has been deleted, which leaves an orphaned assignment that should be removed.

Exam Tips

Remember for the exam

  • Start with the broadest roles at the broadest scopes.
  • Compare granted access with used access in the activity log.
  • Add the narrow role before removing the broad one.
  • Unknown principals in IAM are orphaned assignments and should be removed.