yuj1osm's tech blog

クラウド、セキュリティ、AIなど

Microsoft Entra IDとMicrosoft Graph APIによるログ調査 ③Microsoft Entra ID Protection編

3編にわたって「Microsoft Entra IDとMicrosoft Graph APIによるログ調査」について紹介しています。

前回の「②サインイン&監査編」では、スマートロックアウトやSSPRのログを発生させて、Entra ID管理センターやMicrosoft Graph APIでどのようなログが記録されるのかを確認しました。
今回の「③Microsoft Entra ID Protection編」では、意図的にリスクのある挙動を発生させ、Microsoft Entra ID Protectionで検出したログを確認する方法について紹介します。

事前準備

①Microsoft Graph API基礎編」で、各種セキュリティ設定とGraph APIの設定が完了していることが前提です。

今回は以下1ユーザを使用します。

名前 アカウント 用途
ユーザ04 user01@xxx.onmicrosoft.com Microsoft Entra ID Protection

まずは、トークンを取得します。

APIドキュメント learn.microsoft.com

リクエス

curl -X POST https://login.microsoftonline.com/[テナントID]/oauth2/v2.0/token -H "Host: login.microsoftonline.com" -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=[クライアントID]" -d "scope=https%3A%2F%2Fgraph.microsoft.com/.default" -d "client_secret=[クライアントシークレット値]" -d "grant_type=client_credentials" 

レスポンス

{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"[トークン]"}

access_tokenにTTL1時間のトークンが入っているため、このトークン使って各種ログを取得します。

Microsoft Entra ID Protectionログの取得

Microsoft Entra ID Protectionは、機械学習によるサインインのリスクや通常とは異なるユーザーの行動を特定し、アクセスをブロック、認証情報を要求、アクセスを制限することができます。
Entra IDのライセンス種別により、閲覧できる情報が制限されます。
本機能をフルに活用するには、Microsoft Entra ID P2ライセンスを利用することが推奨されます。

learn.microsoft.com

条件

Microsoft Entra ID Protectionでリスクを検出させます。
意図的にリスクを検出させる方法がドキュメントに掲載されています。

learn.microsoft.com

今回は、user04でTor Browserを使って認証試行を行います。

複数回認証失敗したのち、成功させます。
すると、セキュリティ機能によりアクセスがブロックされます。

結果(サインイン)

Entra管理センター

Entra管理センターでサインインログを確認すると、失敗が繰り返されていることが分かります。

Graph API

APIドキュメント learn.microsoft.com

リクエス

curl -H "Authorization: Bearer [トークン]" https://graph.microsoft.com/v1.0/auditLogs/signIns?$filter=createdDateTime%20ge%202025-03-17T17:30:00Z%20and%20createdDateTime%20lt%202025-03-17T17:55:00Z

レスポンス

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#auditLogs/signIns",
    "value": [
        {
            "id": "xxxxx",
            "createdDateTime": "2025-03-17T17:54:30Z",
            "userDisplayName": "ユーザ04",
            "userPrincipalName": "user04@xxx.onmicrosoft.com",
            "userId": "xxxxx",
            "appId": "xxxxx",
            "appDisplayName": "OfficeHome",
            "ipAddress": "xx.xx.xx.xx",
            "clientAppUsed": "Browser",
            "correlationId": "xxxxx",
            "conditionalAccessStatus": "notApplied",
            "isInteractive": true,
            "riskDetail": "none",
            "riskLevelAggregated": "low",
            "riskLevelDuringSignIn": "medium",
            "riskState": "atRisk",
            "riskEventTypes": [
                "anonymizedIPAddress"
            ],
            "riskEventTypes_v2": [
                "anonymizedIPAddress"
            ],
            "resourceDisplayName": "OfficeHome",
            "resourceId": "4xxxxx",
            "status": {
                "errorCode": 530035,
                "failureReason": "Access has been blocked by security defaults.",
                "additionalDetails": "If this is unexpected, see security defaults that applied to this request in the Azure Portal."
            },
            "deviceDetail": {
                "deviceId": "",
                "displayName": "",
                "operatingSystem": "Windows10",
                "browser": "Firefox 128.0",
                "isCompliant": false,
                "isManaged": false,
                "trustType": ""
            },
            "location": {
                "city": "",
                "state": "",
                "countryOrRegion": "NL",
                "geoCoordinates": {
                    "altitude": null,
                    "latitude": xx.x,
                    "longitude": xx.x
                }
            },
            "appliedConditionalAccessPolicies": []
        },
  {
            "id": "xxxxx",
            "createdDateTime": "2025-03-17T15:08:07Z",
            "userDisplayName": "ユーザ01",
            "userPrincipalName": "user01@xxx.onmicrosoft.com",

   (省略)

            "appliedConditionalAccessPolicies": []
        }
    ]
}

結果(危険なユーザー)

Entra管理センター

「保護」→「ID保護」でEntra ID Protectionにアクセスします。

「レポート」→「危険なユーザー」を確認します。
ユーザ04が危険なユーザーとして記録されています。

エントリをクリックすると詳細を確認できます。

「最近の危険なサインイン」タブでは、アラートの発端となったサインインログが確認できます。

「リスクの履歴」タブでは、このあと確認する「リスクの検出」が確認できます。
今回は匿名IPアドレスからの認証試行が、危険なアクティビティとして検出されています。

Graph API

APIドキュメント learn.microsoft.com

リクエス

curl -H "Authorization: Bearer [トークン]" https://graph.microsoft.com/v1.0/identityProtection/riskyUsers?$filter=riskLastUpdatedDateTime%20ge%202025-03-17T17:30:00Z%20and%20riskLastUpdatedDateTime%20lt%202025-03-17T18:00:00Z

レスポンス

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identityProtection/riskyUsers",
  "value":
    [
      {
        "id": "xxxxx",
        "isDeleted": false,
        "isProcessing": false,
        "riskLevel": "low",
        "riskState": "atRisk",
        "riskDetail": "none",
        "riskLastUpdatedDateTime": "2025-03-17T17:56:42.6728408Z",
        "userDisplayName": "ユーザ04",
        "userPrincipalName": "user04@xxx.onmicrosoft.com",
      },
    ],
}

結果(危険なサインイン)

Entra管理センター

「レポート」→「危険なサインイン」を確認します。
先ほど「危険なユーザー」で確認した、発端となったサインインログが記録されています。

エントリから詳細を確認できます。

「危険な情報」タブでは、危険と判定された理由が確認できます。
今回は匿名IPアドレスからの認証試行が危険と判定されています。

Graph API

ログの取得方法と確認できる項目は、先ほどのサインインログと同じため省略します。

結果(リスク検出)

Entra管理センター

「レポート」→「リスク検出」を確認します。
先ほど「危険なサインイン」で確認した、各サインログの危険と判定された詳細な理由が記録されています。

エントリから詳細を確認すると、検出の種類が「匿名IPアドレス」、攻撃の種類が「プロキシを使用した難読化/アクセス,有効なアカウントを使用したアクセス (オフライン検出)」と判定されていることが分かります。

Graph API

APIドキュメント learn.microsoft.com

リクエス

curl -H "Authorization: Bearer [トークン]" https://graph.microsoft.com/v1.0/identityProtection/riskDetections?$filter=detectedDateTime%20ge%202025-03-17T17:30:00Z%20and%20detectedDateTime%20lt%202025-03-17T17:55:00Z

レスポンス

  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identityProtection/riskDetections",
  "value": [
    {
      "id": "xxxxx",
      "requestId": "xxxxx",
      "correlationId": "xxxxx",
      "riskEventType": "anonymizedIPAddress",
      "riskState": "atRisk",
      "riskLevel": "medium",
      "riskDetail": "none",
      "source": "IdentityProtection",
      "detectionTimingType": "realtime",
      "activity": "signin",
      "tokenIssuerType": "AzureAD",
      "ipAddress": "xx.xx.xx.xx",
      "activityDateTime": "2025-03-17T17:54:30.6982628Z",
      "detectedDateTime": "2025-03-17T17:54:30.6982628Z",
      "lastUpdatedDateTime": "2025-03-17T17:56:29.6611202Z",
      "userId": "xx.xx.xx.xx",
      "userDisplayName": "ユーザ04",
      "userPrincipalName": "user04@xxx.onmicrosoft.com",
      "additionalInfo": "[{\"Key\":\"userAgent\",\"Value\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0\"},{\"Key\":\"mitreTechniques\",\"Value\":\"T1090.003,T1078\"}]",
      "location": {
        "city": "",
        "state": "",
        "countryOrRegion": "NL",
        "geoCoordinates": {
          "latitude": xx.x,
          "longitude": x.xx
        }
      }
    },
    {
      "id": "xxxxx",
      "requestId": "xxxxx",
      "correlationId": "xxxxx",
      "riskEventType": "anonymizedIPAddress",
      "riskState": "atRisk",
      "riskLevel": "medium",
      "riskDetail": "none",

  (省略)

       "location": {
        "city": "",
        "state": "",
        "countryOrRegion": "NL",
        "geoCoordinates": {
          "latitude": xx.x,
          "longitude": x.xx
        }
      }
    }
  ]
}

まとめ

今回の「③Microsoft Entra ID Protection編」では、意図的にリスクのある挙動を発生させ、Microsoft Entra ID Protectionでどのように検出され、どのような情報が得られるかを確認しました。

クラウド技術の発達やテレワークの普及に、これまで以上にユーザのアクセス管理やセキュリティ対策が重視されています。
企業においては、可能な限りMicrosoft Entra ID Protectionを活用することを推奨します。

3編にわたって、「Microsoft Entra IDとMicrosoft Graph APIによるログ調査」について紹介してきました。
Microsoft Entra IDで利用できるセキュリティ機能やログの見方、Microsoft Graph APIによるログ取得の方法など、事前に知っておくことでログ調査やログ活用がはかどります。
今回ご紹介した知見がセキュリティやガバナンスへの対応の一助になれば幸いです。

Microsoft Entra IDとMicrosoft Graph APIによるログ調査」シリーズ全編はこちら

  1. Microsoft Graph API基礎編
  2. サインイン&監査編
  3. Microsoft Entra ID Protection編