Back to Wazuh

Microsoft Graph Security API

docs/ref/modules/integrations/microsoft-graph.md

4.14.44.7 KB
Original Source

Microsoft Graph Security API

Introduction

The Wazuh Microsoft Graph module retrieves security alerts and events from the Microsoft Graph Security API. This provides access to security data from multiple Microsoft security products, including Microsoft Defender for Endpoint, Microsoft Defender for Identity, Microsoft Defender for Cloud Apps, and Azure AD Identity Protection.

The module runs on the Wazuh agent and periodically queries the Microsoft Graph Security API for new alerts and events. It supports multiple API resources and relationships for comprehensive security monitoring.

Prerequisites

  • A Microsoft 365 or Azure AD tenant with admin access.
  • An Azure AD application registered with Microsoft Graph Security API permissions.
  • The application's tenant ID, client ID, and client secret.

Azure AD application setup

  1. In the Azure portal, navigate to Azure Active Directory > App registrations.
  2. Register a new application.
  3. Under API permissions, add the following Microsoft Graph permissions (Application type):
    • SecurityEvents.Read.All – Read security events
    • SecurityAlert.Read.All – Read security alerts
    • Additional permissions depending on the resources you want to monitor
  4. Grant admin consent for the permissions.
  5. Under Certificates & secrets, create a new client secret.

Configuration

Configure the Microsoft Graph module in the Wazuh agent ossec.conf file:

xml
  <ms-graph>
    <enabled>yes</enabled>
    <only_future_events>yes</only_future_events>
    <run_on_start>yes</run_on_start>
    <interval>5m</interval>
    <version>v1.0</version>
    <curl_max_size>1M</curl_max_size>
    <api_auth>
      <client_id>YOUR_CLIENT_ID</client_id>
      <tenant_id>YOUR_TENANT_ID</tenant_id>
      <secret_value>YOUR_CLIENT_SECRET</secret_value>
      <api_type>global</api_type>
    </api_auth>
    <resource>
      <name>security</name>
      <relationship>alerts_v2</relationship>
    </resource>
  </ms-graph>

Configuration options

OptionRequiredDefaultDescription
enabledNoyesEnables or disables the module.
only_future_eventsNoyesOnly retrieve events generated after the module starts.
run_on_startNoyesQuery the API immediately when the module starts.
intervalNo5mTime interval between API queries.
versionNov1.0Microsoft Graph API version. Options: v1.0, beta.
curl_max_sizeNo1MMaximum size of the HTTP response body.
page_sizeNo50Number of results per API page.
time_delayNo30sDelay before retrieving events to allow API propagation.
api_authYesAuthentication configuration section.
client_idYesAzure AD application (client) ID.
tenant_idYesAzure AD tenant ID.
secret_valueYesAzure AD application client secret.
api_typeNoglobalAPI endpoint type. Options: global, gcc-high, dod.
resourceYesDefines a Microsoft Graph resource to monitor. Multiple resource blocks are supported.
nameYesThe resource name (for example, security, identityProtection).
relationshipYesThe relationship to query within the resource (for example, alerts_v2, incidents).

API types

API typeLogin endpointGraph endpointDescription
globallogin.microsoftonline.comgraph.microsoft.comGlobal Microsoft cloud.
gcc-highlogin.microsoftonline.usgraph.microsoft.usUS Government GCC High cloud.
dodlogin.microsoftonline.usdod-graph.microsoft.usUS Department of Defense cloud.

Common resources and relationships

ResourceRelationshipDescription
securityalerts_v2Security alerts from Microsoft security products.
securityincidentsSecurity incidents that correlate related alerts.

Monitoring multiple resources

xml
<ms-graph>
  <enabled>yes</enabled>
  <interval>5m</interval>
  <api_auth>
    <client_id>YOUR_CLIENT_ID</client_id>
    <tenant_id>YOUR_TENANT_ID</tenant_id>
    <secret_value>YOUR_CLIENT_SECRET</secret_value>
  </api_auth>
  <resource>
    <name>security</name>
    <relationship>alerts_v2</relationship>
    <relationship>incidents</relationship>
  </resource>
</ms-graph>

Verify the integration

Restart the Wazuh agent after applying the configuration:

bash
systemctl restart wazuh-agent

Check the module logs:

bash
grep "ms-graph" /var/ossec/logs/ossec.log

Microsoft Graph security events generate alerts with the ms-graph data field populated.