Back to previous page

Block User Access to Azure AD PowerShell and Graph API Explorer

Blocking user access

By default, any user of Office 365 or Azure AD tenant can read the content of Azure AD using PowerShell and Graph API Explorer. This is a serious security issue because users have undetectable access to other users’ personal data, which violates for instance GDPR. In this blog, I’ll tell how to prevent the access.

Azure AD PowerShell access

As I described in my earlier blog post, any user of Office 365 or Azure AD tenant can access Azure AD and, for instance, export the whole directory and see who has admin rights.

Quite often when I discuss this issue with other administrators, they argue that this is quite similar to the on-premises AD, where users also have access to the directory. Well, that is true but what is the real scenario where regular users do need to have access to admin tools? I don’t know any of such situation. Also, as far as I know, Google doesn’t provide such access to their directory..

So, how do we blog regular users PowerShell access to Azure AD? Just run the following command as Global Admin, and you’re done!

To be more specific, users still do have PowerShell access to Azure AD but they are not able to read other users’ information. Now, when users are trying to read Azure AD using any of the following commands:

They will get error similar to this:

NOTE: As pointed out by @nestafo and @loukkis, disabling user access to others’ information causes problems in Teams and Planner: users will not able to add new members.

Azure AD Graph Explorers

Azure Active Directory Graph API and Microsoft Graph are REST APIs for accessing Azure AD. To use them, one must register an app to Azure AD and assign permissions to it. To do that, you will need admin rights, such as Global Administrator, to Azure AD. In other words, users are not able to access Azure AD using their own apps, unless administrators allow them to do so.

Microsoft has developed API explorers to ease the development of apps using Graph APIs. From technical point-of-view these explorers are apps, that need to be given access to Azure AD tenant. However, the problem is that these API explorers are already authorised by Microsoft to access all Azure AD tenants!

Azure AD Graph Explorer

Azure AD Graph Explorer can be found here.

Login

To use the API, the user needs to login:

After successful login, the user is asked to grant permissions for the Graph explorer:

Permissions requested

To get the list of users, one can use the following url in explorer:

As a result, all users are returned in JSON.

Microsoft Graph Explorer

Microsoft Graph Explorer can be found here.

Sign in with Microsoft

To use the API, the user needs to login:

After successful login, the user is asked to grant permissions for the Graph explorer:

Permissions

To get the list of users, one can use the following url in explorer:

As a result, all users are returned in JSON.

If compared to Azure AD Graph results, there is a lot less information. To get more details, one can use the beta version of the API:

How to blog access to Graph APIs

Actually, you cannot blog access to Graph APIs, as it is in the very core of Azure AD. However, there are two ways you can limit the users’ access to Graph API Explorers.

Block users’ access to others information

This is quite easy, as you use the same PowerShell command as earlier:

This only removes users’ access to others’ data, so they still can use Graph APIs to query their own data.

Disable Graph API Explorers

As I mentioned earlier, Microsoft has granted access to all Azure AD tenants for Graph API Explorers. Luckily, you can disable them for your tenant.

Start by browsing to Azure Portal as Global Administrator. Then select Azure Active Directory and open Enterprise Applications blade. Now you should see two explorer apps, Graph explorer(Microsoft Graph Explorer) and Graph Explorer (Azure AD Graph Explorer).

Note: Graph explorers will not be shown here unless some user has actually used them.

Azure Active Directory

To disable access, click the first Graph explorer. Open properties and click No next to Enabled for users to sign-in? Click save and repeat the steps with the other Graph explorer.

Properties

Now, if users are trying to access the Graph explorers, they will have an error like this:

Sign in error

Sign in error

About the Author:

Dr Syynimaa works as a CIO of eight cities and municipalities surrounding Tampere, the largest inland city in Nordic countries. He also runs his own consultation business Gerenios. Before moving to his current position, Dr Syynimaa worked as a consultant, trainer, and university lecturer for almost 20 years. He is a regular speaker on Office 365 and Azure security in scientific and professional conferences. Dr Syynimaa holds MCSA (Office 365) and is Microsoft Certified Trainer.

Reference:
Syynimaa, N (2018). Block User Access to Azure AD PowerShell and Graph API Explorer. Available at: http://o365blog.com/post/limit-user-access/ [Accessed 2 November 2018].

Share this on...

Leave a Reply

Back to previous page