07 Aws Alert List
Query
// REVIEW ONLY workbook query: 3.2 Deduplicated AWS Security Alerts & Extracted Entities
let Start = {TimeRange:start};
let End = {TimeRange:end};
let AlertScope = base64_decode_tostring("{AlertScope:base64}");
let KnownAwsNames = dynamic(["AWSCloudTrail - Successful API executed from a Tor exit node","AWSCloudTrail - Changes to internet facing AWS RDS Database instances","AWSCloudTrail - Changes to Amazon VPC settings","AWSCloudTrail - Failed Attempts to Change AWS CloudTrail Logs","AWSCloudTrail - Login to AWS Management Console without MFA","AWSCloudTrail - CloudFormation policy created then used for privilege escalation","AWSCloudTrail - Creation of CRUD DynamoDB policy and then privilege escalation","AWSCloudTrail - Creation of new CRUD IAM policy and then privilege escalation","AWSCloudTrail - Creation of CRUD KMS policy and then privilege escalation","AWSCloudTrail - Creation of CRUD Lambda policy and then privilege escalation","AWSCloudTrail - Created CRUD S3 policy and then privilege escalation","AWSCloudTrail - Creation of DataPipeline policy and then privilege escalation","AWSCloudTrail - Creation of EC2 policy and then privilege escalation","AWSCloudTrail - Creation of Glue policy and then privilege escalation","AWSCloudTrail - Creation of Lambda policy and then privilege escalation","AWSCloudTrail - Creation of SSM policy and then privilege escalation","AWSCloudTrail - Creating keys with encrypt policy without MFA","AWSCloudTrail - Monitor AWS Credential abuse or hijacking","AWSCloudTrail - EC2 Startup Shell Script Changed","AWSCloudTrail - ECR image scan findings high or critical","AWSCloudTrail - Amazon ECR image scanning disabled","AWSCloudTrail - Full Admin policy created and then attached to Roles, Users or Groups","AWSCloudTrail - AWS GuardDuty detector disabled or suspended","AWSGuardDuty - GuardDuty Alert","AWSCloudTrail - Changes to AWS Security Group ingress and egress settings","AWSCloudTrail - Changes to AWS Elastic Load Balancer security groups","AWSCloudTrail - Successful Tampering with AWS CloudTrail Logs","AWSCloudTrail - Network ACL with all the open ports to a specified CIDR","AWSCloudTrail - Suspicious overly permissive KMS key policy created","AWSCloudTrail - Privilege escalation with AdministratorAccess managed policy","AWSCloudTrail - Privilege escalation with admin managed policy","AWSCloudTrail - Privilege escalation with FullAccess managed policy","AWSCloudTrail - Privilege escalation via CloudFormation policy","AWSCloudTrail - Privilege escalation via CRUD DynamoDB policy","AWSCloudTrail - Privilege escalation via CRUD IAM policy","AWSCloudTrail - Privilege escalation via CRUD KMS policy","AWSCloudTrail - Privilege escalation via CRUD Lambda policy","AWSCloudTrail - Privilege escalation via CRUD S3 policy","AWSCloudTrail - Privilege escalation via DataPipeline policy","AWSCloudTrail - Privilege escalation via EC2 policy","AWSCloudTrail - Privilege escalation via Glue policy","AWSCloudTrail - Privilege escalation via Lambda policy","AWSCloudTrail - Privilege escalation via SSM policy","AWSCloudTrail - RDS instance publicly exposed","AWSCloudTrail - Successful brute force attack on S3 Bucket","AWSCloudTrail - S3 bucket access point publicly exposed","AWSCloudTrail - S3 bucket exposed via ACL","AWSCloudTrail - S3 bucket exposed via policy","AWSCloudTrail - S3 Object Exfiltration from Anonymous User","AWSCloudTrail - S3 object publicly exposed","AWSCloudTrail - S3 bucket suspicious ransomware activity","AWSCloudTrail - SAML update identity provider","AWSCloudTrail - Policy version set to default","AWSCloudTrail - SSM document is publicly exposed","AWSCloudTrail - Suspicious command sent to EC2","AWSCloudTrail - Unauthorized EC2 Instance Setup Attempt","AWSCloudTrail - Creation of Access Key for IAM User","AWSCloudTrail - User IAM Enumeration","AWSCloudTrail - NRT Login to AWS Management Console without MFA","AWSCloudTrail - Suspicious AWS CLI Command Execution","AWSCloudTrail - Suspicious AWS EC2 Compute Resource Deployments","AWS Security Hub - Detect CloudTrail trails lacking KMS encryption","AWS Security Hub - Detect EC2 Security groups allowing unrestricted high-risk ports","AWS Security Hub - Detect IAM Policies allowing full administrative privileges","AWS Security Hub - Detect root user lacking MFA","AWS Security Hub - Detect IAM root user Access Key existence","AWS Security Hub - Detect SQS Queue lacking encryption at rest","AWS Security Hub - Detect SQS Queue policy allowing public access","AWS Security Hub - Detect SSM documents public sharing enabled","AWS cross-cloud - Risky Entra identity pivots from log searches to secrets","AWS cross-cloud - ScreenConnect-launched AWS secret retrieval","AWS cross-cloud - Python startup artifacts and metadata access precede secrets use","AWS cross-cloud - PHP descendant contacts metadata before EC2 role secrets use","AWS cross-cloud - New Entra workload source also retrieves AWS secrets","AWS cross-cloud - AWS secrets use precedes Entra application credential change","AWS SecOps P0-01 - Root or Break-Glass Runtime Activity and Escalation","AWS SecOps P0-02 - Coordinated IAM Credential Persistence and Cross-Principal Backdooring","AWS SecOps P0-03 - Trust Policy Backdoor, Inline Escalation and Sensitive PassRole Abuse","AWS SecOps P0-04 - Autonomous Cross-Account or Sensitive STS AssumeRole Chain","AWS SecOps P0-05 - CloudTrail Selector Downgrade and Logging Delivery Tampering","AWS SecOps P0-06a - GuardDuty High Severity Prioritized Baseline (Single-Source)","AWS SecOps P0-06b - GuardDuty Correlated with CloudTrail Mutations, VPC Egress and Entra Bridge","AWS SecOps P0-07a - S3 PublicAccessBlock Weakening and Sensitive Bucket Burst Read (Single-Source)","AWS SecOps P0-07b - S3 Exfiltration GuardDuty Finding Correlated with Permission Change or VPC Egress","AWS SecOps P0-08 - AWS Connector Failure, Ingestion Lag and Per-Source Blind Spot","AWS SecOps P1-01a - Route 53 DNS Tunneling, Subdomain Fan-Out and High NXDOMAIN Ratio (Single-Source)","AWS SecOps P1-01b - Route 53 Queries Matching Threat Intel and Correlated VPC Egress","AWS SecOps P1-02 - AWS WAF Attack Campaign and Block-to-Allow Bypass Candidate","AWS SecOps P1-03a - VPC Flow Port/Host Scan and High-Byte Rare-Port Egress (Single-Source)","AWS SecOps P1-03b - VPC Flow Threat-Intel IP Egress and Low-Jitter Beaconing","AWS SecOps P1-04a - EKS Audit Pod Exec, Privileged Workload and Cluster-Admin Escalation (Single-Source)","AWS SecOps P1-04b - EKS Audit Risk Correlated with GuardDuty Container Findings or CloudTrail EKS Role Changes","AWS SecOps P1-05 - CloudFront Signed-URL Abuse, Path Enumeration and Automation Anomaly","AWS SecOps P2-01a - AWS Network Firewall High-Severity Alert and Allowed Threat Signature (Single-Source)","AWS SecOps P2-01b - AWS Network Firewall Correlated with VPC Flow, GuardDuty and IAM Changes"]);
let RawExtraAwsNames = todynamic(base64_decode_tostring("{AdditionalAwsAlertNames:base64}"));
let ExtraAwsNames = iff(isnotnull(array_length(RawExtraAwsNames)), RawExtraAwsNames, dynamic([]));
let AwsAlerts = union isfuzzy=true
(datatable(TimeGenerated:datetime, SystemAlertId:string, AlertName:string, AlertSeverity:string,
ProductName:string, ProviderName:string, Status:string, StartTime:datetime, EndTime:datetime,
Entities:string, ExtendedProperties:string)[]),
(SecurityAlert
| where TimeGenerated between (Start .. End)
| project TimeGenerated, SystemAlertId, AlertName, AlertSeverity, ProductName, ProviderName,
Status, StartTime, EndTime, Entities, ExtendedProperties)
| extend Ext=parse_json(ExtendedProperties)
| extend ClassificationBasis=case(
tostring(Entities) matches regex @"arn:aws[a-z-]*:", "AWS ARN in alert entities",
AlertName in (KnownAwsNames) or AlertName in (ExtraAwsNames), "Reviewed AWS alert name",
tostring(Ext.Query) has_any ("AWSCloudTrail", "AWSGuardDuty", "AWSVPCFlow", "AWSRoute53Resolver", "AWSWAF"), "Alert query references AWS table",
ProductName has_any ("GuardDuty", "AWS"), "AWS-related alert product",
AlertName has "AWS", "AWS name candidate: verify affected environment",
"Unclassified workspace alert")
| where AlertScope == "All" or ClassificationBasis != "Unclassified workspace alert"
| summarize arg_max(TimeGenerated, *) by SystemAlertId;
AwsAlerts
| project TimeGenerated, AlertSeverity, AlertName, ProductName, ProviderName,
Status, StartTime, EndTime, ClassificationBasis, SystemAlertId, Evidence=Entities
| order by TimeGenerated desc
| take 5000Explanation
This query is designed to review and extract AWS security alerts from a data source, focusing on deduplicating and classifying them based on specific criteria. Here's a simplified breakdown of what the query does:
-
Time Range and Alert Scope: It sets a time range (
StartandEnd) and decodes the alert scope from a base64 string to determine which alerts to include. -
Known and Additional Alert Names: It defines a list of known AWS alert names (
KnownAwsNames) and decodes any additional alert names from a base64 string (ExtraAwsNames). -
Data Collection: It gathers alerts from a data table or a
SecurityAlerttable within the specified time range. The alerts are projected with specific fields such asTimeGenerated,SystemAlertId,AlertName, etc. -
Classification: Each alert is classified based on certain conditions:
- If the alert entities contain an AWS ARN.
- If the alert name matches any known or additional AWS alert names.
- If the alert query references AWS-related tables.
- If the product name indicates an AWS-related alert.
- If the alert name contains "AWS", suggesting it might be AWS-related.
-
Filtering: Alerts are filtered based on the
AlertScopeand classification, excluding those classified as "Unclassified workspace alert" unless the scope is "All". -
Deduplication and Summarization: The query deduplicates alerts by taking the most recent entry (
arg_max) for eachSystemAlertId. -
Projection and Ordering: It projects the final set of fields for each alert, orders them by the time they were generated in descending order, and limits the result to the top 5000 alerts.
In essence, this query processes AWS security alerts to identify, classify, and deduplicate them, providing a streamlined view of the most relevant alerts within a specified time frame.