32 Ueba Aws Anomalies Detected
Query
// REVIEW ONLY workbook query: 9.4 AWS Anomalies Detected from Sentinel UEBA & 21-Day ML Engine (`Anomalies` Table)
let Start = {TimeRange:start};
let End = {TimeRange:end};
union isfuzzy=true
(datatable(TimeGenerated:datetime, RuleStatus:string, Score:real, AnomalyTemplateName:string, RuleName:string, UserPrincipalName:string, UserName:string, SourceIpAddress:string, SourceLocation:dynamic, Tactics:string, Techniques:string, Description:string, AnomalyReasons:dynamic, AnomalyDetails:dynamic, Entities:dynamic)[]),
(Anomalies | where TimeGenerated between (Start .. End)
| project TimeGenerated, RuleStatus, Score=todouble(Score), AnomalyTemplateName, RuleName, UserPrincipalName, UserName, SourceIpAddress, SourceLocation=todynamic(SourceLocation), Tactics, Techniques, Description, AnomalyReasons=todynamic(AnomalyReasons), AnomalyDetails=todynamic(AnomalyDetails), Entities=todynamic(Entities))
| where AnomalyTemplateName has_any ("AwsCloudTrail", "AWS", "GuardDuty")
or RuleName has_any ("AwsCloudTrail", "AWS", "GuardDuty")
or Description has_any ("AWS CloudTrail", "AWS GuardDuty", "AWS Security Token Service", "AWS Secrets Manager")
| extend AwsAnomalyDomain = case(
AnomalyTemplateName has "GuardDuty" or RuleName has "GuardDuty", "🔴 AWS GuardDuty UEBA Anomaly",
AnomalyTemplateName has "AssumeRole", "🟠AWS STS AssumeRole UEBA Anomaly",
AnomalyTemplateName has "Secret" or AnomalyTemplateName has "KMS", "🔴 AWS Secrets/KMS UEBA Anomaly",
AnomalyTemplateName has "Privilege" or AnomalyTemplateName has "IAM", "🔴 AWS IAM Privilege UEBA Anomaly",
AnomalyTemplateName has "Federated" or AnomalyTemplateName has "SAML", "🟠AWS Federated/SAML UEBA Anomaly",
AnomalyTemplateName has "Logon", "🟠AWS ConsoleLogin UEBA Anomaly",
"🟡 AWS 21-Day ML Volume Anomaly"),
Actor = coalesce(iff(isnotempty(UserPrincipalName), UserPrincipalName, ""), UserName)
| project TimeGenerated, AwsAnomalyDomain, RuleStatus, Score=round(Score, 2),
AnomalyName=coalesce(iff(isnotempty(AnomalyTemplateName), AnomalyTemplateName, ""), RuleName),
Actor, SourceIpAddress, SourceLocation, Tactics, Techniques, Description, AnomalyReasons, Entities
| order by Score desc, TimeGenerated desc
| take 5000Explanation
This query is designed to analyze and summarize AWS-related anomalies detected by Microsoft's Sentinel User and Entity Behavior Analytics (UEBA) and a 21-day machine learning engine. Here's a simplified breakdown of what the query does:
-
Time Range Setup: It defines a start and end time for the data analysis based on a specified time range.
-
Data Collection: It combines data from two sources:
- An empty datatable with a specified schema (used for structure).
- The
Anomaliestable, filtered to include only records within the specified time range.
-
Filtering: It filters the anomalies to include only those related to AWS services, specifically those involving CloudTrail, GuardDuty, Security Token Service, and Secrets Manager.
-
Classification: It categorizes each anomaly into a specific domain based on its characteristics, such as:
- AWS GuardDuty anomalies
- AWS STS AssumeRole anomalies
- AWS Secrets/KMS anomalies
- AWS IAM Privilege anomalies
- AWS Federated/SAML anomalies
- AWS ConsoleLogin anomalies
- General AWS 21-Day ML Volume anomalies
-
Actor Identification: It identifies the user associated with the anomaly, prioritizing
UserPrincipalNameand falling back toUserNameif necessary. -
Data Projection: It selects and formats specific fields for output, including the time of the anomaly, its domain, status, score, name, actor, source IP, location, tactics, techniques, description, reasons, and entities involved.
-
Sorting and Limiting: It orders the results by the anomaly score (highest first) and time (most recent first), and limits the output to the top 5000 records.
In summary, this query is used to identify, categorize, and prioritize AWS-related security anomalies detected by Sentinel, providing a focused view of potential security issues within a specified time frame.