39 Ueba Behaviors Ueba All Aws Behaviors And Insights
Query
// REVIEW ONLY - AWS Security Operations Workbook Visual Query
// Tab: UebaBehaviors | Panel: ueba-all-aws-behaviors-and-insights | Visualization: table | Mode: All
// Security Question: What aggregated or multi-step sequenced behaviors (and anomaly-on-behavior insights) occurred across our AWS accounts?
// Drill-Through: Inspect BehaviorId and AdditionalFields.SupportingEvidence to drill down to underlying AWSCloudTrail events.
// Empty/No-Data Contract: No AWS records in SentinelBehaviorInfo / BehaviorInfo yet. Enable Defender Portal -> Sentinel -> UEBA -> New! Behaviors layer -> AWS Cloud Trail.
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}");
let AwsBehaviors = union isfuzzy=true
(datatable(TimeGenerated:datetime, BehaviorId:string, Title:string, ActionType:string, Categories:string, AttackTechniques:string, DataSources:string, Description:string, Insights:string, AdditionalFields:string, AccountUpn:string)[]),
(SentinelBehaviorInfo | where TimeGenerated between (Start .. End)
| project TimeGenerated, BehaviorId, Title, ActionType, Categories, AttackTechniques, DataSources, Description, Insights, AdditionalFields, AccountUpn),
(BehaviorInfo | where TimeGenerated between (Start .. End) and ServiceSource == "Microsoft Sentinel"
| project TimeGenerated, BehaviorId, Title=tostring(column_ifexists("Title", ActionType)), ActionType, Categories, AttackTechniques, DataSources, Description, Insights=tostring(column_ifexists("Insights", "")), AdditionalFields, AccountUpn)
| where DataSources has_any ("AWS", "CloudTrail", "Amazon") or AdditionalFields has "AWSCloudTrail";
let AwsEntities = union isfuzzy=true
(datatable(BehaviorId:string, EntityType:string, EntityRole:string, CloudPlatform:string, CloudResource:string, CloudResourceType:string, CloudSubscriptionId:string, AccountName:string, RemoteIP:string)[]),
(SentinelBehaviorEntities | where TimeGenerated between (Start .. End)
| project BehaviorId, EntityType, EntityRole, CloudPlatform, CloudResource, CloudResourceType, CloudSubscriptionId, AccountName, RemoteIP),
(BehaviorEntities | where TimeGenerated between (Start .. End) and ServiceSource == "Microsoft Sentinel"
| project BehaviorId, EntityType, EntityRole, CloudPlatform="Amazon Web Services", CloudResource="", CloudResourceType="", CloudSubscriptionId="", AccountName, RemoteIP)
| summarize InvolvedEntities=make_set_if(strcat(EntityType, ":", coalesce(iff(isnotempty(CloudResource), CloudResource, ""), iff(isnotempty(AccountName), AccountName, ""), RemoteIP)), isnotempty(EntityType), 10),
AwsAccountIds=make_set_if(CloudSubscriptionId, isnotempty(CloudSubscriptionId), 5),
RemoteIps=make_set_if(RemoteIP, isnotempty(RemoteIP), 5)
by BehaviorId;
AwsBehaviors
| join kind=leftouter AwsEntities on BehaviorId
| extend Enrich = parse_json(AdditionalFields)["ueba.enrichments"]
| extend ServiceLayer = case(
ActionType has_any ("Vpc", "Gateway", "Route", "Network", "Mirror", "Subnet", "Peering", "FlowLogs", "RuleChange", "RemoteAccess"), "EC2 / VPC Network Layer",
ActionType has_any ("S3", "StorageLens", "ObjectLock"), "Amazon S3 Storage Layer",
ActionType has_any ("Secret", "Kms"), "Secrets Manager & KMS Layer",
ActionType has "EKS", "Amazon EKS Container Layer",
"AWS IAM, STS & Compute Layer"),
ExplainabilityBadges = strcat_delim(",",
iff(Insights has "FirstSeen", "FirstSeen", ""),
iff(Insights has "HighVolumeAnomaly", "HighVolumeAnomaly", ""),
iff(Insights has "UncommonValue", "UncommonValue", ""),
iff(Insights has "ThreatIntel", "ThreatIntel", ""))
| project TimeGenerated, ServiceLayer, Title, ActionType, ExplainabilityBadges,
Categories, AttackTechniques, AccountUpn, AwsAccountIds, RemoteIps,
IPLocation=tostring(Enrich.IPLocation), ISP=tostring(Enrich.ISP),
ThreatIntelType=tostring(Enrich.ThreatIntelIndicatorType),
InvolvedEntities, Description, BehaviorId
| order by isnotempty(ExplainabilityBadges) desc, TimeGenerated desc
| take 5000Explanation
This query is designed to analyze and display aggregated or multi-step behaviors and anomalies related to AWS accounts within a security operations context. Here's a simplified breakdown of what the query does:
-
Time and Filters Setup: It begins by setting up time ranges and various filters (like organization, account, region, environment, workload, severity, source, principal, and IP) using base64-decoded strings.
-
Data Collection:
- It gathers behavior data from two sources:
SentinelBehaviorInfoandBehaviorInfo, focusing on AWS-related activities (like AWS, CloudTrail, Amazon). - It also collects entity data related to these behaviors from
SentinelBehaviorEntitiesandBehaviorEntities.
- It gathers behavior data from two sources:
-
Data Processing:
- The query combines behavior and entity data, linking them via
BehaviorId. - It enriches the data with additional fields and categorizes actions into different AWS service layers (like EC2/VPC Network Layer, Amazon S3 Storage Layer, etc.).
- It identifies and labels behaviors with specific insights (e.g., FirstSeen, HighVolumeAnomaly, UncommonValue, ThreatIntel).
- The query combines behavior and entity data, linking them via
-
Output:
- The query projects relevant fields such as time, service layer, title, action type, categories, attack techniques, account information, involved entities, and descriptions.
- It orders the results by the presence of explainability badges and time, showing the most recent and significant behaviors first.
- Finally, it limits the output to 5000 records.
This query helps security analysts understand complex behaviors and anomalies across AWS accounts, providing insights into potential security threats or unusual activities.