EntraID授权攻击案例解析&防御指南

admin 2026-03-03 03:48:13 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 文档基于RedCanary研究,解析了EntraID中OAuth授权攻击案例,模拟用户非管理员授权ChatGPT应用获取邮件读取权限。尽管本例为合法应用,但突出了滥用Mail.Read等权限的风险。关键发现需关联Consenttoapplication和Addserviceprincipal日志事件进行调查。建议企业监控OAuth授权行为,验证应用来源与用户意图,以防御恶意应用访问敏感数据。 综合评分: 83 文章分类: 威胁情报,应用安全,云安全,安全运营,漏洞分析


cover_image

Entra ID授权攻击案例解析&防御指南

Dubito Dubito

云原生安全指北

2026年2月26日 08:35 江苏

注:本文翻译自 Red Canary 的文章《ChatGPT in your inbox? Investigating Entra apps that request unexpected permissions》[1],可点击文末“阅读原文”按钮查看英文原文。

全文如下:

一、引言

当 Red Canary 持续观察到 OAuth 应用程序攻击[2]时,我们的威胁研究团队[3]正基于现实世界的攻击手法进行探索,以预判攻击技术的新演进。

以下研究分解了一个在 Entra ID 中假设性的 OAuth 攻击场景,该攻击利用 ChatGPT 最终获取用户电子邮件账户的访问权限。通过应用我们在分析数据源以进行检测时所使用的框架[4],我们将研究可更广泛适用于 OAuth 授权攻击的检测与修复策略。

二、可能发生的情况

在此场景中,发生了以下事件:

在 2025-12-02T20:22:16,于 Entra ID 租户 ID 747930ee-9a33-43c0-9d5d-470b3fb855e7 内,[email protected](ID: 1daac687-c3b3-4aad-8111-4bac9568a064)添加了新的第三方服务主体 ChatGPT(App ID: e0476654-c1d5-430b-ab80-70cbd947616a),并以非管理员身份授权了以下 Microsoft Graph(App ID: 00000003-0000-0000-c000-000000000000)的 OAuth 权限:Mail.Read offline_access profile openid。此操作来自 IP 地址:3.89.177.26

这个 ChatGPT 应用程序确实是合法的 OpenAI 应用程序,之所以被调查,是因为它使用了Mail.Read这个常被滥用的 OAuth 权限之一。最终,此次调查结果为良性分类,但调查步骤与我们在野观察到[2]的一个事件的流程相似。

更高层次地概括,这意味着 ChatGPT 应用有权读取 [email protected] 的邮件。在调查过程中可能会产生以下问题:

  1. 1. [email protected] 身份背后的真实用户是否真的打算使用这个应用程序?用户是否被某种方式胁迫进行了授权?
  2. 2. 该应用是否有权读取此用户的邮件?
  3. 3. ChatGPT 应用是否真的来自 OpenAI,还是仅仅伪装成一个看起来合法的应用程序?
  4. 4. 此应用是否真正被该租户许可?

为了回答这些问题,我们需要数据,具体来说,需要以下 Log Analytics AuditLogs[5] 事件,并通过 CorrelationId 属性进行关联:

  1. 1. OperationName: Consent to application(操作名称:授权应用程序)
  2. 2. OperationName: Add service principal(操作名称:添加服务主体)

以下是为本案例研究生成的实际(已做混淆处理)数据:

{
   "TenantId": "52672484-b4e1-402d-934c-a8e2fd9b05d1",
   "SourceSystem": "Azure AD",
   "TimeGenerated": "2025-12-02T20:22:16.1185371Z",
   "ResourceId": "/tenants/747930ee-9a33-43c0-9d5d-470b3fb855e7/providers/Microsoft.aadiam",
   "OperationName": "Add service principal",
   "OperationVersion": "1.0",
   "Category": "ApplicationManagement",
   "ResultType": "",
   "ResultSignature": "None",
   "ResultDescription": "",
   "DurationMs": "0",
   "CorrelationId": "f540cbd8-9ec4-4d0e-855c-86e8916c3a1b",
   "Resource": "Microsoft.aadiam",
   "ResourceGroup": "Microsoft.aadiam",
   "ResourceProvider": "",
   "Identity": "Azure ESTS Service",
   "Level": "4",
   "Location": "",
   "AdditionalDetails": [
     {
       "key": "User-Agent",
       "value": "EvoSTS"
     },
     {
       "key": "AppId",
       "value": "e0476654-c1d5-430b-ab80-70cbd947616a"
     },
     {
       "key": "AppOwnerOrganizationId",
       "value": "a48cca56-e6da-484e-a814-9c849652bcb3"
     }
   ],
   "Id": "Directory_f540cbd8-9ec4-4d0e-855c-86e8916c3a1b_XC60C_97530478",
   "InitiatedBy": {
     "user": {
       "displayName": "Azure ESTS Service",
       "id": "1daac687-c3b3-4aad-8111-4bac9568a064",
       "userPrincipalName": "[email protected]",
       "ipAddress": "3.89.177.26",
       "roles": []
     }
   },
   "LoggedByService": "Core Directory",
   "Result": "success",
   "ResultReason": "",
   "TargetResources": {
     "id": "07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21",
     "displayName": "ChatGPT",
     "type": "ServicePrincipal",
     "modifiedProperties": [
       {
         "displayName": "AccountEnabled",
         "oldValue": [],
         "newValue": [true]
       },
       {
         "displayName": "AppAddress",
         "oldValue": [],
         "newValue": [
           {
             "AddressType": 0,
             "Address": "http://localhost:5000/hermes/connectors/oauth",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://platform.api.openai.org/hermes/connectors/oauth",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://platform.openai.com/hermes/connectors/oauth",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://tailor.openai.com/api/v1/oauth/callback",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://connectors.api.openai.com/connector/oauth_callback/ios_relay",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://chatgpt.com/ccc/o365connector-business-dac4c231-bc0f-4d07-8b4c-3e1f3ee122ae/oauth/callback",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://chatgpt.com/ccc/o365connector-personal-b9ce8873-ed1f-405d-97b4-51ca6b2a4f3f/oauth/callback",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           },
           {
             "AddressType": 0,
             "Address": "https://chatgpt.com/connector_platform_oauth_redirect",
             "ReplyAddressClientType": 1,
             "ReplyAddressIndex": null,
             "IsReplyAddressDefault": false
           }
         ]
       },
       {
         "displayName": "AppPrincipalId",
         "oldValue": [],
         "newValue": ["e0476654-c1d5-430b-ab80-70cbd947616a"]
       },
       {
         "displayName": "DisplayName",
         "oldValue": [],
         "newValue": ["ChatGPT"]
       },
       {
         "displayName": "ServicePrincipalName",
         "oldValue": [],
         "newValue": ["e0476654-c1d5-430b-ab80-70cbd947616a","api://e0476654-c1d5-430b-ab80-70cbd947616a"]
       },
       {
         "displayName": "Credential",
         "oldValue": [],
         "newValue": [{
           "CredentialType": 2,
           "KeyStoreId": "291154f0-a9f5-45bb-87be-9c8ee5b6d62c",
           "KeyGroupId": "291154f0-a9f5-45bb-87be-9c8ee5b6d62c"
         }]
       },
       {
         "displayName": "ServicePrincipalTag",
         "oldValue": [],
         "newValue": ["WindowsAzureActiveDirectoryIntegratedApp","apiConsumer","webApp"]
       },
       {
         "displayName": "Included Updated Properties",
         "oldValue": null,
         "newValue": "AccountEnabled, AppAddress, AppPrincipalId, DisplayName, ServicePrincipalName, Credential, ServicePrincipalTag"
       },
       {
         "displayName": "TargetId.ServicePrincipalNames",
         "oldValue": null,
         "newValue": "e0476654-c1d5-430b-ab80-70cbd947616a;api://e0476654-c1d5-430b-ab80-70cbd947616a"
       }
     ],
     "administrativeUnits": []
   },
   "AADTenantId": "747930ee-9a33-43c0-9d5d-470b3fb855e7",
   "ActivityDisplayName": "Add service principal",
   "ActivityDateTime": "2025-12-02T20:22:16.1185371Z",
   "AADOperationType": "Add",
   "Type": "AuditLogs"
 },
 {
   "TenantId": "52672484-b4e1-402d-934c-a8e2fd9b05d1",
   "SourceSystem": "Azure AD",
   "TimeGenerated": "2025-12-02T20:22:16.2365366Z",
   "ResourceId": "/tenants/747930ee-9a33-43c0-9d5d-470b3fb855e7/providers/Microsoft.aadiam",
   "OperationName": "Consent to application",
   "OperationVersion": "1.0",
   "Category": "ApplicationManagement",
   "ResultType": "",
   "ResultSignature": "None",
   "ResultDescription": "",
   "DurationMs": "0",
   "CorrelationId": "f540cbd8-9ec4-4d0e-855c-86e8916c3a1b",
   "Resource": "Microsoft.aadiam",
   "ResourceGroup": "Microsoft.aadiam",
   "ResourceProvider": "",
   "Identity": "Azure ESTS Service",
   "Level": "4",
   "Location": "",
   "AdditionalDetails": [
     {
       "key": "User-Agent",
       "value": "EvoSTS"
     },
     {
       "key": "AppId",
       "value": "e0476654-c1d5-430b-ab80-70cbd947616a"
     },
     {
       "key": "AppOwnerOrganizationId",
       "value": "a48cca56-e6da-484e-a814-9c849652bcb3"
     }
   ],
   "Id": "Directory_f540cbd8-9ec4-4d0e-855c-86e8916c3a1b_XC60C_97530533",
   "InitiatedBy": {
     "user": {
       "displayName": "Azure ESTS Service",
       "id": "1daac687-c3b3-4aad-8111-4bac9568a064",
       "userPrincipalName": "[email protected]",
       "ipAddress": "3.89.177.26",
       "roles": []
     }
   },
   "LoggedByService": "Core Directory",
   "Result": "success",
   "ResultReason": "",
   "TargetResources": {
     "id": "07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21",
     "displayName": "ChatGPT",
     "type": "ServicePrincipal",
     "modifiedProperties": [
       {
         "displayName": "ConsentContext.IsAdminConsent",
         "oldValue": null,
         "newValue": "False"
       },
       {
         "displayName": "ConsentContext.IsAppOnly",
         "oldValue": null,
         "newValue": "False"
       },
       {
         "displayName": "ConsentContext.OnBehalfOfAll",
         "oldValue": null,
         "newValue": "False"
       },
       {
         "displayName": "ConsentContext.Tags",
         "oldValue": null,
         "newValue": "WindowsAzureActiveDirectoryIntegratedApp"
       },
       {
         "displayName": "ConsentAction.Permissions",
         "oldValue": null,
         "newValue": "[] => [[Id: FkzsB8Qs10y245WpugB6IUdjEXl8YehProtQM5deXYiHxqods8OtSoERS6yVaKBk, ClientId: 07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21, PrincipalId: 1daac687-c3b3-4aad-8111-4bac9568a064, ResourceId: 79116347-617c-4fe8-ae8b-5033975e5d88, ConsentType: Principal, Scope:  Mail.Read offline_access profile openid, CreatedDateTime: , LastModifiedDateTime ]]; "
       },
       {
         "displayName": "TargetId.ServicePrincipalNames",
         "oldValue": null,
         "newValue": "e0476654-c1d5-430b-ab80-70cbd947616a;api://e0476654-c1d5-430b-ab80-70cbd947616a"
       }
     ],
     "administrativeUnits": []
   },
   "AADTenantId": "747930ee-9a33-43c0-9d5d-470b3fb855e7",
   "ActivityDisplayName": "Consent to application",
   "ActivityDateTime": "2025-12-02T20:22:16.2365366Z",
   "AADOperationType": "Assign",
   "Type": "AuditLogs"
 }

2.1 谁(Who)

此部分对应于执行操作的主体。

[email protected] (ID: 1daac687-c3b3-4aad-8111-4bac9568a064)

2.1.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Consent to application | InitiatedBy.user.userPrincipalName | [email protected] | 该身份的人类可读名称 | | Consent to application | InitiatedBy.user.id | 1daac687-c3b3-4aad-8111-4bac9568a064 | 该身份的对象 ID,是身份的唯一标识符 |

2.2 什么(What)

此部分对应于受影响的资源以及对其执行操作的具体细节。

“成功添加了新的第三方服务主体 ChatGPT(App ID: e0476654-c1d5-430b-ab80-70cbd947616a),并以非管理员身份授权了以下 OAuth 权限:Mail.Read offline_access profile openid。”

2.2.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Add service principal | Result | “successfully” | 当 Result 为 “success” 时,表示服务主体已成功添加到租户。 | | Add service principal | OperationName | “added a new … service principal” | 这表明服务主体是新引入到该租户的。 | | Add service principal | AdditionalDetails['AppOwnerOrganizationId'] 和 AADTenantId | “third-party” | 这不是内部开发的应用,因为如果是的话 AdditionalDetails['AppOwnerOrganizationId'] 的值应该与 AADTenantId 相同。它也不是 第一方 Microsoft 应用[6],因为 AdditionalDetails['AppOwnerOrganizationId'] 既不是 f8cdef31-a31e-4b4a-93e4-5f571e91255a 也不是 72f988bf-86f1-41af-91ab-2d7cd011db47。由于既不是内部应用也不是第一方应用,可以断定它是一个第三方应用程序。 | | Consent to application | TargetResources[0].displayName | ChatGPT | 服务主体的名称 | | Consent to application | AdditionalDetails['AppId'] | e0476654-c1d5-430b-ab80-70cbd947616a | 应用程序的全局唯一标识符 | | Consent to application | OperationName | “consented … to … OAuth permissions” | 表明已授权 OAuth 权限 | | Consent to application | TargetResources[0].modifiedProperties['ConsentContext.IsAdminConsent'].newValue | “non-admin” | 当 TargetResources[0].modifiedProperties['ConsentContext.IsAdminConsent'].newValue 为 “False” 时,表示为非管理员授权。 | | Consent to application | TargetResources[0].modifiedProperties['ConsentAction.Permissions'].newValue | “Mail.Read offline_access profile openid” | 此属性代表一个 oAuth2PermissionGrant[7] 实例,指明了被授权的具体 OAuth 权限。 |

2.2.2 解读 ConsentAction.Permissions 的值

请参考上文中的示例:

[] => [[Id: FkzsB8Qs10y245WpugB6IUdjEXl8YehProtQM5deXYiHxqods8OtSoERS6yVaKBk, ClientId: 07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21, PrincipalId: 1daac687-c3b3-4aad-8111-4bac9568a064, ResourceId: 79116347-617c-4fe8-ae8b-5033975e5d88, ConsentType: Principal, Scope:  Mail.Read offline_access profile openid, CreatedDateTime: , LastModifiedDateTime ]];

此数据的结构并未被 Microsoft 文档记录,但很明显它包含一个由单个或多个 oAuth2PermissionGrant[7] 实例组成的数组。其最基本的形式具有以下结构:

[[PREVIOUS_OAUTH2PERMISSIONGRANT_1],[PREVIOUS_OAUTH2PERMISSIONGRANT_2]] => [[NEW_OAUTH2PERMISSIONGRANT_1],[NEW_OAUTH2PERMISSIONGRANT_2]];

上述 oAuth2PermissionGrant 实例的分解如下:

  • • IdFkzsB8Qs10y245WpugB6IUdjEXl8YehProtQM5deXYiHxqods8OtSoERS6yVaKBk

  • • 这是 OAuth 权限授予的唯一标识符。该值对于执行有针对性的修复操作是必需的。该值由 ClientIdResourceId 和 PrincipalId 的值(按此顺序)组合而成,然后进行 Base-64 编码。更多详情请参见下文修复部分。

  • • ClientId07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21

  • • 这是应用了权限授予的服务主体实例的对象 ID(非应用程序 ID)。

  • • PrincipalId1daac687-c3b3-4aad-8111-4bac9568a064

  • • 这是权限授予所应用到的身份的对象 ID。当 ConsentType 为 AllPrincipals 时,此字段为空。

  • • ResourceId79116347-617c-4fe8-ae8b-5033975e5d88

  • • 这是实现了所请求范围(Scope)的资源应用的对象 ID(非应用程序 ID)。在大多数情况下,这将对应于 Microsoft Graph[8] 资源应用。

  • • ConsentTypePrincipal

  • • 当此值为 Principal 时,表示授予的权限仅适用于由 PrincipalId 指定的身份。当此值为 AllPrincipals 时,表示这些范围已授予给所有用户。

  • • Scope:  Mail.Read offline_access profile openid

  • • 这是一个以空格分隔的列表,列出了被授予的 OAuth 权限。

  • • CreatedDateTime:

  • • 从未观察到此字段有值。

  • • LastModifiedDateTime

  • • 从未观察到此字段有值。

在上述示例中,权限字符串以 [] => 开头,表示这是一个新的 OAuth 权限授予。

注意:权限字符串可能包含多个 oAuth2PermissionGrant 实例。在这种情况下,ResourceId 的值将是唯一的,因为它将包含在该特定资源应用中实现的一组 Scope 值。

2.3 何时(When)

此部分对应于操作发生的时间。

“At 2025-12-02T20:22:16”

2.3.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Consent to application | ActivityDateTime | 2025-12-02T20:22:16.2365366Z | 此事件发生的日期和时间。 |

2.4 何地(Where)

此部分对应于操作发生的环境。

“在 Entra ID 租户 ID 747930ee-9a33-43c0-9d5d-470b3fb855e7内”

2.4.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Consent to application | AADTenantId | 747930ee-9a33-43c0-9d5d-470b3fb855e7 | 操作发生的租户。 |

2.5 来源(Whence)

操作源自何处?

“操作从以下地址执行:3.89.177.26。”

2.5.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Consent to application | InitiatedBy.user.ipAddress | 3.89.177.26 | 执行操作的主体所使用的 IP 地址。 |

2.6 如何(How)

此部分对应于操作发生的方式。

2.6.1 字段来源

| 操作(Operation) | 字段(Field) | 值(Value) | 描述(Description) | | — | — | — | — | | Consent to application | AdditionalDetails['User-Agent'] | EvoSTS | 执行操作的用户代理(User-Agent)。EvoSTS 表示此次授权是通过典型的图形界面授权提示完成的。 |

三、检测

您可能采用的检测策略取决于您如何界定该技术的范围以及您的具体检测目标。

3.1 技术范围

  • • 您是否关注非管理员用户被钓鱼,从而授权给违反策略或恶意的未批准(unsanctioned)应用程序?
  • • 您是否关注管理员被作为目标,从而授予了高权限的 OAuth 范围?
  • • 您是否关注已入侵身份的攻击者创建内部应用程序,然后将该应用程序用于钓鱼活动?

3.2 检测目标

  • • 是检测恶意应用程序,还是检测未批准的应用程序?
  • • 您对检测量的容忍度是多少?
  • • 您对误报的容忍度是多少?
  • • 您是否有能力执行应用程序富化并评估其普遍性?

范围与目标的每种组合都将决定具体的检测策略。作为一个良好的起点,我们推荐以下能够最小化检测量的检测策略。

检测新第三方应用程序的非管理员权限授予,且该应用程序被授予了一个或多个常被滥用的权限。

该策略可以分解如下:

  1. 1. 我们假设非管理员用户更有可能成为攻击目标,并且由于技术知识较少,他们更有可能无法识别可疑的授权请求。
  2. 2. 该应用程序在租户中尚不存在。已经存在于租户中的应用程序更有可能是被批准的。
  3. 3. 恶意、由攻击者控制的应用程序不会是第一方 Microsoft 应用程序。通过排除内部应用和第一方应用,我们可以大幅减少检测量。
  4. 4. 截至本文撰写时,Microsoft 的默认应用授权策略会阻止非管理员授权以下已知常被滥用的权限: Calendars.ReadCalendars.Read.SharedCalendars.ReadBasicCalendars.ReadWriteCalendars.ReadWrite.SharedChat.ReadChat.ReadWriteFiles.Read.AllFiles.ReadWrite.AllMail.ReadMail.Read.SharedMail.ReadBasicMail.ReadBasic.SharedMail.ReadWriteMail.ReadWrite.SharedMailboxFolder.ReadMailboxFolder.ReadWriteMailboxItem.ReadMailboxSettings.ReadMailboxSettings.ReadWriteOnlineMeetings.ReadOnlineMeetings.ReadWriteSites.Read.AllSites.ReadWrite.All

此检测策略可以使用以下伪逻辑实现:

| 操作(Operation) | 字段(Field) | 条件(Condition) | 值(Value) | 描述(Description) | | — | — | — | — | — | | Consent to application | TargetResources[0].modifiedProperties``['ConsentAction.Permissions'].newValue | 开头为(Starts with) | [] => | 这是该用户的新授权。 | | Consent to application | TargetResources[0].modifiedProperties``['ConsentAction.Permissions'].newValue | 包含以下一个或多个(Contains one or more of the following) | 请参阅上方高风险范围列表,例如 Mail.Read | 一个或多个已知常被滥用但非高权限的权限。 | | Consent to application | TargetResources[0].modifiedProperties``['ConsentContext.IsAdminConsent'].newValue | 等于(Equals) | False | 发生了非管理员授权。 | | Consent to application AND Add service principal | CorrelationId | 等于(Equals) | 两个事件的 CorrelationId 值相同 | 用户授权了一个尚未存在于租户中的应用程序。 | | Add service principal | AdditionalDetails['AppOwnerOrganizationId'] AND AADTenantId | 不等于(Does not equal) | 既不是 AADTenantId,也不是 f8cdef31-a31e-4b4a-93e4-5f571e91255a,也不是 72f988bf-86f1-41af-91ab-2d7cd011db47 | 添加的服务主体既不是内部应用也不是第一方应用,因此是第三方应用程序。 |

四、修复

如果已确定某个 OAuth 授权授予是恶意的,可以执行以下即时操作:

4.1 移除授权授予

使用 Consent to application 事件中 TargetResources[0].modifiedProperties['ConsentAction.Permissions'].newValue 字段内的权限授予 ID 值,可以执行以下 Microsoft Graph 命令:

Remove-MgBetaOAuth2PermissionGrant -OAuth2PermissionGrantId FkzsB8Qs10y245WpugB6IUdjEXl8YehProtQM5deXYiHxqods8OtSoERS6yVaKBk

4.2 移除添加到租户的服务主体

如果已添加到租户的应用被判定为恶意或未获批准,可以使用 Consent to application 事件中 TargetResources[0].id 字段内的服务主体 ID 将其移除。在上述示例中,此值为 07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21。以下是一个示例 PowerShell Graph 命令,用于移除该服务主体:

Remove-MgServicePrincipal -ServicePrincipalId 07ec4c16-2cc4-4cd7-b6e3-95a9ba007a21

五、缓解措施

幸运的是,Microsoft 提供了多种机会来缓解这种技术。如前所述,这种技术依赖于受害者拥有执行以下两个操作的权限:

  1. 1. 向租户添加服务主体。
  2. 2. 授权该身份被允许授予的 OAuth 权限。

正如 Microsoft 所述[9],“默认情况下,所有用户都可以授予应用程序的权限(在该权限无需管理员同意的前提下)。例如,默认情况下,用户可以授权应用访问其自己的邮箱,但不能授权应用无限制地读取和写入您组织中的所有文件。”

Microsoft 提供了三种选项[10]来缓解非管理员用户引入未经审查的应用程序和过度授予 OAuth 权限的风险:

  1. 1. 默认最安全,但会增加管理负担: “不允许用户授权(Do not allow user consent)”。此选项需要管理员(即全局管理员或特权角色管理员)批准所有授权请求。
  2. 2. 平衡安全性并减轻管理负担,同时授予用户为“高信任度”应用授权预批准的 OAuth 权限的能力: “对于所选权限,允许用户授权已验证发布者的应用。所有用户可以为权限被归类为‘低影响’的、来自已验证发布者或在本组织中注册的应用进行授权。”
  3. 3. Microsoft 推荐的用于平衡安全性和灵活性的选项: “让 Microsoft 管理您的授权设置。自动将您的组织更新为 Microsoft 当前的用户授权指南。”

参考资料

  • • 配置用户如何授权应用程序[9]
  • • 管理应用授权策略[11]
  • • 检测和修复非法授权[12]
  • • 受损和恶意应用程序调查[13]

引用链接

[1] 《ChatGPT in your inbox? Investigating Entra apps that request unexpected permissions》: https://redcanary.com/blog/threat-detection/entra-id-oauth-attacks/ [2] OAuth 应用程序攻击: https://redcanary.com/blog/threat-detection/oauth-app-attacks/ [3] 威胁研究团队: https://redcanary.com/blog/threat-detection/threat-research-questions/ [4] 我们在分析数据源以进行检测时所使用的框架: https://redcanary.com/blog/threat-detection/detection-engineering-storytelling/ [5] AuditLogs: https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/auditlogs [6] 第一方 Microsoft 应用: https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#verify-a-first-party-microsoft-service-principal-in-your-microsoft-entra-tenant [7] oAuth2PermissionGrant: https://learn.microsoft.com/en-us/graph/api/resources/oauth2permissiongrant [8] Microsoft Graph: https://learn.microsoft.com/en-us/graph/overview [9] Microsoft 所述: https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/configure-user-consent [10] 三种选项: https://portal.azure.com/#view/Microsoft_AAD_IAM/ConsentPoliciesMenuBlade/~/UserSettings [11] 管理应用授权策略: https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-app-consent-policies [12] 检测和修复非法授权: https://learn.microsoft.com/en-us/defender-office-365/detect-and-remediate-illicit-consent-grants [13] 受损和恶意应用程序调查: https://learn.microsoft.com/en-us/security/operations/incident-response-playbook-compromised-malicious-app

交流群


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:云原生安全指北 Dubito Dubito《Entra ID授权攻击案例解析&防御指南》

评论:0   参与:  0