Detection rules › YARA-L
YARA-L rules: 1s
| Rule | Severity |
|---|---|
| Entra ID Add User Outside PIM | medium |
| MITRE ATT&CK T1110.001 Windows Repeated Authentication Failures Before Successful One With User Entity | medium |
| sap hanadb audit trail policy changes | high |
Entra ID Add User Outside PIM
#Adding users to roles is expected but if it occurs outside of PIM, validation should occur
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Persistence |
Telemetry Coverage
| Platform | Record / event type |
|---|---|
| Azure | Add member to role outside of PIM (permanent) |
Rules Detecting the Same Action
These rules filter on the same operation.
- [Entra ID] Application Assigned Administrator Permissions Immediately After Obtaining Role Management Permissions (Kusto)
- [Entra ID] Mass Privileged Role Change Activity Detected (Kusto)
- [Entra ID] Privilege Elevation Request Denied (Kusto)
- [Entra ID] Privileged Role Assigned to a New User (Kusto)
- [Entra ID] Privileged Role Assigned to User (Kusto)
- Account Elevated to New Role (Kusto)
- Admin promotion after Role Management Application Permission Grant (Kusto)
- App Assigned To Azure RBAC/Microsoft Entra Role (Sigma)
Rule Body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule entra_id_add_user_outside_pim {
meta:
author = "Google Cloud Security"
description = "Adding users to roles is expected but if it occurs outside of PIM, validation should occur"
rule_id = "mr_bc0a22e2-7ab1-4368-9408-3e6a5b666bec"
rule_name = "Entra ID Add User Outside PIM"
tactic = "TA0003"
technique = "T1098.003"
assumption = "The list entra_id_watchlist_roles or entra_id_watchlist_roles_guid is populated with role names, ie Exchange Administrator or 29232cdf-9323-42fd-ade2-1d097af3e4de, respectively"
type = "alert"
platform = "azure"
data_source = "azure ad"
severity = "Medium"
priority = "Medium"
events:
$app.metadata.event_type = "USER_UNCATEGORIZED"
$app.metadata.product_name = "Azure AD Directory Audit"
$app.metadata.vendor_name = "Microsoft"
$app.security_result.action = "ALLOW"
$app.metadata.product_event_type = "Add member to role outside of PIM (permanent)" //triggered via PS API call
//Can add watchlist of specific roles by name using the following commented out line
//$app.target.resource.name in %entra_id_watchlist_roles
//Can add watchlist of specific roles by guid using the following commented out line
//$app.target.resource.attribute.labels["TemplateId"] in %entra_id_watchlist_roles_guid
$app.principal.user.userid = $user
match:
$user over 5m
outcome:
$risk_score = 65
$event_count = count_distinct($app.metadata.id)
$assigned_role = array_distinct($app.target.resource.name)
$assigned_role_guid = array_distinct($app.target.resource.attribute.labels["TemplateId"])
$network_session = array_distinct($app.network.session_id)
$userid_making_modification = array_distinct($app.principal.user.userid)
$principal_user_email_addresses = array_distinct($app.principal.user.email_addresses)
$modified_userid = array_distinct($app.target.user.email_addresses)
condition:
$app
}
YARA-L Rule Structure
Condition
Fires when at least one $app event in the 5m window.
Events
$app
security_result.action = "ALLOW"metadata.product_event_type = "Add member to role outside of PIM (permanent)"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | 65 |
event_count | count_distinct($app.metadata.id) |
assigned_role | array_distinct($app.target.resource.name) |
assigned_role_guid | array_distinct($app.target.resource.attribute.labels["TemplateId"]) |
network_session | array_distinct($app.network.session_id) |
userid_making_modification | array_distinct($app.principal.user.userid) |
principal_user_email_addresses | array_distinct($app.principal.user.email_addresses) |
modified_userid | array_distinct($app.target.user.email_addresses) |
MITRE ATT&CK T1110.001 Windows Repeated Authentication Failures Before Successful One With User Entity
#Detect Multiple Failed Login Attempts followed by Successful Login
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Credential Access |
Telemetry Coverage
Rule Body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule win_repeatedAuthFailure_thenSuccess_T1110_001_user_asset_entity {
meta:
author = "Google Cloud Security"
description = "Detect Multiple Failed Login Attempts followed by Successful Login"
rule_id = "mr_2a9dc1d2-d4b8-4b80-a494-3369c681da60"
rule_name = "MITRE ATT&CK T1110.001 Windows Repeated Authentication Failures Before Successful One With User Entity"
type = "alert"
tags = "user entity, asset entity"
assumption = "Assumes ingestion of Windows users and assets to entity graph to entity graph"
data_source = "microsoft windows events"
platform = "Windows"
severity = "Medium"
priority = "Medium"
tactic = "TA0006"
technique = "T1110.001"
events:
$fail.metadata.event_type = "USER_LOGIN"
$fail.metadata.vendor_name = "Microsoft"
$fail.principal.hostname = $hostname
$fail.target.user.userid = $target_user
$fail.security_result.action = "BLOCK"
$fail.metadata.product_event_type = "4625"
$fail.metadata.event_timestamp.seconds < $success.metadata.event_timestamp.seconds
$success.metadata.event_type = "USER_LOGIN"
$success.metadata.vendor_name = "Microsoft"
$success.target.user.userid = $target_user
$success.principal.hostname = $hostname
$success.security_result.action = "ALLOW"
$success.metadata.product_event_type = "4624"
// Correlate with user entity data
$user.graph.entity.user.userid = $target_user
$user.graph.metadata.entity_type = "USER"
$user.graph.metadata.source_type = "ENTITY_CONTEXT"
// Can modify the following line to focus the rule on different user groups
any $user.graph.relations.entity.group.group_display_name = "Domain Admins"
// Correlate with asset entity data
$asset.graph.entity.asset.hostname = $hostname
$asset.graph.metadata.entity_type = "ASSET"
$asset.graph.metadata.source_type = "ENTITY_CONTEXT"
// Can modify the following line to focus the rule on different computer groups
any $asset.graph.relations.entity.group.group_display_name = "Domain Controllers"
match:
$target_user, $hostname over 15m
outcome:
//increment risk score if the system targeted is active directory server, can modify as you see fit, using this as an example
$risk_score = max(if($hostname = /activedir/, 75, 50))
$failed_login_threshold = 5
$impacted_systems = array_distinct($hostname)
$impacted_users = array_distinct($target_user)
$alert_type = "Successful Brute Force Attack"
$tlp = "red"
// added to populate alert graph with additional context
// Commented out principal.hostname because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$principal_hostname = array_distinct($success.principal.hostname)
$principal_ip = array_distinct($success.principal.ip)
$target_hostname = array_distinct($success.target.hostname)
$src_hostname = array_distinct($success.src.hostname)
$target_ip = array_distinct($success.target.ip)
$principal_user_userid = array_distinct($success.principal.user.userid)
// Commented out target.user.userid because it is already represented in graph as match variable. If match changes, can uncomment to add to results
//$target_user_userid = array_distinct($success.target.user.userid)
$principal_resource_name = array_distinct($success.principal.resource.name)
$target_resource_name = array_distinct($success.target.resource.name)
$target_url = array_distinct($success.target.url)
condition:
#fail > 4 and $success and $user and $asset
}
YARA-L Rule Structure
Condition
Fires when $fail occurs more than 4 times in the 15m window and at least one $success event in the 15m window and $user matches entity context and $asset matches entity context.
Events
$asset
graph.metadata.entity_type = "ASSET"graph.metadata.source_type = "ENTITY_CONTEXT"graph.relations.entity.group.group_display_name = "Domain Controllers"
$fail
security_result.action = "BLOCK"metadata.product_event_type = "4625"
$success
security_result.action = "ALLOW"metadata.product_event_type = "4624"
$user
graph.metadata.entity_type = "USER"graph.metadata.source_type = "ENTITY_CONTEXT"graph.relations.entity.group.group_display_name = "Domain Admins"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(if($hostname = /activedir/, 75, 50)) |
failed_login_threshold | 5 |
impacted_systems | array_distinct($hostname) |
impacted_users | array_distinct($target_user) |
principal_ip | array_distinct($success.principal.ip) |
target_hostname | array_distinct($success.target.hostname) |
src_hostname | array_distinct($success.src.hostname) |
target_ip | array_distinct($success.target.ip) |
principal_user_userid | array_distinct($success.principal.user.userid) |
principal_resource_name | array_distinct($success.principal.resource.name) |
target_resource_name | array_distinct($success.target.resource.name) |
target_url | array_distinct($success.target.url) |
sap hanadb audit trail policy changes
#Detects changes to SAP HANA audit policies (Create, Alter, Drop) which could indicate an attempt to evade logging.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Rule Body
// Copyright 2026 Google LLC. Licensed under Apache-2.0.
rule sap_hanadb_audit_trail_policy_changes {
meta:
author = "Google Cloud Security"
description = "Detects changes to SAP HANA audit policies (Create, Alter, Drop) which could indicate an attempt to evade logging."
severity = "High"
tactic = "TA0005"
technique = "T1562"
events:
$e.metadata.product_name = "SAP_HANA_AUDIT"
$statement = $e.additional.fields["executed_statement"]
$statement = /AUDIT\s+POLICY/ nocase
$user = $e.principal.user.user_display_name
match:
$user over 30m
outcome:
$risk_score = max(85)
$principal_user = array_distinct($user)
$statements = array_distinct($statement)
$system_id = array_distinct($e.target.resource.attribute.labels["system_id"])
$policy_name = array_distinct($e.security_result.rule_name)
condition:
$e
}
YARA-L Rule Structure
Condition
Fires when at least one $e event in the 30m window.
Events
$e
additional.fields["executed_statement"] matches "AUDIT\s+POLICY"
Match and Correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
risk_score | max(85) |
principal_user | array_distinct($user) |
statements | array_distinct($statement) |
system_id | array_distinct($e.target.resource.attribute.labels["system_id"]) |
policy_name | array_distinct($e.security_result.rule_name) |