Azure Part 3

部分Entra Id 题目:https://redlabs.enterprisesecurity.io/

01

Sensitive Info in User’s Own Properties

默认情况下,Microsoft Entra ID 用户有权读取/查看当前用户个人信息

实验启动后会给出账号和密码,通过portal登录时,会强制设置2FA,不知道为什么 Authenticator: 2FA Client 没法绑定

image-20260323232354946

image-20260323232443909

最后通过powershell,不需要设置2FA

Connect-AzAccount

image-20260323232536380

PS C:\Windows\system32> Get-AzADUser -UserPrincipalName "[email protected]"


AccountEnabled :
AgeGroup :
ApproximateLastSignInDateTime :
BusinessPhone : {}
City :
CompanyName :
ComplianceExpirationDateTime :
ConsentProvidedForMinor :
Country :
CreatedDateTime :
CreationType :
DeletedDateTime :
Department :
DeviceVersion :
DisplayName : AS-AD-230326-acbaf2e59-qfsoib427
EmployeeHireDate :
EmployeeId :
EmployeeOrgData : {
}
EmployeeType :
ExternalUserState :
ExternalUserStateChangeDateTime :
FaxNumber :
GivenName :
Id : 27ab2f98-a66e-4b11-96c8-0dcb77f018c3
Identity :
ImAddress :
IsResourceAccount :
JobTitle :
LastPasswordChangeDateTime :
LegalAgeGroupClassification :
Mail : [email protected]
MailNickname :
Manager : {
}
MobilePhone :
OdataId :
OdataType : #microsoft.graph.user
OfficeLocation :
OnPremisesImmutableId :
OnPremisesLastSyncDateTime :
OnPremisesSyncEnabled :
OperatingSystem :
OperatingSystemVersion :
OtherMail :
PasswordPolicy :
PasswordProfile : {
}
PhysicalId :
PostalCode :
PreferredLanguage :
ProxyAddress :
ResourceGroupName :
ShowInAddressList :
SignInSessionsValidFromDateTime :
State :
StreetAddress :
Surname :
TrustType :
UsageLocation :
UserPrincipalName : [email protected]
UserType :
AdditionalProperties : {[id, 27ab2f98-a66e-4b11-96c8-0dcb77f018c3]}

02

Sensitive Info in Another User’s Properties

默认情况下,Microsoft Entra ID 用户有权读取/查看 其他用户 的个人信息

查询其他用户的Mail属性

Get-AzADUser | ?{$_.Mail -match "@flag.com"}

image-20260325002057079

03

Add Property to Abuse Dynamic Group

动态组(Dynamic Groups)根据用户或设备属性的规则自动管理组成员。如果攻击者能够修改影响动态组规则(Dynamic membership rules)的属性(例如 department、jobTitle 等),则可能触发动态组成员资格的自动更新,从而加入具有更高权限的组并导致权限提升。例如UserA有修改自身属性权限,通过修改部门属性为 运维,就会被动态组自动加到 运维组 ,实现权限提升

portal 查看动态组的规则为:department属性是某个值

image-20260327233032666

默认情况下,Entra ID 用户无法编辑其用户属性,但是当前用户能编辑属性

image-20260327233519551

当前用户就被加入到了动态组中

image-20260327233637765

04

Add Property to Abuse Administrative Unit

管理单元(Administrative Unit,AU)应用场景:大公司可能有多个部门,不同管理员只能管理自己部门的用户。通过 AU,可以使管理员只能管理特定 AU 内的对象

进入portal,有很多管理单元

image-20260328192523250

只能根据题目,修改用户的部门属性,过一会被加入到其中一个管理单元中

image-20260328184138933

05

Abuse Password Administrator Role

查看用户分配的角色为 Password Administrator 作用范围是一个管理单元 ASrnlgubfizx2780118

image-20260328222343333

查看管理单元发现有另外一个用户,就可以重置该用户密码

image-20260328222449714

image-20260328222931390

06

Recover Deleted M365 Group

查看被删除的组,要想恢复该组,需要该组的owner权限或者更高的权限

image-20260328224024074

查询改组的owner,发现查询结果为空,说明软删除状态下该属性已被剥离

Get-MgDirectoryDeletedItemAsGroup -DirectoryObjectId adc329cb-3da3-414a-925e-2195b9e00d5e | Format-List

...
Onenote : Microsoft.Graph.PowerShell.Models.MicrosoftGraphOnenote
Owners :
PermissionGrants :
...

使用题目提供的账号恢复该组

Restore-MgDirectoryDeletedItem -DirectoryObjectId "adc329cb-3da3-414a-925e-2195b9e00d5e"

Id DeletedDateTime
-- ---------------
adc329cb-3da3-414a-925e-2195b9e00d5e

07

Modify Property of Another User to Abuse Dynamic Group

给出的用户具有一个角色 AS-ADCRADLC8,查询该角色有如下权限,可修改用户属性

(Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'AS-ADCRADLC8'").RolePermissions.AllowedResourceActions

microsoft.directory/users/basic/update
microsoft.directory/users/jobInfo/update

对应的scope是一个用户

image-20260328233802448

题目要求将目标用户添加到某个组中,查看该组的 Dynamic membership rules,修改该用户的department即可添加到该组

image-20260328234352162

08

Modify Property of Another User to Abuse Administrative Unit

同07,用户具有角色可以修改用户属性

(Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'AS-ADCRADLC9'").RolePermissions.AllowedResourceActions

microsoft.directory/users/basic/update
microsoft.directory/users/jobInfo/update

查询 指定管理单元的规则

Get-MgDirectoryAdministrativeUnit -AdministrativeUnitId 4c273c69-720e-4a5b-8a25-c61b72970573 | Format-List

DeletedDateTime :
Description : Administrative unit for Azure AD Challenge
DisplayName : AScjzxsdymqw2780068
Extensions :
Id : 4c273c69-720e-4a5b-8a25-c61b72970573
IsMemberManagementRestricted :
Members :
MembershipRule : (user.department -eq "zpmhgelBXwvWydY")
MembershipRuleProcessingState : On
MembershipType : Dynamic
ScopedRoleMembers :
Visibility :
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#directory/administrativeUnits/$entity]}

09

Abuse Dynamic Administrative Unit and Password Administrator Role

05 + 08

10

Abuse Dynamic Membership Rule

查询用户后具有角色,查询角色具有的权限,具有更改动态组规则的权限,修改rule可以将目标用户添加到该动态组中

(Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'AS-ADCRADLC11'").RolePermissions.AllowedResourceActions

microsoft.directory/groups.security/dynamicMembershipRule/update

11

Invite Guest and Add to Dynamic Group

默认情况下,Microsoft Entra ID 用户拥有邀请来宾用户加入其租户的权限。此来宾用户可能已被添加到 Microsoft Entra ID 中的动态组中

查看组的rule,目标名称需要包含 attacker

(user.objectId -eq "6e855f42-9a9c-474a-92f5-2c7c658e557f") or (user.userPrincipalName -contains "attacker")

选择邀请用户

image-20260329121142494

可以发现被邀请的用户类型为 Guest

image-20260329121218742

12

Sensitive Info in Application Notes

查看应用注册中的信息

直接查看应用的信息

image-20260329121657245

13

Abusing Application Restore

查看题目给出用户的角色为,可以创建、删除、恢复拥有的应用注册

AS-ADCRADLC16  Can create, delete and restore owned app registrations.

搜索已删除的应用注册

image-20260329123151508

恢复

Restore-MgDirectoryDeletedItem -DirectoryObjectId e75350f1-727b-4ceb-9350-97ffa75cc0a5

Id DeletedDateTime
-- ---------------
e75350f1-727b-4ceb-9350-97ffa75cc0a5

14

Abuse Application Client Secret

拥有添加应用程序注册新凭据权限的用户,可以添加凭据并以服务主体身份登录

可以对应用注册添加:

  • Client Secrets(密钥)
  • Federated Credential(联合认证)
  • Certificate(证书)

查看拥有的app,可以添加密钥

image-20260329160511257

通过Graph添加密钥

$params = @{ passwordCredential = @{ displayName = "<Password friendly name>" } }
Add-MgApplicationPassword -ApplicationId "<APPLICATION_ID>" -BodyParameter $params

15

Sensitive Info in Application Notes

应用注册的备注存在敏感信息泄露 client secrets,可以登录

image-20260329161549035

16

Abuse Password Administrator Role and Hidden Dynamic Group

Groups中的属性 visibility 用来控制 谁可以看到这个 group、谁可以看到成员

  • Public:任何人都能看到 group 和成员
  • Private:只有成员能看到
  • HiddenMembership:成员列表隐藏