Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

App Gateway WAF - XSS Detection

Back
Id1c7ff502-2ad4-4970-9d29-9210c6753138
RulenameApp Gateway WAF - XSS Detection
DescriptionIdentifies a match for an XSS attack in the App Gateway WAF logs. The threshold value in the query can be changed as per your infrastructure’s requirements.

References: https://owasp.org/www-project-top-ten/2017/A7_2017-Cross-Site_Scripting_(XSS)
SeverityHigh
TacticsInitialAccess
Execution
TechniquesT1189
T1203
T0853
Required data connectorsWAF
KindScheduled
Query frequency6h
Query period6h
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Azure Web Application Firewall (WAF)/Analytic Rules/App-GW-WAF-XSSDetection.yaml
Version1.0.1
Arm template1c7ff502-2ad4-4970-9d29-9210c6753138.json
Deploy To Azure
let Threshold = 3;  
AzureDiagnostics
| where Category == "ApplicationGatewayFirewallLog"
| where action_s == "Matched"
| where Message has "XSS"
| extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)
| extend hostname_s = tostring(parse_json(AdditionalFields).hostname_s)
| project transactionId_g, hostname_s, requestUri_s, TimeGenerated, clientIp_s, Message
| join kind = inner(
AzureDiagnostics
| where Category == "ApplicationGatewayFirewallLog"
| where action_s == "Blocked"
| extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)) on transactionId_g
| extend Uri = strcat(hostname_s,requestUri_s)
| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), TransactionID = make_set(transactionId_g,100), Message = make_set(Message,100), Total_TransactionId = dcount(transactionId_g) by clientIp_s, Uri, action_s
| where Total_TransactionId >= Threshold
status: Available
triggerOperator: gt
triggerThreshold: 0
name: App Gateway WAF - XSS Detection
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Azure Web Application Firewall (WAF)/Analytic Rules/App-GW-WAF-XSSDetection.yaml
queryPeriod: 6h
severity: High
tags:
- Cross Site Scripting
kind: Scheduled
entityMappings:
- entityType: URL
  fieldMappings:
  - columnName: Uri
    identifier: Url
- entityType: IP
  fieldMappings:
  - columnName: clientIp_s
    identifier: Address
queryFrequency: 6h
relevantTechniques:
- T1189
- T1203
- T0853
requiredDataConnectors:
- dataTypes:
  - AzureDiagnostics
  connectorId: WAF
description: |
  'Identifies a match for an XSS attack in the App Gateway WAF logs. The threshold value in the query can be changed as per your infrastructure's requirements.
   References: https://owasp.org/www-project-top-ten/2017/A7_2017-Cross-Site_Scripting_(XSS)'  
tactics:
- InitialAccess
- Execution
query: |
  let Threshold = 3;  
  AzureDiagnostics
  | where Category == "ApplicationGatewayFirewallLog"
  | where action_s == "Matched"
  | where Message has "XSS"
  | extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)
  | extend hostname_s = tostring(parse_json(AdditionalFields).hostname_s)
  | project transactionId_g, hostname_s, requestUri_s, TimeGenerated, clientIp_s, Message
  | join kind = inner(
  AzureDiagnostics
  | where Category == "ApplicationGatewayFirewallLog"
  | where action_s == "Blocked"
  | extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)) on transactionId_g
  | extend Uri = strcat(hostname_s,requestUri_s)
  | summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), TransactionID = make_set(transactionId_g,100), Message = make_set(Message,100), Total_TransactionId = dcount(transactionId_g) by clientIp_s, Uri, action_s
  | where Total_TransactionId >= Threshold  
id: 1c7ff502-2ad4-4970-9d29-9210c6753138
version: 1.0.1
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/1c7ff502-2ad4-4970-9d29-9210c6753138')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/1c7ff502-2ad4-4970-9d29-9210c6753138')]",
      "properties": {
        "alertRuleTemplateName": "1c7ff502-2ad4-4970-9d29-9210c6753138",
        "customDetails": null,
        "description": "'Identifies a match for an XSS attack in the App Gateway WAF logs. The threshold value in the query can be changed as per your infrastructure's requirements.\n References: https://owasp.org/www-project-top-ten/2017/A7_2017-Cross-Site_Scripting_(XSS)'\n",
        "displayName": "App Gateway WAF - XSS Detection",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "URL",
            "fieldMappings": [
              {
                "columnName": "Uri",
                "identifier": "Url"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "clientIp_s",
                "identifier": "Address"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Azure Web Application Firewall (WAF)/Analytic Rules/App-GW-WAF-XSSDetection.yaml",
        "query": "let Threshold = 3;  \nAzureDiagnostics\n| where Category == \"ApplicationGatewayFirewallLog\"\n| where action_s == \"Matched\"\n| where Message has \"XSS\"\n| extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)\n| extend hostname_s = tostring(parse_json(AdditionalFields).hostname_s)\n| project transactionId_g, hostname_s, requestUri_s, TimeGenerated, clientIp_s, Message\n| join kind = inner(\nAzureDiagnostics\n| where Category == \"ApplicationGatewayFirewallLog\"\n| where action_s == \"Blocked\"\n| extend transactionId_g = tostring(parse_json(AdditionalFields).transactionId_g)) on transactionId_g\n| extend Uri = strcat(hostname_s,requestUri_s)\n| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), TransactionID = make_set(transactionId_g,100), Message = make_set(Message,100), Total_TransactionId = dcount(transactionId_g) by clientIp_s, Uri, action_s\n| where Total_TransactionId >= Threshold\n",
        "queryFrequency": "PT6H",
        "queryPeriod": "PT6H",
        "severity": "High",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Execution",
          "InitialAccess"
        ],
        "tags": [
          "Cross Site Scripting"
        ],
        "techniques": [
          "T1189",
          "T1203"
        ],
        "templateVersion": "1.0.1",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}