The ServiceNow Microsoft Defender for Endpoint integration synchronizes security alerts, incidents, and device data between Microsoft's endpoint protection platform and ServiceNow's Security Operations Center (SecOps) workflows. This integration enables security teams to centralize threat detection, automate incident response, and maintain comprehensive visibility across their security ecosystem while leveraging ServiceNow's case management and orchestration capabilities. The integration supports bidirectional data flows, allowing alerts and incidents to flow from Defender into ServiceNow Security Incident Response tables while enabling response actions to be executed back to Defender endpoints. Primary triggers include real-time webhook notifications for new alerts and scheduled imports for device inventory updates, with all configuration managed through the ServiceNow Integration Hub and Security Operations applications.
Prerequisites
- •ServiceNow San Diego release or later with Security Operations application installed
- •Integration Hub Professional license or higher
- •Microsoft Defender for Endpoint Plan 1 or Plan 2 license
- •Global Administrator or Security Administrator role in Microsoft Azure AD tenant
- •ServiceNow admin role and security_admin role for configuration
- •Active MID Server for outbound API calls (recommended for production environments)
- •Microsoft Graph API permissions including SecurityEvents.Read.All and Machine.ReadWrite.All
Architecture Overview
The integration leverages the ServiceNow Microsoft Security Graph spoke within Integration Hub, which provides pre-built actions for interacting with Microsoft Defender for Endpoint APIs through Microsoft Graph endpoints. Authentication is established using OAuth 2.0 Client Credentials flow, with application credentials stored in ServiceNow Connection and Credential Alias records that securely manage the client ID, client secret, and tenant information. Data flows bidirectionally with inbound alerts triggered by scheduled imports or webhook notifications creating Security Incident Response (SIR) incidents, while outbound actions like device isolation or file quarantine are executed through Integration Hub flows. A MID Server is recommended for production environments to handle the OAuth token refresh cycles and provide better error handling for API rate limiting, though cloud-to-cloud connectivity is supported. Microsoft Graph API enforces rate limits of approximately 15,000 requests per 10 minutes per application, requiring implementation of exponential backoff and retry logic in custom flows.
Sourdough: ServiceNow Monitoring and Analytics
A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.
Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.
Implementation Steps
Register application in Microsoft Azure AD and configure API permissions
Navigate to the Azure portal and access Azure Active Directory > App registrations, then create a new application registration for ServiceNow integration. Record the Application (client) ID and Directory (tenant) ID for later use in ServiceNow. Under API permissions, add Microsoft Graph permissions including SecurityEvents.Read.All, SecurityEvents.ReadWrite.All, Machine.Read.All, and Machine.ReadWrite.All, ensuring to grant admin consent for the organization. Generate a client secret under Certificates & secrets and securely store the secret value as it will only be displayed once.
Create Connection and Credential Alias in ServiceNow
Navigate to Connections & Credentials > Connections and create a new connection record with the name 'Microsoft Defender ATP Connection'. Set the connection URL to 'https://graph.microsoft.com' and select 'OAuth 2.0' as the authentication type. Create a corresponding Credential Alias under Connections & Credentials > Credential Aliases, configuring it with the Azure application's client ID as the username, client secret as the password, and the OAuth token URL as 'https://login.microsoftonline.com/[tenant-id]/oauth2/v2.0/token'. Set the OAuth scope to 'https://graph.microsoft.com/.default' to ensure proper API access permissions.
Install and configure Microsoft Security Graph spoke
Navigate to System Applications > All Available Applications > All and search for 'Microsoft Security Graph' spoke, then install the latest version. After installation, go to Process Automation > Flow Designer and create a new flow for testing the connection. Add a Microsoft Security Graph action such as 'Get Security Alerts' and configure it to use the Connection and Credential Alias created in the previous step. Test the connection by running the flow and verifying that it successfully retrieves security alert data from Microsoft Defender for Endpoint without authentication errors.
Configure inbound alert synchronization flow
Create a new scheduled flow in Flow Designer named 'Import Defender ATP Alerts' that runs every 5-10 minutes to retrieve new security alerts. Use the 'Get Security Alerts' action with appropriate filters to retrieve alerts from the last polling interval, filtering by vendorInformation.provider equals 'Microsoft Defender ATP'. Map the alert data to ServiceNow Security Incident Response (SIR) incident records, ensuring fields like priority, description, affected_user, and custom fields capture relevant threat intelligence data. Implement deduplication logic using the alert ID to prevent duplicate incident creation, and add error handling to manage API rate limits and connection failures gracefully.
// Flow script step for alert deduplication
(function execute(inputs, outputs) {
var alertId = inputs.alert_id;
var gr = new GlideRecord('sn_si_incident');
gr.addQuery('correlation_id', alertId);
gr.query();
if (gr.hasNext()) {
outputs.alert_exists = true;
outputs.existing_incident = gr.getUniqueValue();
} else {
outputs.alert_exists = false;
}
})(inputs, outputs);Implement CMDB device record enrichment
Create a flow called 'Enrich CMDB with Defender Device Data' that synchronizes device information from Microsoft Defender for Endpoint to ServiceNow CMDB computer records. Use the 'Get Machines' Microsoft Graph action to retrieve device inventory including device names, IP addresses, operating system information, risk scores, and onboarding status. Map this data to appropriate CMDB CI fields, creating new Computer [cmdb_ci_computer] records for devices not already in the CMDB and updating existing records with current risk assessment data. Schedule this flow to run daily or weekly depending on your environment's change frequency, and implement logging to track newly discovered devices and risk score changes.
// Script step for CMDB device update
(function execute(inputs, outputs) {
var deviceName = inputs.device_name;
var riskScore = inputs.risk_score;
var computer = new GlideRecord('cmdb_ci_computer');
computer.addQuery('name', deviceName);
computer.query();
if (computer.next()) {
computer.setValue('u_defender_risk_score', riskScore);
computer.setValue('u_last_defender_sync', new GlideDateTime());
computer.update();
outputs.action_taken = 'updated';
} else {
computer.initialize();
computer.setValue('name', deviceName);
computer.setValue('u_defender_risk_score', riskScore);
computer.insert();
outputs.action_taken = 'created';
}
})(inputs, outputs);Build automated response workflow for device isolation
Create a flow named 'Defender ATP Automated Response' that can be triggered from Security Incident Response workflows to execute containment actions on compromised devices. Configure the flow to accept inputs including device ID, action type (isolate, unisolate, run antivirus scan), and incident number for tracking. Use the Microsoft Graph 'Isolate Machine' or 'Run Antivirus Scan' actions as appropriate, and implement proper error handling to capture API responses and update the associated incident with action results. Add approval gates for destructive actions and ensure all automated responses are logged in the incident activity stream for audit purposes.
// REST Message for custom device isolation if spoke action unavailable
var rm = new RESTMessage('Microsoft Graph API', 'POST');
rm.setEndpoint('https://graph.microsoft.com/v1.0/security/machines/' + device_id + '/isolate');
rm.setRequestHeader('Authorization', 'Bearer ' + access_token);
rm.setRequestHeader('Content-Type', 'application/json');
var requestBody = {
'Comment': 'Automated isolation from ServiceNow incident ' + incident_number,
'IsolationType': 'Full'
};
rm.setRequestBody(JSON.stringify(requestBody));
var response = rm.execute();
gs.info('Device isolation response: ' + response.getBody());Configure bidirectional incident status synchronization
Implement a business rule on the Security Incident Response table that triggers when incident state changes to 'Resolved' or 'Closed' and updates the corresponding alert status in Microsoft Defender for Endpoint. Create a flow action that uses the Microsoft Graph 'Update Alert' API to change the alert status, feedback, and add closure comments. Configure the business rule to run asynchronously to avoid blocking user actions, and include error handling to manage cases where the original alert may no longer exist in Defender. Ensure proper field mapping between ServiceNow incident resolution codes and Microsoft Defender alert feedback values like 'TruePositive', 'FalsePositive', or 'Benign'.
// Business Rule script for incident closure sync
(function executeRule(current, previous) {
if (current.state == '3' && previous.state != '3') { // Resolved state
var correlationId = current.correlation_id.toString();
if (correlationId) {
sn_fd.FlowAPI.getRunner().trigger('defender_update_alert_status', {
'alert_id': correlationId,
'status': 'resolved',
'feedback': current.u_alert_feedback.toString(),
'comments': current.close_notes.toString()
});
}
}
})(current, previous);Test integration and validate data flows
Execute comprehensive testing by manually triggering each flow and verifying data synchronization in both directions between ServiceNow and Microsoft Defender for Endpoint. Generate test alerts in Defender (using Microsoft's built-in alert simulation tools if available) and confirm they create appropriate incidents in ServiceNow with correct field mapping and priority assignment. Test outbound actions like device isolation by executing the response workflow on a test device and verifying the action completes successfully in Defender's security portal. Validate CMDB enrichment by comparing device records in ServiceNow with the device inventory in Microsoft 365 Defender portal, and confirm that incident status updates in ServiceNow properly sync back to close alerts in Defender.
// Test script for connection validation
var testConnection = function() {
try {
var rm = new RESTMessage('Microsoft Graph API', 'GET');
rm.setEndpoint('https://graph.microsoft.com/v1.0/security/alerts?$top=1');
var response = rm.execute();
if (response.getStatusCode() == 200) {
gs.info('Microsoft Defender ATP connection test successful');
return true;
} else {
gs.error('Connection test failed: ' + response.getStatusCode());
return false;
}
} catch (ex) {
gs.error('Connection test exception: ' + ex.getMessage());
return false;
}
};Common Use Cases
Automated incident creation from high-severity malware alerts
When Microsoft Defender for Endpoint detects high-severity malware or suspicious executable activity, it automatically creates a Security Incident Response incident in ServiceNow with enriched context including affected device details, file hashes, and threat intelligence. The incident is assigned to the appropriate security team based on device organizational unit or IP subnet, and includes automated enrichment with CMDB data to identify device owner and business criticality. This reduces mean time to response by eliminating manual alert triage and ensures consistent incident categorization across the security operations team.
Automated device isolation for confirmed threats
Security analysts can execute automated device containment directly from ServiceNow incident workflows, triggering immediate network isolation of compromised endpoints through Microsoft Defender for Endpoint APIs. The integration captures isolation status, timestamps, and any error conditions back into the incident record for complete audit trails. Additional automated actions include running full antivirus scans, collecting investigation packages, and restricting app execution on isolated devices based on incident severity and analyst approval workflows.
CMDB enrichment with endpoint security posture
Device configuration items in the ServiceNow CMDB are automatically enriched with real-time security posture data from Microsoft Defender for Endpoint, including risk scores, compliance status, and installed security agent versions. This data enables proactive vulnerability management workflows and helps identify devices that may need security configuration updates or are at higher risk for compromise. Integration with Change Management processes ensures security impact assessments include current threat landscape data for affected devices.
Bidirectional alert lifecycle management
Alert status synchronization ensures that when security analysts resolve incidents in ServiceNow, the corresponding alerts in Microsoft Defender for Endpoint are automatically updated with resolution status, feedback classification, and analyst comments. This prevents duplicate investigation effort and maintains consistent alert states across both platforms while providing proper closure documentation for compliance reporting. False positive classifications in ServiceNow trigger automatic alert suppression rules in Defender to reduce future noise from similar detections.
Threat hunting workflow orchestration
ServiceNow orchestration workflows can automatically initiate advanced hunting queries in Microsoft Defender for Endpoint based on indicators of compromise discovered during incident investigation, such as file hashes, IP addresses, or behavioral patterns. Results are automatically parsed and attached to the incident as additional evidence, while any newly discovered affected devices are added to the incident scope. This enables security teams to quickly assess the full impact of security incidents across their endpoint environment without manual hunting activities.
Troubleshooting
OAuth token refresh failures causing 401 Unauthorized errors on API calls
Check the Connection record's OAuth configuration and verify the tenant ID is correct in the token URL. Navigate to System Logs > REST Messages to review the token refresh attempt details and confirm the client secret hasn't expired in Azure AD. If using a MID Server, restart the MID Server service to clear any cached credentials and test the connection again using the Test Connection feature in the Connection record.
Microsoft Graph API rate limiting causing flow execution failures with 429 status codes
Implement exponential backoff retry logic in your flows using Wait actions with increasing delays between API calls. Review your polling frequency and reduce the scheduled flow execution interval if you're hitting rate limits consistently. Check the Retry-After header in the API response and configure your flows to respect Microsoft's recommended back-off periods, typically 60-120 seconds for security APIs.
Security alerts not creating incidents despite successful API connectivity
Verify that your Microsoft Graph API permissions include SecurityEvents.Read.All and have been granted admin consent in Azure AD. Check the alert filtering criteria in your flow to ensure you're not accidentally filtering out all alerts with overly restrictive date ranges or vendor filters. Review the Flow Designer execution history to identify where the flow is failing and examine the alert payload structure to ensure field mappings match the actual Microsoft Graph API response format.
CMDB device records not updating with Defender risk scores and device information
Confirm that your flows have proper read/write permissions to the CMDB tables and that the device matching logic correctly identifies existing CI records. Check for field naming mismatches between the Microsoft Graph API device response and your ServiceNow CMDB schema, particularly for custom fields storing Defender-specific data. Enable debug logging in your flows to trace the device lookup and update process, and verify that device names returned by Defender match the naming convention used in your CMDB.
Device isolation actions failing with insufficient permissions errors
Verify that your Azure AD application registration includes Machine.ReadWrite.All permissions and has been granted admin consent for your organization. Check that the target device is properly onboarded to Microsoft Defender for Endpoint and appears in the devices list with an active status. Review the device isolation API response for specific error details and ensure your request payload includes required fields like Comment and IsolationType with valid values.
Duplicate incidents being created for the same Defender alerts
Implement proper deduplication logic using the alert ID or other unique identifiers from Microsoft Defender before creating new incident records. Check your correlation ID field mapping to ensure each alert has a unique identifier stored in ServiceNow that can be used for future lookups. Review your scheduled flow execution intervals and alert filtering criteria to prevent re-processing the same alerts in subsequent polling cycles, and consider using last-run timestamps to track processed alerts.
Pro Tips
- →Implement custom retry logic with exponential backoff in your Integration Hub flows to handle Microsoft Graph API rate limits gracefully, using Wait actions with dynamically calculated delays based on the Retry-After response header. This prevents flow failures during high-volume alert periods and ensures reliable data synchronization.
- →Create custom ServiceNow tables for storing Microsoft Defender-specific metadata like alert evidence, investigation timeline data, and device threat analytics that don't map cleanly to standard incident fields. This preserves valuable forensic information while keeping incident records clean and allows for advanced reporting on threat patterns.
- →Use ServiceNow's Event Management capabilities alongside Security Incident Response to handle lower-priority Defender alerts as events first, automatically promoting them to incidents only when specific criteria are met like multiple related alerts or high device risk scores. This reduces incident noise while maintaining visibility into security telemetry.
- →Configure webhook endpoints in ServiceNow using Scripted REST APIs for real-time alert ingestion instead of relying solely on scheduled polling, reducing alert detection-to-incident creation time from minutes to seconds. Implement proper authentication and payload validation to secure these endpoints against unauthorized access.
- →Leverage ServiceNow's Connection Aliases for different Defender tenants or environments, allowing the same flows to work across development, staging, and production Microsoft environments by simply changing the connection configuration rather than maintaining separate flows.
- →Implement comprehensive logging and monitoring of integration health using ServiceNow's Metrics framework to track API call success rates, alert processing times, and data synchronization lag, enabling proactive identification and resolution of integration issues before they impact security operations.
Known Limitations
- —Microsoft Graph Security APIs enforce rate limits of approximately 15,000 requests per 10-minute window per application, which can constrain real-time alert processing in high-volume environments with thousands of endpoints. Large organizations may need to implement request queuing and batching strategies to stay within these limits.
- —The Microsoft Security Graph spoke in Integration Hub may not support all available Microsoft Defender for Endpoint API endpoints, requiring custom REST Message implementations for advanced features like live response commands, custom threat indicators, or advanced hunting queries. This increases development complexity and maintenance overhead.
- —Alert data retention in Microsoft Graph is limited to 30 days for most alert types, meaning ServiceNow cannot retrieve historical alert data beyond this timeframe through the standard APIs. Organizations requiring longer retention periods must implement continuous synchronization rather than one-time bulk imports.
- —Device action APIs in Microsoft Defender have inherent latency of 2-5 minutes before actions take effect on endpoints, which may not meet requirements for immediate threat containment in critical scenarios. Network isolation and other containment actions should not be considered instantaneous.
- —Complex alert evidence and investigation data from Microsoft Defender may not map cleanly to ServiceNow's standard incident and task structure, requiring custom tables and workflows to preserve forensic details and maintain investigative context across platforms.
Frequently Asked Questions
Can the integration handle multiple Microsoft Defender for Endpoint tenants simultaneously?
Yes, you can configure multiple Connection and Credential Alias records in ServiceNow to connect to different Microsoft tenants or Defender instances. Each connection requires its own Azure AD application registration and separate Integration Hub flows, but you can use the same spoke actions across different connections. Consider using naming conventions like 'Defender-Production' and 'Defender-Development' for your connections to maintain clarity in multi-tenant environments.
How does the integration handle Microsoft Defender alerts that are automatically resolved by the platform?
The integration can detect status changes in Microsoft Defender alerts during scheduled synchronization and automatically update corresponding ServiceNow incidents to match the alert status. Configure your flows to check alert status during each polling cycle and implement business rules to handle automatic incident closure when Defender resolves false positives or applies automatic remediation. You can also configure notifications to security analysts when incidents are automatically closed based on upstream resolution.
What happens if ServiceNow cannot reach Microsoft Graph APIs due to network connectivity issues?
Integration Hub flows include built-in error handling for network connectivity issues, and you can configure retry logic with exponential backoff to handle temporary outages. Failed API calls are logged in the System Logs, and flows can be configured to send notifications to administrators when connectivity issues persist beyond defined thresholds. Consider implementing queue-based processing for critical alerts to ensure no data loss during extended outages.
Can custom threat intelligence feeds be synchronized from ServiceNow back to Microsoft Defender for Endpoint?
Yes, you can create flows that push custom indicators of compromise from ServiceNow threat intelligence tables to Microsoft Defender using the Threat Intelligence Indicators API. This requires additional Microsoft Graph permissions (ThreatIndicators.ReadWrite.OwnedBy) and custom flow development since the standard spoke may not include these actions. Consider implementing validation logic to ensure indicator quality and prevent false positive detections.
How should large organizations handle the volume of alerts from thousands of endpoints?
Implement intelligent alert filtering and aggregation strategies using Microsoft Defender's alert suppression rules and ServiceNow's event correlation capabilities to reduce noise before creating incidents. Configure threshold-based promotion where multiple related alerts create a single incident, and use ServiceNow's Event Management module for lower-priority alerts. Consider implementing custom priority scoring based on device criticality from CMDB data and threat severity from Defender.
Are there specific Integration Hub license requirements for this integration?
The Microsoft Security Graph spoke requires an Integration Hub Professional license or higher, and you'll need sufficient Integration Hub step allocations for your expected alert volume and polling frequency. Each API call consumes Integration Hub steps, so high-volume environments may need additional step packages. The spoke is included in the IntegrationHub store at no additional cost beyond the base Integration Hub licensing.
Can the integration automatically create Security Incident Response playbooks based on Defender alert types?
Yes, you can configure flows to automatically attach appropriate playbooks to incidents based on Microsoft Defender alert categories, threat types, or MITRE ATT&CK technique classifications included in the alert metadata. Create mapping logic that matches Defender alert classifications to your organization's standard incident response playbooks, and use ServiceNow's Security Incident Response playbook automation to guide analyst response activities. This ensures consistent response procedures across different threat types.
Test Your Knowledge
Quick 3-question quiz — see how your ServiceNow skills stack up.
A list view on a table with millions of records is slow. Best fix?
Select an answer to continue