You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: defender-xdr/custom-detection-rules.md
+38-43Lines changed: 38 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,30 +30,33 @@ Custom detection rules are rules you can design and tweak using [advanced huntin
30
30
31
31
## Required permissions for managing custom detections
32
32
33
+
> [!IMPORTANT]
34
+
> Microsoft recommends that you use roles with the fewest permissions. This helps improve security for your organization. Global Administrator is a highly privileged role that should be limited to emergency scenarios when you can't use an existing role.
35
+
33
36
To manage custom detections, you need to be assigned one of these roles:
34
37
35
-
-**Security settings (manage)**—Users with this [Microsoft Defender XDR permission](manage-rbac.md) can manage security settings in the Microsoft Defender portal.
36
-
-**Security administrator**—Users with this [Microsoft Entra role](/azure/active-directory/roles/permissions-reference#security-administrator) can manage security settings in the Microsoft Defender portal and other portals and services.
38
+
-**Security settings (manage)** — Users with this [Microsoft Defender XDR permission](manage-rbac.md) can manage security settings in the Microsoft Defender portal.
37
39
38
-
-**Security operator**—Users with this [Microsoft Entra role](/azure/active-directory/roles/permissions-reference#security-operator) can manage alerts and have global read-only access to security-related features, including all information in the Microsoft Defender portal. This role is sufficient for managing custom detections only if role-based access control (RBAC) is turned off in Microsoft Defender for Endpoint. If you have RBAC configured, you also need the **manage security settings** permission for Defender for Endpoint.
40
+
-**Security Administrator** — Users with this [Microsoft Entra role](/azure/active-directory/roles/permissions-reference#security-administrator) can manage security settings in the Microsoft Defender portal and other portals and services.
41
+
42
+
-**Security Operator** — Users with this [Microsoft Entra role](/azure/active-directory/roles/permissions-reference#security-operator) can manage alerts and have global read-only access to security-related features, including all information in the Microsoft Defender portal. This role is sufficient for managing custom detections only if role-based access control (RBAC) is turned off in Microsoft Defender for Endpoint. If you have RBAC configured, you also need the *Manage Security Settings permission for Defender for Endpoint.
39
43
40
44
You can manage custom detections that apply to data from specific Microsoft Defender XDR solutions if you have the right permissions for them. For example, if you only have manage permissions for Microsoft Defender for Office 365, you can create custom detections using `Email*` tables but not `Identity*` tables.
41
45
42
46
Likewise, since the `IdentityLogonEvents` table holds authentication activity information from both Microsoft Defender for Cloud Apps and Defender for Identity, you need to have manage permissions for both services to manage custom detections querying the said table.
43
47
44
48
> [!NOTE]
45
-
> To manage custom detections, **security operators** will need the **manage security settings** permission in Microsoft Defender for Endpoint if RBAC is turned on.
49
+
> To manage custom detections, Security Operators must have the Manage Security Settings permission in Microsoft Defender for Endpoint if RBAC is turned on.
50
+
51
+
To manage required permissions, a Global Administrator can:
46
52
47
-
To manage required permissions, a **global administrator** can:
53
+
- Assign the Security Administrator or Security Operator role in [Microsoft 365 admin center](https://admin.microsoft.com/) under **Roles**\>**Security Administrator**.
48
54
49
-
- Assign the **security administrator** or **security operator** role in [Microsoft 365 admin center](https://admin.microsoft.com/) under **Roles**\>**Security admin**.
50
55
- Check RBAC settings for Microsoft Defender for Endpoint in [Microsoft Defender XDR](https://security.microsoft.com/) under **Settings**\>**Permissions** > **Roles**. Select the corresponding role to assign the **manage security settings** permission.
51
56
52
57
> [!NOTE]
53
58
> A user also needs to have the appropriate permissions for the devices in the [device scope](#5-set-the-rule-scope) of a custom detection rule that they are creating or editing before they can proceed. A user can't edit a custom detection rule that is scoped to run on all devices, if the same user does not permissions for all devices.
54
59
55
-
56
-
57
60
## Create a custom detection rule
58
61
59
62
### 1. Prepare the query
@@ -111,31 +114,30 @@ DeviceEvents
111
114
112
115
With the query in the query editor, select **Create detection rule** and specify the following alert details:
113
116
114
-
-**Detection name**—name of the detection rule; should be unique
115
-
-**Frequency**—interval for running the query and taking action. [See more guidance in the rule frequency section](#rule-frequency)
116
-
-**Alert title**—title displayed with alerts triggered by the rule; should be unique
117
-
-**Severity**—potential risk of the component or activity identified by the rule
118
-
-**Category**—threat component or activity identified by the rule
119
-
-**MITRE ATT&CK techniques**—one or more attack techniques identified by the rule as documented in the [MITRE ATT&CK framework](https://attack.mitre.org/). This section is hidden for certain alert categories, including malware, ransomware, suspicious activity, and unwanted software
120
-
-**Description**—more information about the component or activity identified by the rule
121
-
-**Recommended actions**—additional actions that responders might take in response to an alert
117
+
-**Detection name** — name of the detection rule; should be unique
118
+
-**Frequency** — interval for running the query and taking action. [See more guidance in the rule frequency section](#rule-frequency)
119
+
-**Alert title** — title displayed with alerts triggered by the rule; should be unique
120
+
-**Severity** — potential risk of the component or activity identified by the rule
121
+
-**Category** — threat component or activity identified by the rule
122
+
-**MITRE ATT&CK techniques** — one or more attack techniques identified by the rule as documented in the [MITRE ATT&CK framework](https://attack.mitre.org/). This section is hidden for certain alert categories, including malware, ransomware, suspicious activity, and unwanted software
123
+
-**Description** — more information about the component or activity identified by the rule
124
+
-**Recommended actions** — additional actions that responders might take in response to an alert
122
125
123
126
#### Rule frequency
124
127
125
128
When you save a new rule, it runs and checks for matches from the past 30 days of data. The rule then runs again at fixed intervals, applying a lookback duration based on the frequency you choose:
126
129
127
-
-**Every 24 hours**—runs every 24 hours, checking data from the past 30 days
128
-
-**Every 12 hours**—runs every 12 hours, checking data from the past 48 hours
129
-
-**Every 3 hours**—runs every 3 hours, checking data from the past 12 hours
130
-
-**Every hour**—runs hourly, checking data from the past 4 hours
131
-
-**Continuous (NRT)**—runs continuously, checking data from events as they're collected and processed in near real-time (NRT), see [Continuous (NRT) frequency](custom-detection-rules.md#continuous-nrt-frequency)
130
+
-**Every 24 hours** — runs every 24 hours, checking data from the past 30 days
131
+
-**Every 12 hours** — runs every 12 hours, checking data from the past 48 hours
132
+
-**Every 3 hours** — runs every 3 hours, checking data from the past 12 hours
133
+
-**Every hour** — runs hourly, checking data from the past 4 hours
134
+
-**Continuous (NRT)** — runs continuously, checking data from events as they're collected and processed in near real-time (NRT), see [Continuous (NRT) frequency](custom-detection-rules.md#continuous-nrt-frequency)
132
135
133
136
> [!TIP]
134
137
> Match the time filters in your query with the lookback duration. Results outside of the lookback duration are ignored.
135
138
136
139
When you edit a rule, it will run with the applied changes in the next run time scheduled according to the frequency you set. The rule frequency is based on the event timestamp and not the ingestion time.
137
140
138
-
139
141
##### Continuous (NRT) frequency
140
142
141
143
Setting a custom detection to run in Continuous (NRT) frequency allows you to increase your organization's ability to identify threats faster.
@@ -180,8 +182,6 @@ Near real-time detections are supported for the following tables:
180
182
> [!NOTE]
181
183
> Only columns that are generally available can support **Continuous (NRT)** frequency.
182
184
183
-
184
-
185
185
### 3. Choose the impacted entities
186
186
187
187
Identify the columns in your query results where you expect to find the main affected or impacted entity. For example, a query might return sender (`SenderFromAddress` or `SenderMailFromAddress`) and recipient (`RecipientEmailAddress`) addresses. Identifying which of these columns represent the main impacted entity helps the service aggregate relevant alerts, correlate incidents, and target response actions.
@@ -198,11 +198,11 @@ Your custom detection rule can automatically take actions on devices, files, use
198
198
199
199
These actions are applied to devices in the `DeviceId` column of the query results:
200
200
201
-
-**Isolate device**—uses Microsoft Defender for Endpoint to apply full network isolation, preventing the device from connecting to any application or service. [Learn more about Microsoft Defender for Endpoint machine isolation](/windows/security/threat-protection/microsoft-defender-atp/respond-machine-alerts#isolate-devices-from-the-network)
202
-
-**Collect investigation package**—collects device information in a ZIP file. [Learn more about the Microsoft Defender for Endpoint investigation package](/windows/security/threat-protection/microsoft-defender-atp/respond-machine-alerts#collect-investigation-package-from-devices)
203
-
-**Run antivirus scan**—performs a full Microsoft Defender Antivirus scan on the device
204
-
-**Initiate investigation**—initiates an [automated investigation](m365d-autoir.md) on the device
205
-
-**Restrict app execution**—sets restrictions on device to allow only files that are signed with a Microsoft-issued certificate to run. [Learn more about app restrictions with Microsoft Defender for Endpoint](/defender-endpoint/respond-machine-alerts#restrict-app-execution)
201
+
-**Isolate device** — uses Microsoft Defender for Endpoint to apply full network isolation, preventing the device from connecting to any application or service. [Learn more about Microsoft Defender for Endpoint machine isolation](/windows/security/threat-protection/microsoft-defender-atp/respond-machine-alerts#isolate-devices-from-the-network)
202
+
-**Collect investigation package** — collects device information in a ZIP file. [Learn more about the Microsoft Defender for Endpoint investigation package](/windows/security/threat-protection/microsoft-defender-atp/respond-machine-alerts#collect-investigation-package-from-devices)
203
+
-**Run antivirus scan** — performs a full Microsoft Defender Antivirus scan on the device
204
+
-**Initiate investigation** — initiates an [automated investigation](m365d-autoir.md) on the device
205
+
-**Restrict app execution** — sets restrictions on device to allow only files that are signed with a Microsoft-issued certificate to run. [Learn more about app restrictions with Microsoft Defender for Endpoint](/defender-endpoint/respond-machine-alerts#restrict-app-execution)
206
206
207
207
#### Actions on files
208
208
@@ -227,10 +227,8 @@ For more details on user actions, read [Remediation actions in Microsoft Defende
227
227
228
228
- Alternatively, you can select **Delete email** and then choose to either move the emails to Deleted Items (**Soft delete**) or delete the selected emails permanently (**Hard delete**).
229
229
230
-
231
230
The columns `NetworkMessageId` and `RecipientEmailAddress` must be present in the output results of the query to apply actions to email messages.
232
231
233
-
234
232
### 5. Set the rule scope
235
233
236
234
Set the scope to specify which devices are covered by the rule. The scope influences rules that check devices and doesn't affect rules that check only mailboxes and user accounts or identities.
@@ -245,8 +243,6 @@ Only data from devices in the scope will be queried. Also, actions are taken onl
245
243
> [!NOTE]
246
244
> Users are able to create or edit a custom detection rule only if they have the corresponding permissions for the devices included in the scope of the rule. For instance, admins can only create or edit rules that are scoped to all device groups if they have permissions for all device groups.
247
245
248
-
249
-
250
246
### 6. Review and turn on the rule
251
247
252
248
After reviewing the rule, select **Create** to save it. The custom detection rule immediately runs. It runs again based on configured frequency to check for matches, generate alerts, and take response actions.
@@ -267,10 +263,10 @@ You can view the list of existing custom detection rules, check their previous r
267
263
268
264
To view all existing custom detection rules, navigate to **Hunting** > **Custom detection rules**. The page lists all the rules with the following run information:
269
265
270
-
-**Last run**—when a rule was last run to check for query matches and generate alerts
271
-
-**Last run status**—whether a rule ran successfully
272
-
-**Next run**—the next scheduled run
273
-
-**Status**—whether a rule has been turned on or off
266
+
-**Last run** — when a rule was last run to check for query matches and generate alerts
267
+
-**Last run status** — whether a rule ran successfully
268
+
-**Next run** — the next scheduled run
269
+
-**Status** — whether a rule has been turned on or off
274
270
275
271
### View rule details, modify rule, and run rule
276
272
@@ -280,12 +276,11 @@ To view comprehensive information about a custom detection rule, go to **Hunting
280
276
281
277
You can also take the following actions on the rule from this page:
282
278
283
-
-**Run**—run the rule immediately. This also resets the interval for the next run.
284
-
-**Edit**—modify the rule without changing the query
285
-
-**Modify query**—edit the query in advanced hunting
286
-
-**Turn on** / **Turn off**—enable the rule or stop it from running
287
-
-**Delete**—turn off the rule and remove it
288
-
279
+
-**Run** — run the rule immediately. This also resets the interval for the next run.
280
+
-**Edit** — modify the rule without changing the query
281
+
-**Modify query** — edit the query in advanced hunting
282
+
-**Turn on** / **Turn off** — enable the rule or stop it from running
0 commit comments