Detection rules › YARA-L
YARA-L rules: 11
| Rule | Severity |
|---|---|
| AWS IAM Administrator Access Policy Attached | high |
| Direct Autorun Keys Modification | medium |
| Office 365 logging is disabled | critical |
AWS IAM Administrator Access Policy Attached
#Detects when AWS IAM AdministratorAccess policy is attached to a user, group or role which can be used for privilege escalation.
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Initial Access | |
| Persistence | |
| Privilege Escalation | |
| Stealth |
Telemetry Coverage
Rule Body
// Copyright 2023 Google LLC. Licensed under Apache-2.0.
rule aws_iam_administrator_access_policy_attached {
meta:
author = "Google Cloud Security"
description = "Detects when AWS IAM AdministratorAccess policy is attached to a user, group or role which can be used for privilege escalation."
rule_id = "mr_52c6643b-f6ce-4299-9fb6-05554901800c"
rule_name = "AWS IAM Administrator Access Policy Attached"
mitre_attack_tactic = "Defense Evasion, Persistence, Privilege Escalation, Initial Access"
mitre_attack_technique = "Valid Accounts: Cloud Accounts"
mitre_attack_url = "https://attack.mitre.org/techniques/T1078/004/"
mitre_attack_version = "v13.1"
type = "Alert"
data_source = "AWS CloudTrail"
platform = "AWS"
severity = "High"
priority = "High"
events:
$cloudtrail.metadata.vendor_name = "AMAZON"
$cloudtrail.metadata.product_name = "AWS CloudTrail"
(
$cloudtrail.metadata.product_event_type = "AttachUserPolicy" or
$cloudtrail.metadata.product_event_type = "AttachGroupPolicy" or
$cloudtrail.metadata.product_event_type = "AttachRolePolicy"
)
$cloudtrail.target.resource.name = "arn:aws:iam::aws:policy/AdministratorAccess"
$cloudtrail.security_result.action = "ALLOW"
outcome:
$risk_score = max(75)
$mitre_attack_tactic = "Defense Evasion, Persistence, Privilege Escalation, Initial Access"
$mitre_attack_technique = "Valid Accounts: Cloud Accounts"
$mitre_attack_technique_id = "T1078.004"
$event_count = count_distinct($cloudtrail.metadata.id)
$network_http_user_agent = $cloudtrail.network.http.user_agent
$principal_ip = array_distinct($cloudtrail.principal.ip)
$principal_ip_country = array_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region)
$principal_ip_state = array_distinct($cloudtrail.principal.ip_geo_artifact.location.state)
$principal_user_display_name = $cloudtrail.principal.user.user_display_name
$recipient_aws_account_id = $cloudtrail.additional.fields["recipientAccountId"]
$aws_region = $cloudtrail.principal.location.name
$target_resource_name = $cloudtrail.target.resource.name
$target_resource_product_object_id = $cloudtrail.target.resource.product_object_id
condition:
$cloudtrail
}
YARA-L Rule Structure
Condition
Fires when at least one $cloudtrail event.
Events
$cloudtrail
metadata.product_event_typeis one of:AttachUserPolicyAttachGroupPolicyAttachRolePolicy
target.resource.name = "arn:aws:iam::aws:policy/AdministratorAccess"security_result.action = "ALLOW"
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(75) |
event_count | count_distinct($cloudtrail.metadata.id) |
network_http_user_agent | $cloudtrail.network.http.user_agent |
principal_ip | array_distinct($cloudtrail.principal.ip) |
principal_ip_country | array_distinct($cloudtrail.principal.ip_geo_artifact.location.country_or_region) |
principal_ip_state | array_distinct($cloudtrail.principal.ip_geo_artifact.location.state) |
principal_user_display_name | $cloudtrail.principal.user.user_display_name |
recipient_aws_account_id | $cloudtrail.additional.fields["recipientAccountId"] |
aws_region | $cloudtrail.principal.location.name |
target_resource_name | $cloudtrail.target.resource.name |
target_resource_product_object_id | $cloudtrail.target.resource.product_object_id |
Direct Autorun Keys Modification
#Detects direct modification of autostart extensibility point (ASEP) in registry using reg.exe
Known False Positives
- Legitimate software automatically sets up autorun keys for legitimate reasons
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Persistence |
References
Telemetry Coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 1: Process creation |
| Security-Auditing | Event ID 4688: A new process has been created. |
Rule Body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule direct_autorun_keys_modification {
meta:
author = "Victor Sergeev, Daniil Yugoslavskiy, oscd.community"
description = "Detects direct modification of autostart extensibility point (ASEP) in registry using reg.exe"
reference = "https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_reg_direct_asep_registry_keys_modification.yml"
license = "https://github.com/SigmaHQ/Detection-Rule-License/blob/main/LICENSE.Detection.Rules.md"
rule_name = "Direct Autorun Keys Modification"
rule_id = "mr_b031bea5-d00b-43ae-a74c-b4df380262e8"
sigma_uuid = "24357373-078f-44ed-9ac4-6d334a668a11"
sigma_status = "test"
tactic = "TA0003"
technique = "T1547.001"
type = "Detection"
data_source = "Windows Event Logs"
platform = "Windows"
severity = "Medium"
priority = "Medium"
false_positives = "Legitimate software automatically sets up autorun keys for legitimate reasons"
events:
$process.metadata.event_type = "PROCESS_LAUNCH"
re.regex($process.target.process.file.full_path, `\\reg\.exe$`) nocase
strings.contains(strings.to_lower($process.target.process.command_line), "add")
(
strings.contains(strings.to_lower($process.target.process.command_line), "\\software\\microsoft\\windows\\currentversion\\run") or
strings.contains(strings.to_lower($process.target.process.command_line), "\\software\\microsoft\\windows nt\\currentversion\\winlogon\\userinit") or
strings.contains(strings.to_lower($process.target.process.command_line), "\\software\\microsoft\\windows nt\\currentversion\\winlogon\\shell") or
strings.contains(strings.to_lower($process.target.process.command_line), "\\software\\microsoft\\windows nt\\currentversion\\windows") or
strings.contains(strings.to_lower($process.target.process.command_line), "\\software\\microsoft\\windows\\currentversion\\explorer\\user shell folders") or
strings.contains(strings.to_lower($process.target.process.command_line), "\\system\\currentcontrolset\\control\\safeboot\\alternateshell")
)
$process.principal.hostname = $hostname
match:
$hostname over 5m
outcome:
//example usage of specifying test user and hostname to adjust risk score
$risk_score = max(if($process.principal.user.userid = "user" and $process.principal.hostname = "hostname", 0, 15))
$principal_process_pid = array_distinct($process.principal.process.pid)
$principal_process_command_line = array_distinct($process.principal.process.command_line)
$principal_process_file_sha256 = array_distinct($process.principal.process.file.sha256)
$principal_process_file_full_path = array_distinct($process.principal.process.file.full_path)
$principal_process_product_specfic_process_id = array_distinct($process.principal.process.product_specific_process_id)
$principal_process_parent_process_product_specfic_process_id = array_distinct($process.principal.process.parent_process.product_specific_process_id)
$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_specfic_process_id = array_distinct($process.target.process.product_specific_process_id)
$principal_user_userid = array_distinct($process.principal.user.userid)
$log_type = array_distinct(strings.concat($process.metadata.log_type,"/",$process.metadata.product_event_type))
condition:
$process
}
YARA-L Rule Structure
Condition
Fires when at least one $process event in the 5m window.
Events
$process
target.process.file.full_path matches "\\reg\.exe$"target.process.command_line contains "add"target.process.command_line contains "\software\microsoft\windows\currentversion\run"target.process.command_line contains "\software\microsoft\windows nt\currentversion\winlogon\userinit"target.process.command_line contains "\software\microsoft\windows nt\currentversion\winlogon\shell"target.process.command_line contains "\software\microsoft\windows nt\currentversion\windows"target.process.command_line contains "\software\microsoft\windows\currentversion\explorer\user shell folders"target.process.command_line contains "\system\currentcontrolset\control\safeboot\alternateshell"
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($process.principal.user.userid = "user" and $process.principal.hostname = "hostname", 0, 15)) |
principal_process_pid | array_distinct($process.principal.process.pid) |
principal_process_command_line | array_distinct($process.principal.process.command_line) |
principal_process_file_sha256 | array_distinct($process.principal.process.file.sha256) |
principal_process_file_full_path | array_distinct($process.principal.process.file.full_path) |
principal_process_product_specfic_process_id | array_distinct($process.principal.process.product_specific_process_id) |
principal_process_parent_process_product_specfic_process_id | array_distinct($process.principal.process.parent_process.product_specific_process_id) |
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_specfic_process_id | array_distinct($process.target.process.product_specific_process_id) |
principal_user_userid | array_distinct($process.principal.user.userid) |
log_type | array_distinct(strings.concat($process.metadata.log_type,"/",$process.metadata.product_event_type)) |
Office 365 logging is disabled
#Detect when the Unified Audit Log is disabled
MITRE ATT&CK Coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Telemetry Coverage
| Platform | Record / event type |
|---|---|
| Microsoft 365 | Exchange audit operation Set-AdminAuditLogConfig: Federated domain added |
Rules Detecting the Same Action
These rules filter on the same operation.
- Office 365 logging has been enabled (YARA-L)
Rule Body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule o365_logging_disabled {
meta:
author = "Google Cloud Security"
description = "Detect when the Unified Audit Log is disabled"
rule_id = "mr_17a49d19-2ea1-4d7d-9e4d-bbc7ffb07099"
rule_name = "Office 365 logging is disabled"
assumption = "If logging is expected, there is no reason for this to be switched off. If it is disabled a gap in logging will occur."
tactic = "TA0005"
technique = "T1562.008"
type = "alert"
platform = "azure"
data_source = "o365"
severity = "Critical"
priority = "Critical"
events:
$log.metadata.event_type = "SETTING_CREATION"
$log.metadata.product_event_type = "Set-AdminAuditLogConfig"
$log.metadata.product_name = "Office 365"
$log.metadata.vendor_name = "Microsoft"
$log.security_result.detection_fields["UnifiedAuditLogIngestionEnabled"] = "False"
$log.principal.user.userid = $user
match:
$user over 5m
outcome:
$risk_score = 85
$event_count = count_distinct($log.metadata.id)
$referral_url = array_distinct($log.network.http.referral_url)
$user_agent = array_distinct($log.network.http.user_agent)
$principal_application = array_distinct($log.principal.application)
$principal_ip = array_distinct($log.principal.ip)
$target_application = array_distinct($log.target.application)
$principal_user_userid = array_distinct($log.principal.user.userid)
$session = array_distinct($log.network.session_id)
$location = array_distinct(strings.coalesce($log.principal.location.state,$log.principal.location.country_or_region))
$target_resource_resource_type = array_distinct($log.target.resource.resource_type)
$target_url = array_distinct($log.target.url)
condition:
$log
}
YARA-L Rule Structure
Condition
Fires when at least one $log event in the 5m window.
Events
$log
metadata.product_event_type = "Set-AdminAuditLogConfig"security_result.detection_fields["UnifiedAuditLogIngestionEnabled"] = "False"
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 | 85 |
event_count | count_distinct($log.metadata.id) |
referral_url | array_distinct($log.network.http.referral_url) |
user_agent | array_distinct($log.network.http.user_agent) |
principal_application | array_distinct($log.principal.application) |
principal_ip | array_distinct($log.principal.ip) |
target_application | array_distinct($log.target.application) |
principal_user_userid | array_distinct($log.principal.user.userid) |
session | array_distinct($log.network.session_id) |
location | array_distinct(strings.coalesce($log.principal.location.state,$log.principal.location.country_or_region)) |
target_resource_resource_type | array_distinct($log.target.resource.resource_type) |
target_url | array_distinct($log.target.url) |