Deny Path Sets

Configure a deny paths set to refuse outside access to specific paths of an endpoint.

Deny paths set is a feature you can configure at the project level of a Commerce subscription. This setting of WAF Lite allows you to filter out incoming access to certain paths of an endpoint. You can assign one deny paths set to an endpoint.

Deny Path Set syntax

Deny Path Set exists in a text file format, and will be processed line by line.

A line can be:
  • an empty line
  • a comment, which starts with a #
  • a rule, which follows Rule syntax

Rule syntax

The rule syntax is:
DENY|ALLOW <path> [QUERY_STRING_CONTAINS <substring_to_look_for>]...
It consists of:
  • required positional arguments:
    1. DENY or ALLOW as the action the rule executes. DENY results in denying the request with the HTTP 403 Forbidden response status code. ALLOW enables the request to go through the deny paths set processing phase.

    2. path which the rule runs to check if it matches the request path. Take the following GET request as an example. The rule checks against the string /en/login:
      GET https://accstorefront.myshop.model-t.myhybris.cloud/en/login?site=electronics
  • optional keyword arguments, or Conditional Arguments, which will be evaluated as true or false:
    • QUERY_STRING_CONTAINS follows by a literal substring. It is true if the request query string contains the given substring, otherwise it is false. Also take the above GET request as an example. The rule searches substring in query string site=electronics. A rule can have 0 or more QUERY_STRING_CONTAINS, in any order.
Follow these guidelines while creating rules:
  • Order of entries matters. The last matched rule takes priority over others.
  • Separate arguments by one or more spaces.
  • Matching isn't case-sensitive.
  • The rules match all characters as they appear, except for:
    • A prefix asterisk, for example in DENY */login. In this place, it is a wildcard.
    • A suffix asterisk, for example in DENY /en/*. In this place, it is a wildcard.
    • A backslash. Use it for escaping characters.
      • Escaped prefix/suffix asterisks (\*) match literal asterisks. For example, DENY /login* matches any request that starts with /login, but DENY /login\* matches only /login*.
      • Escaped backslashes (\\) match literal backslashes. For example, DENY /login\\* matches requests that start with /login\.
      • Escaped literals are simply literals. For example, in DENY /logi\n matches requests coming to /login.
  • All incoming requests pass a URL decoder before WAF matches it against the configured rules. For example, a rule DENY *^*, which means "deny any request with ^ in the path", matches both /login^ and /login%5E, because %5E encodes ^.

See the following examples of deny paths set rules:

# Example 1: an exact match.
# Deny access to the server info endpoint.
DENY /server-info
 
# Example 2: an exact match with conditional argument QUERY_STRING_CONTAINS.
# Deny access to the server info endpoint.
DENY /server-info
 
# Example 2: how to use wildcards.
# Deny access to any path that contains 'login' in it.
DENY *login*
 
# Example 3: match with conditional argument QUERY_STRING_CONTAINS.
# Deny access to products if query string contains substring 'no-limit'.
DENY /products/* QUERY_STRING_CONTAINS no-limit
 
# Example 4: how to use rule ordering.
# Deny access to all products, except those in the cameras category.
# Additionally, inside the cameras category, deny access to the lenses subcategory.
DENY /products/*
ALLOW /products/cameras/*
DENY /products/cameras/lenses/*
 
# Example 5: how to achieve conditional access by using multiple argument QUERY_STRING_CONTAINS.
# Only allow access to products if query string contains both substring 'site' and 'lang'.
DENY /products/*
ALLOW /products/* QUERY_STRING_CONTAINS site QUERY_STRING_CONTAINS lang
 
# Example 6: how to escape special characters.
# Escape a wildcard to make it a literal asterisk.
DENY /my-path\*
# Escape a backslash to make it a literal backslash.
# Note that because it's escaped, it no longer escapes the asterisk, which as a consequence becomes a wildcard.
DENY /my-path\\*