WAF rules for blocking high number of query string param values

metalheart 361 Reputation points
2022-08-10T08:45:08.673+00:00

I'd like to block thousands of values of a query string parameter for a certain URL in Azure Front Door Premium Tier.

My understanding is that this is best done by adding WAF custom rules.

I have created custom rules with two matching conditions, one for the RequestUri and another for QueryString with a Regex operator of the form "id=(value1|value2|....)([&#\s]|$)".

My issue is that I need to block thousands of ID values and aligning them into rules with a single regex of max length 256 characters will exceed the limit of 100 rules per WAF policy. I'm also concerned about the performance of traversing such a high number of regexes for each hit.

Is there an alternative way of doing the blocking that would suit my needs?

UPDATE: additionally, when trying to set up multiple rules like this, I'm getting the error "Policy exceeds 5 regular expressions". I can't see this kind of limit documented in AFD service limits - what's going on here?

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
576 questions
Azure Web Application Firewall
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 34,926 Reputation points Microsoft Employee
    2022-08-19T09:36:00.267+00:00

    Hi @metalheart ,

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.
    I understand that you are trying an add a large number of Custom regex rules to an AFD WAF Policy.

    At present, a single WAF policy supports only up to 5 Custom rules with regular expressions.

    Addressing your question,

    One solution I can think of is, if the IDs are GUIDs, or are similarly long/unique, then use the Contains operator instead of Regex and add each id=GUID string as a separate match value. The idea here is that you will have more options

    Thanks,
    Kapil

    ----------------------------------------------------------------------------------------------------------------

    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful