rule impossible_travel_activity{
meta:
author = "Anurag Singh"
description = "Detects potential account compromise by identifying logon attempts from two different geo locations within a short span of time, indicating impossible travel between the locations."
severity = "High"
events:
$e1.metadata.event_type = "USER_LOGIN"
$e1.metadata.product_event_type = "UserLoggedIn"
$user = $e1.target.user.userid
$e1_lat = $e1.principal.location.region_coordinates.latitude
$e1_long = $e1.principal.location.region_coordinates.longitude
$location1 = $e1.principal.ip_geo_artifact.location.country_or_region
$e2.metadata.event_type = "USER_LOGIN"
$e2.metadata.product_event_type = "UserLoggedIn"
// match variables
$user = $e2.target.user.userid
$e2_lat = $e2.principal.location.region_coordinates.latitude
$e2_long = $e2.principal.location.region_coordinates.longitude
$location2 = $e2.principal.ip_geo_artifact.location.country_or_region
match:
$user over 1h
outcome:
$distance_kilometers = math.ceil(
max(math.geo_distance($e1_long, $e1_lat, $e2_long,$e2_lat)) / 1000
)
$risk_score = (
if($e1.principal.ip_geo_artifact.location.country_or_region != $e2.principal.ip_geo_artifact.location.country_or_region nocase, 90) +
if($distance_kilometers > 100 and $distance_kilometers <= 500, 20) +
if($distance_kilometers > 500 and $distance_kilometers <= 1000, 30) +
if($distance_kilometers > 1000, 50)
)
condition:
$e1 and $e2 and $risk_score >= 20
}
But the part where I am assigning the risk score is showing an error which says
validating intermediate representation: repeated values in outcome assignment must be aggregated
Can someone help me on this?