App Services are a service offered by Azure for easily building and running web applications and APIs. It is getting increasingly popular as it allows you to integrate capabilities like load balancing, autoscaling, or Continuous Development / Continuous Integration (CI/CD) in an easy fashion.
With Azure and other cloud platforms, the main risk is that developers are building applications without understanding how to secure them. We will see in the next section that Microsoft provides great recommendations and guidelines on how to secure these App Services, but as often, the problem is that these settings are not enabled by default. If your developers are unaware of these guidelines and best practices, they may make sensitive data available to anyone on the internet.
This article provides knowledge of App Services that you host in your tenant or subscriptions, which can be accessed by anyone on the Internet. So, let’s dig into what you need to know about App Services in terms of security, and how to discover if your developers are well-versed in terms of best practices.
In their online documentation, Microsoft defines a total of 19 recommendations classified into five categories (General, Identity and access management, Data protection, Networking, and Monitoring). In the context of this work, two recommendations are particularly important for restricting access to anyone on the internet:
So how can we translate these two recommendations into something we can query using the Azure API? Well, let’s see how the Azure Resource Graph Explorer can help us here.
If you have never heard of the Resource Graph Explorer in Azure, now is the time to try it out! Resource Graph Explorer is a service in Azure that gives you the ability to query resources’ configuration, using the Kusto Query Language, and gives back results in seconds.
As Microsoft explains in their documentation, you will need read access to the resources you want to query for the Resource Graph Explorer to return meaningful results.
So, let’s build a query to get all running web applications of type 'microsoft.web/sites':
Figure 3: Resource Graph Explorer query to get all existing web applications
Resource Graph Explorer has found a total of 848 web applications in our tenant in under 6 seconds of work. Now let’s clean up this query and filter out Function Apps as we don’t want to tackle these for now. On top of that, let’s focus on running applications, with their public network access property not being disabled (so enabled):
Figure 4: Example of our Resource Graph Explorer query with the associated results
We have found a total of 515 App Services that don’t have any network restrictions configured.
The other filter we want to add now is to check if requests must be authenticated. The resources table we just used doesn’t seem to contain this piece of information though. Authentication settings can only be queried in the table appserviceresources. Thanks to KQL capabilities, this can be achieved using a join statement as shown below.
We now have a total of 493 App Services that don’t have any network restrictions and any authentication settings configured. These 493 App Services are therefore supposedly accessible from anyone on the internet. It is however possible that:
So, how can we validate even further this list of supposedly accessible App Services? Well, now that we have a reduced list, let’s build a quick Powershell script to check these out automatically. Without doing anything too fancy, the script would:
The final script can be found here, but below is a snippet of its output. The list of domains and the associated result is given in a CSV format so that it can easily be copy/pasted in an Excel sheet later.
In the end, we have reduced our list of 848 existing web applications in Azure to 493 App Services supposedly available using appropriate filters. Scripting this query then has allowed us to automatically identify which ones have additional controls implemented in the application itself and has highlighted a total of 98 verified accessible App Services.
Now, what to do with these results? The exact answer will depend on these, your organization, and your role in this one. But without being too specific, here is some food for thought:
Also, be sure to check out our Mirai Security services if you are interested in the security services we are doing at Mirai and especially what we are doing to help secure your cloud.