Free plan available. Set up in minutes with the collectors you already use. Start free
Logthread

Guide

Azure WAF management

Beta. Logthread reads your Azure Application Gateway web application firewall (WAF_v2 and its WAF policies) and helps it work well:

  • Coverage: every gateway and WAF policy, with its tier, mode, rule sets and whether its firewall log reaches Logthread, and what to fix.
  • Tuning: which rules block real users, as false-positive candidates checked on your own traffic, each with a preview of what a fix would have changed.
  • Detection to Prevention: what Prevention mode would block, and a checklist of what to clear first.
  • Reporting: WAF posture in the threat report, PCI DSS 6.4.2 evidence, and a detection when a policy is switched to Detection or disabled.

Logthread never changes your WAF. It reads with a custom Azure role that has no write action. Every fix is offered as Azure CLI commands, a Terraform block and a Bicep fragment for you to apply, after an approval in Logthread. Logthread then notices when your policy matches and marks the change applied by you.

Logthread is never in the request path, so it cannot slow down or take down your site.

Find it under Security → WAF in the app. Front Door WAF policies follow later.

1. The app registration#

Logthread signs in to Azure Resource Manager with an app registration in your tenant (client credentials). If you already connected Microsoft Entra ID or Microsoft 365, use the same app and secret: no Microsoft Graph permission is needed for this.

Otherwise, in the Microsoft Entra admin center: Identity, Applications, App registrations, New registration. Then Certificates & secrets, New client secret. Copy its Value and the expiry date. Logthread stores the secret encrypted, and Home reminds you 30 days before it expires.

Go to Integrations, choose Azure WAF management, and enter:

  • the Directory (tenant) ID and Application (client) ID from the app's Overview page;
  • the client secret and its expiry date;
  • the subscription IDs to read (comma separated, up to 20).

2. Create the read-only role#

The setup page shows the role with your subscription ids filled in. It reads, and nothing else:

{"Name": "Logthread WAF reader", "IsCustom": true,
 "Actions": ["Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/read",
             "Microsoft.Network/applicationGateways/read",
             "Microsoft.Network/frontDoorWebApplicationFirewallPolicies/read",
             "Microsoft.Cdn/profiles/read",
             "Microsoft.Cdn/profiles/securityPolicies/read",
             "Microsoft.Insights/diagnosticSettings/read",
             "Microsoft.Insights/eventtypes/values/read",
             "Microsoft.Resources/subscriptions/resourceGroups/read",
             "Microsoft.Resources/deployments/read",
             "Microsoft.ResourceGraph/resources/read"],
 "NotActions": [], "AssignableScopes": ["/subscriptions/<id>"]}

Create it with az role definition create --role-definition @logthread-waf-reader.json, signed in as an Owner or User Access Administrator.

3. Assign it to the app#

az role assignment create --assignee <application (client) id> --role "Logthread WAF reader" --scope /subscriptions/<id>

Run it once per subscription. With many subscriptions, assign it once at a management group and put that scope in AssignableScopes. Role assignments can take a few minutes to apply.

4. Check access#

Choose Test connection on the integration's page. Logthread signs in and reads your gateways and WAF policies once, now. A missing permission is named, for example "The Logthread WAF reader role is missing the permission Microsoft.Network/applicationGateways/read".

After that Logthread reads every 15 minutes:

  • Inventory from Azure Resource Graph. When Resource Graph cannot be read, it lists each subscription's gateways and policies instead. A policy Resource Graph returns without its mode or rule sets is read with its own GET; one still missing them is shown as read in part.
  • Each policy's version. A policy that changed since the last read is kept as a new version with what changed (400 days), and shown as changed outside Logthread.
  • Diagnostic settings of each gateway: whether its firewall log is sent anywhere.

5. Send the WAF log#

Coverage and the analysis read two Application Gateway logs from your Azure integration (Event Hub and the Logthread Agent):

  • ApplicationGatewayFirewallLog, the WAF's own log;
  • ApplicationGatewayAccessLog, every request. It tells returning users from attackers, and shows which addresses got normal answers.

Turn on the Azure security parser first: under the Azure integration's Then add, choose Use parser: Azure role assignments and Key Vault (it also reads Application Gateway WAF logs). Azure logs the value each rule matched in clear text, in details.data. The parser:

  • drops details.data and details.message, after keeping the matched variable's name (waf.matched_var, for example ARGS:q) and the value's shape (waf.value_shape: a length bucket and the character classes, for example 16-63 alpha,digit,quote,operator), never the value;
  • keeps only the path of requestUri (url.path), and drops requestQuery and originalRequestUriWithArgs from access log records;
  • replaces a custom rule's message with "Custom rule", since it can expand a matched value.

Records stored before the parser was on are counted on the WAF page; they expire with your retention.

Then send both logs to the hub with a diagnostic setting (the WAF page gives the command for each gateway that does not send them):

az monitor diagnostic-settings create --name logthread-waf --resource <gateway id> \
  --event-hub logs --event-hub-rule <hub rule id> \
  --logs '[{"category":"ApplicationGatewayFirewallLog","enabled":true},{"category":"ApplicationGatewayAccessLog","enabled":true}]'

You can also turn on Azure's own log scrubbing for argument and cookie names: the WAF page offers it as a change.

How requests are counted#

Azure logs one firewall record per rule that matched. The parser turns them into:

  • one event.dataset:waf record per request: rule 949110's verdict (Blocked or Detected, with the total anomaly score as waf.anomaly.inbound), or a record that blocked the request itself (a custom rule, or a rule overridden to Block);
  • one event.dataset:waf_match record per rule and variable that contributed, with waf.rule.id, waf.matched_var, waf.value_shape and the same waf.transaction_id.

So the threat report, the WAF dashboard and the "Surge in WAF blocks" detection count each blocked request once. The analysis counts requests (distinct transactions), not rule matches.

Coverage#

Security → WAF lists every Application Gateway with its tier, its WAF policy (or none, or the legacy configuration), the mode and rule sets, the listener and path policies, and the firewall records of the last 24 hours. Each finding comes with its fix:

  • Standard_v2 without WAF: change the tier to WAF_v2 (in place, no downtime) with a policy in Detection mode first.
  • Legacy WAF configuration: Azure ends support on 15 March 2027. Upgrade it to a WAF policy from the gateway's Web application firewall page (in place, no downtime).
  • Detection mode: open the detection-mode report.
  • Outdated rule set: OWASP 3.0 and 3.1 have support end dates. Changing the version resets that rule set's overrides, so plan it as a change of its own.
  • Logs not sent, or not arriving.

Unfinished items also appear on Home.

Rule analysis and false-positive candidates#

Choose a policy, then 7 or 30 days. Per rule: the requests it matched, how many were blocked or detected, the distinct client addresses, and the top paths and variable names.

A false-positive candidate is a (rule, variable name, value shape) group where, by default:

  • the matches come from at least 10 distinct networks (/24 for IPv4, /48 for IPv6);
  • they are spread over at least 3 days;
  • at least 80% of the addresses made clean requests (no WAF record) before their first match: returning users. This needs the access log;
  • fewer than 10% of the addresses matched a rule of another attack family, and none was flagged by another detection;
  • it is not a scanner pattern (rule family 913);
  • at least 80% of the addresses also got 2xx answers from the same host (with the access log).

You can change each threshold. Every criterion shows its number, and one that cannot be checked says so. ASN diversity is not checked yet: Logthread has no ASN data for client addresses, so the network count stands in for it. Every count reconciles with the raw rows.

Candidates on SQL injection (942), command execution (932), PHP (933) and Java (944) rules, and the DRS equivalents, are labelled high risk: their fix needs two admins' approval, and they are never suggested on Home.

The proposed fix#

An exclusion of that variable from that rule only, in the policy named by the records' policyId (which can be a listener or path policy):

  • ARGS:x becomes RequestArgValues with selector x, ARGS_NAMES:x becomes RequestArgKeys, cookies RequestCookieValues and RequestCookieKeys, headers RequestHeaderValues and RequestHeaderKeys, operator Equals;
  • it is scoped to the rule set and version, the rule group and the rule id. That needs OWASP 3.2 or DRS 2.1 and later; on older rule sets, upgrade first.

Azure applies an exclusion to every request the policy covers, which can mean every listener and gateway that shares it. Exclusions cannot be scoped to a path. When the path matters, use a per-path policy: a copy of the policy plus the exclusion, attached to that path rule.

The preview#

Preview shows what the exclusion would have changed over the last 7 days, over every request under the policy:

  • each request's anomaly score is recomputed from its matched rules, per rule and variable, with the policy's overrides (disabled and Log rules count 0; rules overridden to Block block whatever the score);
  • the severity of each rule comes from a table per rule set version (OWASP 3.2, DRS 2.1, DRS 2.2): Critical 5, Error 4, Warning 3, Notice 2, a threshold of 5, and paranoia level 2 rules only where they are on;
  • a request whose recomputed score does not equal the total Azure logged, or that matched a rule not in the table, counts as an estimate and is left out of "no longer blocked". When Azure logged no total at all, every number is an estimate and the preview says so.

It shows the requests that would no longer be blocked, those still blocked by other rules, and would now pass and looks like an attack: requests that also matched another attack family, or whose value shape differs from the candidate's. Review those before applying.

Detection-mode report#

For a policy in Detection mode: the requests Prevention would have blocked (949110 Detected), split into those the open false-positive candidates explain and the rest, and the checklist of candidates to clear. Switch to Prevention is offered as a change once no candidate is open.

Changes#

Every change is built by Logthread from typed fields: an exclusion, the switch to Prevention, or log scrubbing on. A member proposes it with its preview, and an admin approves it (two admins, neither the proposer, for a high-risk rule family). Once approved, it shows:

  • the Azure CLI commands, with your resource group and policy name;
  • a Terraform block for azurerm_web_application_firewall_policy;
  • a Bicep fragment.

Policies tagged as managed by Terraform or Bicep show the code first: the next apply of your code would undo a change made in Azure.

Logthread checks every 15 minutes whether the policy now contains the change, and marks it applied by you. Logthread does not write to Azure; applying changes for you comes later, after it is checked on a customer's own test policy.

Detection: WAF policy switched to Detection or disabled#

When a read finds that a policy went from Prevention to Detection, or was disabled, Logthread records it (event.dataset:waf_posture, event.action:waf_policy_weakened) and the detection WAF policy switched to Detection or disabled can alert you. Turn it on under Security → SIEM. The Azure activity log shows who made the change.

Roles#

  • Viewer: reads coverage, the analysis and previews.
  • Member: proposes changes.
  • Admin: approves changes, and reads Azure again on demand.

MCP and Pari#

The MCP server has read tools for this: list_waf_targets (coverage), analyse_waf_policy (rules and candidates) and preview_waf_change (the preview of an exclusion). Pari answers questions about your WAF from the same reads.

Troubleshooting#

  • "The Logthread WAF reader role is missing the permission …": add that action to the role, or assign the role on the subscription. Then choose Test connection.
  • "Azure does not know this subscription id": check the id, and that the role is assigned on it.
  • Policies read in part: Azure did not return the mode or rule sets. Logthread tries the policy's own GET and keeps reading every 15 minutes.
  • No WAF log in the last 24 hours: check the gateway's diagnostic setting, the Event Hub the agent reads, and the agent on the Agents page. A gateway with no traffic logs nothing.
  • Every preview number is an estimate: Azure did not log a total score, or the rule set version has no severity table here (OWASP 3.2, DRS 2.1 and DRS 2.2 do).