Hi community,
Our team is relatively new to the Yara rules, would highly appreciate any leads or pointers on how to achieve our requirements: we are trying to find 3 different country events from a single user in 24 hrs of time, on which we are excluding certain events in detection on condition that-
1. we don't want events from sequence window of 5 mins before "OpenID Connect Client" value
ex: if we have "session requested" and/or "session approved " and/or "session started" etc within 5 mins of event "OpenID Connect Client", then we shouldn't have the alert triggered
2. But if the "OpenID Connect Client" value is getting generated after 5 mins of any event , we need them to populate.
Ex: if we have "session requested" and/or "session approved " and/or "session started" etc and "OpenID Connect Client" after 5 min window - we should have an alert.
For added clarity -
a. session approved, session requested all generates before openID connect client event
b. we need to 2 match conditions - one for spanning in 24 hours rolling window and other one spanning for 5 mins window
rule okta_geo_hopping{
meta:
author = "ff"
description = "Detects when an user signing in from different countries in last 24hrs"
rule_id = "ff"
rule_name = "okta geo_hopping_"
reference = "test"
type = "Alert"
events:
$login.metadata.vendor_name = "Okta"
($login.metadata.product_event_type = "user.session.start" nocase or
$login.metadata.product_event_type = /user.authentication/ )
($login.extracted.fields["actor.alternateId"] != "Okta Dashboard" nocase or
$login.extracted.fields["actor.alternateId"] != "unknown" nocase or
$login.extracted.fields["actor.alternateId"] != "Okta Browser Plugin" nocase or
$login.extracted.fields["actor.alternateId"] != "xxy" nocase or
$login.extracted.fields["actor.alternateId"] != "xxt" nocase or
$login.extracted.fields["actor.alternateId"] != "Okta System" nocase)
$login.principal.user.userid = $userid
$t1.target.resource.name = "OpenID Connect Client"
$beforeopenID.target.resource.name= $allothervalue
match:
$allothervalue over 5m before $t1, $userid over 24h
outcome:
$target_user_agent = array_distinct($login.network.http.user_agent)
$principal_ip = array_distinct($login.principal.ip)
$principal_ip_city = array_distinct($login.principal.location.city)
$principal_user_email_addresses = array_distinct ($login.principal.user.email_addresses)
$country_count = count_distinct($login.principal.location.country_or_region)
$security_result_summary = array_distinct($login.security_result.summary)
condition:
($login and $beforeopenID and $t1) and $country_count > 2
}
This seem like a very challenging one our team, since we are new to Yara and chronicle - Any help is greatly appreciated.
thanks!