37 Ueba Behaviors Ueba Cloudtrail Guardduty Priority
Query
// REVIEW ONLY - AWS Security Operations Workbook Visual Query
// Tab: UebaBehaviors | Panel: ueba-cloudtrail-guardduty-priority | Visualization: table | Mode: All
// Security Question: Which AWS CloudTrail sign-ins or GuardDuty-flagged identities received high UEBA InvestigationPriority scores?
// Drill-Through: Click Actor to populate SelectedPrincipal and inspect Tab 10 Cross-Cloud Entra/XDR Pivot.
// Empty/No-Data Contract: No AWS records in BehaviorAnalytics in this window (verify AWS Cloud Trail and AWS Guard Duty are enabled in Sentinel -> UEBA).
let Start = {TimeRange:start};
let End = {TimeRange:end};
let OrgFilter = base64_decode_tostring("{Organization:base64}");
let AccountFilter = base64_decode_tostring("{AwsAccount:base64}");
let RegionFilter = base64_decode_tostring("{AwsRegion:base64}");
let EnvFilter = base64_decode_tostring("{Environment:base64}");
let WorkloadFilter = base64_decode_tostring("{Workload:base64}");
let SeverityFilter = base64_decode_tostring("{Severity:base64}");
let SourceFilter = base64_decode_tostring("{SourceTable:base64}");
let SummaryPref = base64_decode_tostring("{SummaryMode:base64}");
let SelectedPrincipalFilter = base64_decode_tostring("{SelectedPrincipal:base64}");
let SelectedIpFilter = base64_decode_tostring("{SelectedIp:base64}");
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 AWS security events, specifically focusing on sign-ins and identities flagged by AWS GuardDuty that have received high User and Entity Behavior Analytics (UEBA) InvestigationPriority scores. Here's a simplified breakdown of what the query does:
-
Time Range and Filters: It sets a time range and applies various filters for organization, account, region, environment, workload, severity, source table, summary mode, selected principal, and selected IP. These filters are decoded from base64 strings.
-
Data Sources: The query pulls data from AWS CloudTrail and AWS GuardDuty logs, focusing on events related to these services.
-
Event Filtering: It filters events to include only those from AWS CloudTrail or AWS GuardDuty, or where the event source or vendor is related to AWS.
-
Data Processing:
- It identifies the source of the event as either "AWS GuardDuty UEBA" or "AWS CloudTrail UEBA (ConsoleLogin)".
- It determines the actor involved in the event by checking various fields for user or actor names.
- It extracts insights such as whether the user connected from a new country, if the action is uncommon among peers, and the blast radius of the event.
-
Priority Levels: The query assigns a priority level to each event based on the InvestigationPriority 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: It projects relevant fields, orders the results by priority and time, and limits the output to 5000 records.
-
Drill-Through: Users can click on an actor to further investigate in another tab, focusing on cross-cloud security insights.
-
Empty Data Handling: If no records are found, it suggests verifying that AWS CloudTrail and GuardDuty are enabled in Sentinel's UEBA.
In summary, this query helps security analysts identify and prioritize AWS security events that require immediate attention based on behavioral analytics scores.