Code Monkey home page Code Monkey logo

aadappaudit's Introduction

Azure AD Application Analytics Solution

Major Refactor of previous solution

  • You can read about some of the use cases in the previous solutions documentation solution

Before using this tool

Read the MIT license

⚠ Only use this tool if you know what you are doing and have reviewed the code

⚠ Always test the tool first in test environments with non-sensitive data

Release notes

Beta v 0.1.0
- Compared to previous version uses now JSON batching and larger resultsize across all queries. 2-3x faster than the previous version
- Release for Azure Security meetup UG

Major performance improvement with JSON batching

List of checks

  1. List app type

  1. Collect appOwners from both objects (when both exist) spn and application

  1. Collect all credential types from both objects (when both exist) spn and application

  1. Review replyUrls for dangling DNS records

  • Please note, in case of multitenant app, these values might be outdated (ReplyURL changes are not reflected visibly on the resulting SPN object, but are nonetheless effective)
  1. Check if the object has been assigned AAD roles

  1. List API permissions in the following format
{ "permissionsReading": [
        "\"AppRole --> api-15764 --> Microsoft Graph - permission: PrivilegedAccess.Read.AzureAD\"",
        "\"AppRole --> api-15764 --> Microsoft Graph - permission: RoleManagement.Read.All\"",
        "\"AppRole --> api-15764 --> Microsoft Graph - permission: PrivilegedAccess.Read.AzureResources\"",
        "\"AppRole --> api-15764 --> Microsoft Graph - permission: PrivilegedAccess.Read.AzureADGroup\"",
        "\"AppRole --> api-15764 --> Office 365 Management APIs - permission: ActivityFeed.Read\"",
        "\"oauth2PermissionGrants --> AllPrincipals --> Microsoft Graph - permission: User.Read\"",
        "\"oauth2PermissionGrants --> AllPrincipals --> Microsoft Graph - permission: Directory.AccessAsUser.All\"",
        "\"oauth2PermissionGrants --> admin santasalo --> Microsoft Graph - permission: User.Read\"",
    ]
  }

Requirements and operation

Access to Azure Cloud Shell (Bash)

  • Permissions to create new storage account or to use existing one.
  • Access to Log Analytics workspace
  • Azure CLI installed (this get tokens from the underlying Azure CLI installation)
Requirement description
✅ Access to Azure Cloud Shell Bash Uses pre-existing software on Azure CLI, Node etc
✅ Permissions to Azure subscription to create needed resources Tool creates a storage account and a resource group. Possible also to use existing storage account. In both scenarios tool generates short lived read-only shared access links (SAS) for the externalData() -operator
✅ User is Azure AD member Cloud-only preferred with read-only Azure AD permissions. More permissions are needed if sign-in events are included
✅ Existing Log Analytics Workspace This is where you paste the output from this tool

About the generated KQL

  • The query is valid for 10 minutes, as SAS tokens are only generated for 10 minutes

Start

git clone https://github.com/jsa2/AADAppAudit

cd AADAppAudit

Use existing storage account

storageAcc=dogs
rg=queryStorage-29991
location=westeurope
az storage account show-connection-string -g $rg  -n  $storageAcc -o json  > src/config.json

Provision new

rnd=$RANDOM
rg=queryStorage-$rnd
location=westeurope
# You can ignore the warning "command substitution: ignored null byte in input"
storageAcc=storage$(head /dev/urandom | tr -dc a-z | head -c10)

echo $storageAcc
# Create Resource Group
az group create -n $rg \
-l $location \
--tags="svc=scan"


# Create storageAcc Account 
az storage account create -n $storageAcc  -g $rg --kind storageV2 -l $location -t Account --sku Standard_LRS

az storage account show-connection-string -g $rg  -n  $storageAcc -o json  > src/config.json
# Creates retention policy
az storage account management-policy create --account-name $storageAcc  -g $rg --policy @retention.json

Operation

If you are running the tool in Azure Cloud Shell then all depedencies are already installed

# in the folder where the solution was installed 
npm install

node main 

# paste the code in runtime.kql to the desired log analytics worspace
# "navigate to kql/runtime.kql if code does not open up


Run the pasted query in the workspace

After running the tool

  • Remove installation of this service (removes the json files that were stored for the query)
  • Delete the resource group (if you provisoned new one) az group delete -n $rg

Contribution

Feel free to open issue or pull requests

aadappaudit's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.