Query Details

P2 01a Network Firewall Alert Baseline

Query

// Standalone KQL for Analytic Rule: AWS SecOps P2-01a - AWS Network Firewall High-Severity Alert and Allowed Threat Signature (Single-Source)
// Rule File: analytics/P2-01a-network-firewall-alert-baseline.yaml | Rule ID: REPLACE_WITH_RULE_GUID | Severity: High
// Schedule: 15m / Lookback: 1h | REVIEW ONLY - Do not deploy/schedule without approval.
// REVIEW ONLY. Validate AWSNetworkFirewallAlert schema via discovery/D08 first.
let SuppressedSignatures = _GetWatchlist('AWS_TrustedDomainsAndScanners')
| where tolower(tostring(column_ifexists("Verified", ""))) == "true" and tostring(column_ifexists("PatternType", "")) == "SuricataSid"
| project tostring(column_ifexists("IndicatorValue", ""));
let FirewallMap = _GetWatchlist('AWS_CriticalAssets')
| where tolower(tostring(column_ifexists("Verified", ""))) == "true" and tostring(column_ifexists("ResourceType", "")) == "NetworkFirewall"
| project FirewallKey=tolower(tostring(column_ifexists("ResourceIdOrName", ""))), AWSAccountId=tostring(column_ifexists("AWSAccountId", "")),
    VpcId=tostring(column_ifexists("VpcId", "")), Environment=tostring(column_ifexists("Environment", ""));
AWSNetworkFirewallAlert
| where TimeGenerated > ago(1h) and ingestion_time() > ago(15m)
| where SignatureId !in (SuppressedSignatures)
| where Severity in ("1", "2", "High", "Critical") or AlertAction =~ "allowed" or VerdictAction =~ "pass"
| extend FirewallKey = tolower(FirewallName)
| join kind=leftouter FirewallMap on FirewallKey
| summarize TimeGenerated=min(TimeGenerated), HitCount=count(), SampleSni=take_any(Sni),
    Categories=make_set(Category, 5), Verdicts=make_set(VerdictAction, 5)
    by FirewallName, AvailabilityZone, SrcIp, DestIp, DestPort, Proto, SignatureId, Signature,
       Severity, AWSAccountId=coalesce(AWSAccountId, "MapFirewallInWatchlist"),
       VpcId=coalesce(VpcId, "MapFirewallInWatchlist")
| extend HitCountStr = tostring(HitCount),
    VerdictSummary = tostring(Verdicts)
| project TimeGenerated, AWSAccountId, VpcId, FirewallName, AvailabilityZone,
    SourceIpAddress=SrcIp, DestinationIpAddress=DestIp, DestPort, Proto,
    SignatureId, Signature, Severity, SampleSni, HitCountStr, VerdictSummary

Explanation

This KQL query is designed to analyze AWS Network Firewall alerts, focusing on high-severity alerts and allowed threat signatures from a single source. Here's a simplified breakdown of what the query does:

  1. Suppressed Signatures List: It retrieves a list of trusted domains and scanners from a watchlist, filtering for verified entries with a specific pattern type ("SuricataSid").

  2. Firewall Map: It creates a map of critical network firewall assets from another watchlist, filtering for verified entries and extracting relevant details like AWS account ID, VPC ID, and environment.

  3. Filter Alerts: It queries the AWSNetworkFirewallAlert table for alerts generated in the last hour and ingested in the last 15 minutes. It excludes alerts with signature IDs found in the suppressed signatures list.

  4. Severity and Action Filtering: It filters alerts based on severity levels ("1", "2", "High", "Critical") or if the alert action is "allowed" or the verdict action is "pass".

  5. Join with Firewall Map: It joins the filtered alerts with the firewall map to enrich the data with additional context like AWS account ID and VPC ID.

  6. Summarize Data: It summarizes the data by various fields (e.g., firewall name, source and destination IPs, signature ID) and calculates metrics such as the earliest time generated, hit count, and unique categories and verdicts.

  7. Format Output: It formats the output to include relevant details such as time generated, AWS account ID, VPC ID, firewall name, IP addresses, port, protocol, signature details, severity, sample SNI, hit count, and a summary of verdicts.

This query is intended for review only and should not be deployed or scheduled without approval. It is also advised to validate the AWSNetworkFirewallAlert schema before using this query.