Detection rules › YARA-L
ADFS DKM Key Access
Detects access to the AD contact object to read the AD FS DKM (distributed key manager) master key value
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Credential Access | T1552.004 Unsecured Credentials: Private Keys |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| Security-Auditing | Event ID 4624 | An account was successfully logged on. |
| Security-Auditing | Event ID 4625 | An account failed to log on. |
| Security-Auditing | Event ID 4648 | A logon was attempted using explicit credentials. |
| Security-Auditing | Event ID 4662 | An operation was performed on an object. |
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_dkm_key_access {
meta:
author = "Google Cloud Security"
description = "Detects access to the AD contact object to read the AD FS DKM (distributed key manager) master key value"
rule_id = "mr_2517eaa0-0915-4a9e-8ca2-abce955eb635"
rule_name = "ADFS DKM Key Access"
reference = "https://github.com/OTRF/BHEU22-ADFS/blob/main/Slide-Deck.pdf"
type = "alert"
tactic = "TA0006"
technique = "T1552.004"
platform = "Windows"
data_source = "windows security events"
severity = "High"
priority = "High"
events:
$object.metadata.event_type = "USER_RESOURCE_ACCESS"
$object.metadata.product_name = "Microsoft-Windows-Security-Auditing"
$object.metadata.vendor_name = "Microsoft"
$object.metadata.product_event_type = "4662"
any $object.security_result.detection_fields.value = "properties:{8d3bca50-1d7e-11d0-a081-00aa006c33ed}"
$object.principal.labels["SubjectLogonId"] = $subject
$login.metadata.event_type = "USER_LOGIN"
$login.metadata.product_name = "Microsoft-Windows-Security-Auditing"
$login.metadata.vendor_name = "Microsoft"
$login.metadata.product_event_type = "4624"
$login.target.labels["TargetLogonId"] = $subject
$login.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
$risk_score = 85
//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($logon.principal.hostname)
$object_principal_process_pid = array_distinct($object.principal.process.pid)
$object_principal_user_userid = array_distinct($object.principal.user.userid)
//$principal_user_windows_sid = array_distinct($object.principal.user.windows_sid)
$object_target_resource_name = array_distinct($object.target.resource.name)
condition:
$object and $login
}
Stages and Predicates
Stage 0: match + condition
match:
$hostname over 5m
condition:
$object and $login
Fires when at least one $object event in the 5m window and at least one $login event in the 5m window.
Stage 1: events: $login · USER_LOGIN
$login.metadata.event_type = "USER_LOGIN"
$login.metadata.product_name = "Microsoft-Windows-Security-Auditing"
$login.metadata.vendor_name = "Microsoft"
$login.metadata.product_event_type = "4624"
$login.target.labels["TargetLogonId"] = $subject
$login.principal.hostname = $hostname
Stage 2: events: $object · USER_RESOURCE_ACCESS
$object.metadata.event_type = "USER_RESOURCE_ACCESS"
$object.metadata.product_name = "Microsoft-Windows-Security-Auditing"
$object.metadata.vendor_name = "Microsoft"
$object.metadata.product_event_type = "4662"
any $object.security_result.detection_fields.value = "properties:{8d3bca50-1d7e-11d0-a081-00aa006c33ed}"
$object.principal.labels["SubjectLogonId"] = $subject
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 |
|
security_result.detection_fields.value | 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 | 85 |
object_principal_process_pid | array_distinct($object.principal.process.pid) |
object_principal_user_userid | array_distinct($object.principal.user.userid) |
object_target_resource_name | array_distinct($object.target.resource.name) |