1 of 170

It’s Raining Shells

How to Find New�Attack Primitives in Azure

Permalink to this deck: https://bit.ly/3ItRi6u

2 of 170

Hello!

My name is Andy Robbins

Co-creator of BloodHound

Product Architect of BloodHound Enterprise�I work at @SpecterOps�You can find me at @_wald0

3 of 170

Agenda

Why abuses, not bugs?

Crash Course Through The Basics

Finding New Attack Primitives: MS Graph Case Study

Where to find research ideas

Conclusion

4 of 170

Agenda

Why abuses, not bugs?

Crash Course Through The Basics

Finding New Attack Primitives: MS Graph Case Study

Where to find research ideas

Conclusion

5 of 170

Abuse primitives:

  • Generally enjoy a dramatically longer shelf life

6 of 170

Abuse primitives:

  • Generally enjoy a dramatically longer shelf life
  • Are much cheaper to maintain over time

7 of 170

Abuse primitives:

  • Generally enjoy a dramatically longer shelf life
  • Are much cheaper to maintain over time
  • Exist in almost every instance of a given platform

8 of 170

Abuse primitives:

  • Generally enjoy a dramatically longer shelf life
  • Are much cheaper to maintain over time
  • Exist in almost every instance of a given platform
  • Present a notorious challenge to detection engineers

9 of 170

10 of 170

11 of 170

Agenda

Why Azure abuses?

Crash Course Through The Basics

Finding New Attack Primitives: MS Graph Case Study

Where to find research ideas

Conclusion

12 of 170

What (exactly) is Azure?

Simply put: Azure is Microsoft’s cloud computing product.

Azure is comprised of more than 600 distinct services that cover:

  • Identity
  • Computing
  • Storage
  • Data management
  • Messaging
  • DevOps
  • IoT
  • etc

13 of 170

Securable Object Hierarchy

14 of 170

Azure AD Tenant

15 of 170

Azure AD Tenant

User

Group

Service Principal

Device

App

16 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

App

17 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

App

18 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

App

Management Groups

19 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

20 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

21 of 170

Authentication

22 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

23 of 170

Token issuance

Principal

MS Graph API App Role

MS Graph Resource App

Authenticates via Security Token Service

Scoped To

GrantedRole

value: “AppRoleAssignment.ReadWrite.All”

Azure AD�Directory Service

Brokers To

Specified resource

Securable

Object

Contains

24 of 170

Token issuance

Principal

JWT

Has Token

"aud": "https://graph.microsoft.com"�…�…�“roles”: [� “AppRoleAssignment.ReadWrite.All”�]�…�...

25 of 170

Access Control

26 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Disk

  • AzureAD Admin Roles
  • MS Graph API Permissions
  • AzureAD API Permissions
  • Object-scoped admin roles
  • Explicit Ownership

27 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

Azure Admin Roles ●

Attribute Based Access Control ●

Key/Secret/Cert Rights ●

28 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

29 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

30 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

31 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

32 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Blobs

33 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Disk

34 of 170

Azure AD Tenant

User

Group

Service Principal

Device

Root Management Group

Management Groups

Subscriptions

Resource Groups

App

Management Groups

VM

Key Vault

DB

Disk

35 of 170

Azure AD Tenant

User

Group

Service Principal

Device

App

Root Management Group

Management Groups

Subscriptions

Resource Groups

Management Groups

VM

Key Vault

DB

Blobs

36 of 170

Agenda

Why Azure abuses?

Crash Course Through The Basics

My Abuse Primitive Research Process: MS Graph Case Study

Where to find research ideas

Conclusion

37 of 170

Begin with the end in mind

38 of 170

Begin with the end in mind

Study Intent and Design of the System

39 of 170

Begin with the end in mind

Study Intent and Design of the System

Explore the system using various means

40 of 170

Begin with the end in mind

Study Intent and Design of the System

Explore the system using various means

Catalogue abuse capabilities

41 of 170

Begin with the end in mind

Study Intent and Design of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

42 of 170

Begin with the end in mind

Study Intent and Design of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

43 of 170

Begin with the end in mind

Study Intent and Design of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

44 of 170

I want to understand:

● The fundamental mechanics the system

● How the system interacts with other systems

● How the system can be abused

Begin with the end in mind

45 of 170

I want to understand:

● The fundamental mechanics the system

● How the system interacts with other systems

● How the system can be abused

I want to produce:

● A blog/talk for others to understand and build on

● Example audit and abuse code

● Practical remediation guidance

Begin with the end in mind

46 of 170

I want to understand:

● The fundamental mechanics the system

● How the system interacts with other systems

● How the system can be abused

I want to produce:

● A blog/talk for others to understand and build on

● Example audit and abuse code

● Practical remediation guidance

If appropriate for BloodHound, I want to prepare for:

● The impact on the existing graph model

● How to expand the graph model

● What data to collect and ingest, and how to get that data

Begin with the end in mind

47 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

48 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

49 of 170

Technical

Non-Technical

Official Documentation

Study Intent, Design and Usage of the System

50 of 170

51 of 170

Microsoft MS graph

52 of 170

53 of 170

54 of 170

55 of 170

56 of 170

57 of 170

ms graph permissions

58 of 170

59 of 170

Initial MS Graph Notes

  • MS Graph is some kind of Azure-related service

60 of 170

Initial MS Graph Notes

  • MS Graph is some kind of Azure-related service�
  • It exposes a REST API

61 of 170

Initial MS Graph Notes

  • MS Graph is some kind of Azure-related service�
  • It exposes a REST API�
  • It can let you reset other users’ passwords if you have the right permissions

62 of 170

Initial MS Graph Notes

  • MS Graph is some kind of Azure-related service�
  • It exposes a REST API�
  • It can let you reset other users’ passwords if you have the right permissions�
  • It seems to have a distinct permissions system versus Azure AD and Azure RM

63 of 170

Technical

Non-Technical

Official Documentation

Study Intent, Design and Usage of the System

64 of 170

Technical

Non-Technical

Code Repositories

People

Official Documentation

Blogs

Talks

Study Intent, Design and Usage of the System

65 of 170

site:linkedin.com “Microsoft” “Graph” “Architect”

66 of 170

67 of 170

68 of 170

69 of 170

70 of 170

71 of 170

Technical

Non-Technical

Code Repositories

People

Official Documentation

Blogs

Talks

Study Intent, Design and Usage of the System

72 of 170

Technical

Non-Technical

Code Repositories

Community

People

Official Documentation

Blogs

Talks

Chat & Forums

Repo Issues

Study Intent, Design and Usage of the System

73 of 170

74 of 170

Initial MS Graph Notes

  • MS Graph is some kind of Azure-related service�
  • It exposes a REST API�
  • It can let you reset other users’ passwords if you have the right permissions�
  • It seems to have a distinct permissions system versus Azure AD and Azure RM

75 of 170

Updated MS Graph Notes

  • Microsoft is investing into MS Graph as a sort of “API for APIs”, a unifying endpoint that may eventually allow for indirectly interacting with any object in any service just by interfacing with MS Graph.

76 of 170

Updated MS Graph Notes

  • Microsoft is investing into MS Graph as a sort of “API for APIs”, a unifying endpoint that may eventually allow for indirectly interacting with any object in any service just by interfacing with MS Graph.�
  • MS Graph’s REST API is instantiated into every Azure tenant as a Resource App (aka Enterprise App, aka Service Principal, aka First Party App).

77 of 170

Updated MS Graph Notes

  • Microsoft is investing into MS Graph as a sort of “API for APIs”, a unifying endpoint that may eventually allow for indirectly interacting with any object in any service just by interfacing with MS Graph.�
  • MS Graph’s REST API is instantiated into every Azure tenant as a Resource App (aka Enterprise App, aka Service Principal, aka First Party App).�
  • MS Graph brokers requests to particular Azure services, including privileged action requests like resetting passwords or adding users to security groups.

78 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

79 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

80 of 170

You must go beyond the documentation.

  • These systems are interconnected in undocumented and non-public ways

81 of 170

You must go beyond the documentation.

  • These systems are interconnected in undocumented and non-public ways
  • Documentation often doesn’t keep up with changes

82 of 170

You must go beyond the documentation.

  • These systems are interconnected in undocumented and non-public ways
  • Documentation often doesn’t keep up with changes
  • Tooling based only on documentation is almost always inaccurate, unreliable tooling.

83 of 170

Explore the system using various means

84 of 170

Azure Portal GUI

Explore the system using various means

85 of 170

86 of 170

87 of 170

88 of 170

89 of 170

Azure Portal GUI

MS-authored CLI tools

az binary

AzureAD PowerShell Module

Az PowerShell Module

Explore the system using various means

90 of 170

91 of 170

92 of 170

Azure Portal GUI

MS-authored CLI tools

Our own basic client

Explore the system using various means

93 of 170

Get a token

Get data from the API

Work with the data

94 of 170

The data

Client execution

95 of 170

96 of 170

Token gotchas

  • JWTs facilitate stateless authentication but only partly facilitate stateless authorization
  • But not all authorization is stored in the JWT

97 of 170

Token gotchas

  • JWTs facilitate stateless authentication but only partly facilitate stateless authorization
  • But not all authorization is stored in the JWT

  • AzureAD roles and MS Graph roles are stored in JWTs
  • But these tokens do not include AzureRM role assignments or the various other access control configs

98 of 170

Token gotchas

  • JWTs facilitate stateless authentication but only partly facilitate stateless authorization
  • But not all authorization is stored in the JWT

  • AzureAD roles and MS Graph roles are stored in JWTs
  • But these tokens do not include AzureRM role assignments or the various other access control configs

  • Tl;dr: You can have more privileges than what your JWT states

99 of 170

100 of 170

101 of 170

102 of 170

Audience

103 of 170

Issuer

104 of 170

MS Graph scoped App Roles

105 of 170

AzureAD Roles

106 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

107 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

Create a simple, functional client

108 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

Create a simple, functional client

109 of 170

Enumerate assignable permissions

Catalogue abuse capabilities

110 of 170

111 of 170

112 of 170

113 of 170

Enumerate assignable permissions

Test existing abuses, consider new abuses

Catalogue abuse capabilities

114 of 170

115 of 170

116 of 170

117 of 170

118 of 170

119 of 170

120 of 170

Enumerate assignable permissions

Automate this process

Test existing abuses, consider new abuses

Catalogue abuse capabilities

121 of 170

122 of 170

123 of 170

Example Attack Path

User

App�Registration

Service�Principal

App�Role

App�Role

AAD Directory Role

Owns

Runs As

Granted

Can Grant

Can Grant

Name:�Matt Nelson

Name: MyCoolApp

Name: MyCoolApp

Value:�AppRoleAssignment.ReadWrite.All

Value:�RoleManagement.ReadWrite.Directory

Name:�Global Administrator

124 of 170

125 of 170

126 of 170

Coming soon: Atomic Azure Tests

  • Inspired by Red Canary’s Atomic Red Team
  • But with no dependence on existing PowerShell modules
  • Can be easily expanded to cover other Azure services

  • End result: daily automatic permission->abuse mapping available for anyone to see.

127 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

Create a simple, functional client

Automate collection, audit, and abuse

128 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

Create a simple, functional client

Automate collection, audit, and abuse

129 of 170

Give a Talk

Write a Blog

Share your Code

Share findings

130 of 170

Begin with the end in mind

Study Intent, Design and Usage of the System

Explore the system using various means

Catalogue abuse capabilities

Share findings

My Abuse Primitive Research Process

Establish success criteria for this research

Build foundational, academic knowledge

Create a simple, functional client

Automate collection, audit, and abuse

Write the blog you needed at the start

131 of 170

I want to understand:

● The fundamental mechanics the system

● How the system interacts with other systems

● How the system can be abused

I want to produce:

● A blog/talk for others to understand and build on

● Example audit and abuse code

● Practical remediation guidance

If appropriate for BloodHound, I want to prepare for:

● The impact on the existing graph model

● How to expand the graph model

● What data to collect and ingest, and how to get that data

Begin with the end in mind

132 of 170

I want to understand:

The fundamental mechanics the system

How the system interacts with other systems

How the system can be abused

I want to produce:

A blog/talk for others to understand and build on

Example audit and abuse code

Practical remediation guidance

If appropriate for BloodHound, I want to prepare for:

The impact on the existing graph model

How to expand the graph model

What data to collect and ingest, and how to get that data

Begin with the end in mind

133 of 170

Agenda

Why Azure abuses?

Crash Course Through The Basics

Finding New Attack Primitives: MS Graph Case Study

Where to find research ideas

Conclusion

134 of 170

Build on your existing expertise

Databases

● Azure SQL Database

● Azure Database for PostgreSQL

● Azure Cosmos DB

DevOps / CICD

● Azure Pipelines

● Azure Artifacts

● Azure Repos

Web Apps/Infra

● Azure Web PubSub

● Content Delivery Network

● Azure SignalR Service

See the full (?) directory of services here: https://azure.microsoft.com/en-us/services/

135 of 170

Follow Microsoft Leaders on Twitter

@JefTek - Jef KazimerPrincipal Program Manager - Azure Active Directory�

@BaileyBercick - Bailey BercickProgram Manager - Azure Active Directory Product Group�

@Sue_Bohn - Sue BohnVice President of Program Management in the Identity & Network Access Division�

@Alex_A_Simons - Alex SimonsCorporate Vice President of Program Management, Microsoft Identity Division

136 of 170

Follow These People on Twitter

@mariussmellum - Marius SolbakkenPrincipal - TietoEVRY

@inversecos - Lina LauPrincipal Incident Response Consultant - Secureworks

@DrAzureAD - Dr. Nestori SyynimaaSenior Principal Security Researcher - Secureworks

@asegunlolu - David OkeyodeEMEA Chief Technology Officer, Azure Cloud - Palo Alto Networks

137 of 170

Bookmark these pages

138 of 170

Agenda

Why abuses, not bugs?

Crash Course Through The Basics

Finding New Attack Primitives: MS Graph Case Study

Where to find research ideas

Conclusion

139 of 170

Conclusion

There has never been a better time than right now to get involved in Azure abuse research.

140 of 170

Conclusion

There has never been a better time than right now to get involved in Azure abuse research.

I hope I’ve shown you just how easy (if tedious) it actually is. Happy hunting!

141 of 170

Thank you!

You can find me at @_wald0

142 of 170

Appendix Slides

143 of 170

144 of 170

145 of 170

146 of 170

147 of 170

148 of 170

149 of 170

150 of 170

Review: Catalogue the system’s abuse capabilities

Results:

  • You should understand where the system materially differs from documentation
  • You should now know at least some abuse primitives against the system
  • You should now know what information to collect, and how, to find abusable configurations in the system
  • You should be able to publish your findings for industry colleagues to understand and build on top of

Actions:

  • Determine the scope of objects that can be acted upon through the system
  • For each object type, attempt to “abuse” the object through the system using various privileges
  • Document your findings
  • If possible, automate your abuse tests

151 of 170

152 of 170

153 of 170

154 of 170

155 of 170

156 of 170

157 of 170

158 of 170

159 of 170

160 of 170

161 of 170

162 of 170

163 of 170

164 of 170

165 of 170

166 of 170

Fine-grained control lets you:

  • Determine the minimum parameters actually required by the API
  • Easily change request properties to test for CA bypasses
  • Accurately automate your testing
  • Build future tooling without needing 3rd party modules
  • Discover how the system materially differs from its documentation
  • VASTLY simplify getting data out of the system
  • Get MORE data than what the GUI will ever show you

167 of 170

Principal

MS Graph API App Role

MS Graph Resource App

Scoped To

GrantedRole

value: “AppRoleAssignment.ReadWrite.All”

Brokers To

Specified resource

Securable

Object

Contains

Azure AD�Directory Role

Authenticates To

name: “Cloud App Admin”

GrantedRole

Scoped To

Azure AD�Directory Service

168 of 170

Principal

Token

Has Token

"aud": "https://graph.microsoft.com"�…�“roles”: [� “AppRoleAssignment.ReadWrite.All”�]�…

“wids”: [� “158c047a-c907-4556-b7ef-446551a6b5f7”

]

...

169 of 170

170 of 170

My High Level Methodology:

  1. Begin with the end in mind
  2. Understand the intent and design of the system
  3. Explore the system from different perspectives
  4. Catalogue the system’s abuse capabilities