31 Ueba Cloudtrail Guardduty Priority
Query
// REVIEW ONLY workbook query: 9.3 Classic UEBA High-Priority Events — AWS CloudTrail & AWS GuardDuty (`BehaviorAnalytics`)
let Start = {TimeRange:start};
let End = {TimeRange:end};
union isfuzzy=true
(datatable(TimeGenerated:datetime, NativeTableName:string, EventSource:string, EventVendor:string, ActivityType:string, ActionType:string, InvestigationPriority:int, UserPrincipalName:string, ActorPrincipalName:string, UserName:string, ActorName:string, SourceIPAddress:string, SourceIPLocation:string, ActivityInsights:dynamic, UsersInsights:dynamic, SourceRecordId:string)[]),
(BehaviorAnalytics | where TimeGenerated between (Start .. End)
| project TimeGenerated, NativeTableName, EventSource, EventVendor, ActivityType, ActionType, InvestigationPriority=toint(InvestigationPriority), UserPrincipalName, ActorPrincipalName, UserName, ActorName, SourceIPAddress, SourceIPLocation, ActivityInsights=todynamic(ActivityInsights), UsersInsights=todynamic(UsersInsights), SourceRecordId)
| where NativeTableName in ("AWSCloudTrail", "AWSGuardDuty")
or EventSource has_any ("AWS", "CloudTrail", "GuardDuty")
or EventVendor has_any ("AWS", "Amazon")
| extend AwsSource = case(
NativeTableName == "AWSGuardDuty" or EventSource has "GuardDuty", "AWS GuardDuty UEBA",
"AWS CloudTrail UEBA (ConsoleLogin)"),
Actor = coalesce(
iff(isnotempty(UserPrincipalName), UserPrincipalName, ""),
iff(isnotempty(ActorPrincipalName), ActorPrincipalName, ""),
iff(isnotempty(UserName), UserName, ""),
ActorName),
BlastRadius = tostring(UsersInsights.BlastRadius),
IsNewCountry = tostring(ActivityInsights.FirstTimeUserConnectedFromCountry),
UncommonForPeers = tostring(ActivityInsights.ActionUncommonlyPerformedAmongPeers),
PriorityLevel = case(
InvestigationPriority >= 7, "🔴 CRITICAL - Immediate Review",
InvestigationPriority >= 4, "🟠 HIGH - Elevated Deviation",
InvestigationPriority >= 1, "🟡 Medium - Baseline Deviation",
"🟢 Low - Routine")
| project TimeGenerated, PriorityLevel, AwsSource, InvestigationPriority, Actor, ActivityType, ActionType,
SourceIPAddress, SourceIPLocation, IsNewCountry, UncommonForPeers, BlastRadius,
ActivityInsights, UsersInsights, SourceRecordId
| order by InvestigationPriority desc, TimeGenerated desc
| take 5000Explanation
This query is designed to analyze and prioritize high-priority security events from AWS CloudTrail and AWS GuardDuty using User and Entity Behavior Analytics (UEBA). Here's a simplified breakdown:
-
Time Range: The query examines events within a specified time range (
StarttoEnd). -
Data Sources: It pulls data from AWS CloudTrail and AWS GuardDuty logs.
-
Filtering: It filters events to include only those from AWS-related sources, specifically focusing on CloudTrail and GuardDuty.
-
Data Processing:
- Event Categorization: Events are categorized as either "AWS GuardDuty UEBA" or "AWS CloudTrail UEBA (ConsoleLogin)" based on their source.
- Actor Identification: It identifies the actor involved in the event using various user-related fields.
- Insights Extraction: It extracts insights such as whether the event occurred from a new country, if the action is uncommon among peers, and the potential impact (blast radius).
-
Priority Assignment: Events are assigned a priority level based on their investigation priority score:
- 🔴 CRITICAL for scores 7 and above
- 🟠 HIGH for scores between 4 and 6
- 🟡 Medium for scores between 1 and 3
- 🟢 Low for scores below 1
-
Output: The query outputs a list of up to 5000 events, sorted by priority and time, showing key details such as time, priority level, source, actor, activity type, IP address, location, and insights.
This query helps security analysts quickly identify and focus on the most critical security events in their AWS environment.