Detection rules › YARA-L
ADFS DB Suspicious Named Pipe Connection
Connection to ADFS via named pipes that are not using specific Windows ADFS processes may be indicative of user attempting to access ADFS for suspicious purposes
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| Sysmon | Event ID 17 | PipeEvent (Pipe Created) |
| Sysmon | Event ID 18 | PipeEvent (Pipe Connected) |
Rule body yaral
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
rule adfs_db_suspicious_named_pipe_connection {
meta:
author = "Google Cloud Security"
description = "Connection to ADFS via named pipes that are not using specific Windows ADFS processes may be indicative of user attempting to access ADFS for suspicious purposes"
rule_id = "mr_a25913a1-65be-4cb5-b0de-6858dd04ac99"
rule_name = "ADFS DB Suspicious Named Pipe Connection"
reference = "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows%20Security%20Events/Analytic%20Rules/ADFSDBNamedPipeConnection.yaml"
type = "alert"
platform = "Windows"
data_source = "sysmon"
severity = "Medium"
priority = "Medium"
events:
$process.metadata.event_type = "PROCESS_UNCATEGORIZED"
$process.metadata.product_event_type = "18"
$process.metadata.product_name = "Microsoft-Windows-Sysmon"
not re.regex($process.target.process.file.full_path, `Microsoft.Identity.Health.Adfs.PshSurrogate.exe|Microsoft.IdentityServer.ServiceHost.exe|AzureADConnect.exe|Microsoft.Tri.Sensor.exe|wsmprovhost.exe|mmc.exe|sqlservr.exe|sqlwriter.exe`) nocase
$process.target.resource.name = "\\MICROSOFT##WID\\tsql\\query" nocase
/*
If you have a listing of ADFS servers, you can use a reference list or enumerate them in the field below.
Alternatively, if ADFS servers are grouped in an asset attribute, that attribute could be used instead.
*/
$process.principal.hostname = /adfs/ nocase
$process.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
$risk_score = 65
$event_count = count_distinct($process.metadata.id)
$security_summary = array_distinct($process.security_result.summary)
$target_process_parent_process_command_line = array_distinct($process.target.process.parent_process.command_line)
//added to populate alert graph with additional context
//Commented out because it is the same as the match variable, if match variable changes, uncomment to use
//$principal_hostname = array_distinct($process.principal.hostname)
$principal_user_userid = array_distinct($process.principal.user.userid)
$target_process_pid = array_distinct($process.target.process.pid)
$target_process_command_line = array_distinct($process.target.process.command_line)
$target_process_file_sha256 = array_distinct($process.target.process.file.sha256)
$target_process_file_full_path = array_distinct($process.target.process.file.full_path)
$target_process_product_specific_process_id = array_distinct($process.target.process.product_specific_process_id)
$target_process_parent_product_specific_process_id = array_distinct($process.target.process.parent_process.product_specific_process_id)
$target_resource_name = array_distinct($process.target.resource.name)
condition:
$process
}
Stages and Predicates
Stage 0: match + condition
match:
$hostname over 5m
condition:
$process
Fires when at least one $process event in the 5m window.
Stage 1: events: $process · PROCESS_UNCATEGORIZED
$process.metadata.event_type = "PROCESS_UNCATEGORIZED"
$process.metadata.product_event_type = "18"
$process.metadata.product_name = "Microsoft-Windows-Sysmon"
not re.regex($process.target.process.file.full_path, `Microsoft.Identity.Health.Adfs.PshSurrogate.exe|Microsoft.IdentityServer.ServiceHost.exe|AzureADConnect.exe|Microsoft.Tri.Sensor.exe|wsmprovhost.exe|mmc.exe|sqlservr.exe|sqlwriter.exe`) nocase
$process.target.resource.name = "\\MICROSOFT##WID\\tsql\\query" nocase
/*
If you have a listing of ADFS servers, you can use a reference list or enumerate them in the field below.
Alternatively, if ADFS servers are grouped in an asset attribute, that attribute could be used instead.
*/
$process.principal.hostname = /adfs/ nocase
$process.principal.hostname = $hostname
Exclusions
Top-level NOT(...) conjuncts: predicates this rule actively suppresses.
| Stage | Field | Kind | Excluded values |
|---|---|---|---|
| 1 | target.process.file.full_path | regex_match | Microsoft.Identity.Health.Adfs.PshSurrogate.exe, Microsoft.IdentityServer.ServiceHost.exe, AzureADConnect.exe, Microsoft.Tri.Sensor.exe, wsmprovhost.exe, mmc.exe, sqlservr.exe, sqlwriter.exe |
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
metadata.product_event_type | eq |
|
principal.hostname | regex_match |
|
target.resource.name | eq |
|
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
risk_score | 65 |
event_count | count_distinct($process.metadata.id) |
security_summary | array_distinct($process.security_result.summary) |
target_process_parent_process_command_line | array_distinct($process.target.process.parent_process.command_line) |
principal_user_userid | array_distinct($process.principal.user.userid) |
target_process_pid | array_distinct($process.target.process.pid) |
target_process_command_line | array_distinct($process.target.process.command_line) |
target_process_file_sha256 | array_distinct($process.target.process.file.sha256) |
target_process_file_full_path | array_distinct($process.target.process.file.full_path) |
target_process_product_specific_process_id | array_distinct($process.target.process.product_specific_process_id) |
target_process_parent_product_specific_process_id | array_distinct($process.target.process.parent_process.product_specific_process_id) |
target_resource_name | array_distinct($process.target.resource.name) |