Skip to content

Access rules Since v0.1 ​

Access rules decide early which requests an application accepts. Each rule has conditions (client networks, address lists, countries, paths, methods, an expression) and an action. Rules are checked in order and the first one whose conditions all hold decides, so you can put a narrow exception above a broad refusal.

Before you begin ​

  • Role: operator for the application (viewer can read the rules).
  • To match on address lists, define the lists first. For details, see Address lists.
  • To match on countries, configure the country database first (see Use country conditions).
  • If clients reach the product through a proxy or load balancer, add it under Traffic > Trusted proxies, so that rules see the real client address.

Add an access rule ​

text
1. Open Applications > All applications, and select the application.
2. In the application menu, open Request checks > Access and rate limits.
3. On the Access rules tab, under Rules, select Add access rule.
4. Enter a Name and choose an Action.
5. Fill in the conditions you need (Paths, Client networks, Client in lists,
   Countries, Expression (CEL), ...). Empty conditions match anything.
6. Use Move up and Move down to put the rule in its place: the first match decides.
7. Select Preview changes, check the list of changes, add a comment
   and select Apply.
sh
# The list is replaced as a whole: get it, edit it, set it back.
waap rules get -app shop -list access > access.yaml
# edit access.yaml, then preview and apply
waap rules set -app shop -list access -f access.yaml -dry-run
waap rules set -app shop -list access -f access.yaml -m "refuse admin from outside the office"
yaml
# access.yaml (waap rules set), or applications[].policy.access.rules in the configuration
- name: office-admin
  when:
    paths: ["/admin*"]
    ip_lists: [office]
  action: allow
- name: admin-elsewhere
  when:
    paths: ["/admin*"]
  action: block
  severity: high

A broad block rule can refuse everyone

A block or ban rule with no conditions matches every request. Always preview, and keep the application or Access protection mode in detect until the events show only the requests you meant to refuse.

Start from a filter

In the traffic explorer, Create rule from filter turns the current filter into a draft rule and opens it in this form. A draft only ever starts with action log or block; nothing is saved until you preview and apply it.

Change the order or remove a rule ​

text
1. Open the application's Access and rate limits page, Access rules tab.
2. On the rule, select Move up or Move down, or Remove access rule.
3. Select Preview changes, then Apply.
sh
waap rules get -app shop -list access > access.yaml
# reorder or delete records in access.yaml; the file order is the rule order
waap rules set -app shop -list access -f access.yaml -m "reorder"
# remove every access rule
echo '[]' | waap rules set -app shop -list access -f - -m "no access rules"
yaml
# The order of the list is the evaluation order.
- name: narrow-exception   # checked first
  ...
- name: broad-refusal      # checked only if the one above did not match
  ...

Switch access rules to block ​

Rules only refuse requests when both the application and the access module are in block.

text
1. Open the application's Access and rate limits page, Access rules tab.
2. Set Access protection mode to block (or leave it empty to follow the application).
3. Select Preview changes, then Apply.
sh
waap apps set -app shop -m "access rules enforced" policy.access.mode=block
# back to following the application
waap apps set -app shop -m "follow the application mode" policy.access.mode=
yaml
applications:
  - name: shop
    policy:
      mode: block
      access:
        mode: block   # empty: same as the application; detect wins

Use country conditions ​

Countries and Not countries need a country database (any MMDB country database) on every node that runs inspection.

text
1. On each node, download the database (CLI tab, first command).
2. Open System > Settings, Country database.
3. Set Country database file to the absolute path, preview and apply.
sh
waap geoip update -out /var/lib/waap/country.mmdb
waap settings set geoip -m "country database" database=/var/lib/waap/country.mmdb
waap geoip status
yaml
geoip:
  database: /var/lib/waap/country.mmdb   # absolute path, on every node

The file is reloaded when it changes. waap geoip update downloads the free DB-IP Lite database; its data requires the attribution "IP data by DB-IP.com" wherever results are shown.

Update the file on both nodes of a pair

Only the path is part of the configuration. The file itself is not copied between the nodes of a high-availability pair: update it on each node.

Settings reference ​

Mode ​

SettingWhat it doesDefaultAllowed valuesApplies in
Access protection mode (policy.access.mode)Whether block and ban rules refuse requests or only log.empty (same as the application)detect, block, emptyall; detect wins over the application's block

Rule ​

SettingWhat it doesDefaultAllowed valuesApplies in
Name (name)Identifies the rule in configuration and events; it is the event's rule ID.none (required)lowercase letters, digits and dashes, 1 to 63 characters, starting with a letter or digit; unique in the listall
Action (action)What happens to a matching request. See What each action means.none (required)block, log, allow, trust, banblock, ban refuse only in block mode
Skip modules (skip)Modules that do not run for a matching request.nonebots, signatures, rate_limitsaction trust only; skipped in every mode
Ban for (ban_for)How long a matching client is banned.noneduration, 1s to 168h (required with ban)action ban only; bans only in block mode
Severity (severity)Severity recorded on the event. Does not change the action.mediuminfo, low, medium, high, criticalall

Conditions ​

Every condition that is set must hold. An empty condition matches anything.

SettingWhat it doesDefaultAllowed valuesApplies in
Paths (when.paths)Matches the request path, without the query string.none (any path)up to 100; exact path, or a prefix ending in *; must start with /; no ? or #; at most 2048 bytes eachall
Path pattern (when.path_regex)Matches the path with a regular expression.noneRE2 syntax, at most 1024 bytes; unanchored (add ^ and $ for a whole-path match)all
Methods (when.methods)Matches the HTTP method.none (any method)up to 100; uppercase, for example POSTall
Client networks (when.cidrs)Matches the client address against addresses or networks.none (any client)IPv4 or IPv6 addresses or CIDRsall
Client in lists (when.ip_lists)Matches when the client is in at least one of these address lists.nonenames of defined address listsall
Client not in lists (when.not_ip_lists)Matches when the client is in none of these lists.nonenames of defined address listsall
Countries (when.countries)Matches when the client's country is one of these.nonetwo-letter uppercase codes (DE, US)needs the country database
Not countries (when.not_countries)Matches when the client's country is known and not one of these.nonetwo-letter uppercase codesneeds the country database
Expression (CEL) (expr)A condition written in CEL that must also be true.noneat most 2048 bytes; must return true or falseall

Clients without a known country match no country condition

A client whose country is unknown (a private address, or one missing from the database) matches neither Countries nor Not countries. A rule such as "block everyone not in DE" therefore never locks out your internal addresses.

Expression variables ​

An expression that fails to evaluate (for example, it reads a header the request does not have) does not match.

VariableTypeMeaningSince
request.method, request.path, request.hoststringmethod, path without query, hostv0.1
request.querymap of string listsquery parametersv0.1
request.headersmap of stringsheaders by lowercase name; repeated headers joined with , v0.1
client.ip, client.countrystringclient address, two-letter country (empty if unknown)v0.1
client.listslist of stringsnames of the address lists the client is inv0.1
nowtimestamptime of the requestv0.1
request.ja4h, request.referer_hoststringHTTP fingerprint, host of the Referer headerv0.2
client.asn, client.as_orgint, stringnetwork number and organisation (needs the ASN database)v0.2
tls.version, tls.sni, tls.ja3, tls.ja4stringTLS details, empty on plain HTTPv0.2
attack_score, attack_class, attack_sqli, attack_xss, attack_cmd, attack_file, attack_other, automation_score, automation_classscoresscores from the signatures and bot checksv0.2

A rule that uses a score runs later

A rule whose expression names a score is checked after the signatures, in its list order among the other score rules, with the access module's mode. The console marks it "Runs after signatures". Such a rule cannot use trust (the signatures it would skip have already run): use allow or log.

Examples ​

Refuse the admin area to everyone outside the office list:

yaml
- name: admin-office-only
  when:
    paths: ["/admin*"]
    not_ip_lists: [office]
  action: block
  severity: high

Let a monitoring network skip the bot checks and rate limits, but keep the signatures:

yaml
- name: monitoring
  when:
    cidrs: ["10.20.0.0/24"]
  action: trust
  skip: [bots, rate_limits]

Ban for an hour any client that requests a known scanner path:

yaml
- name: scanner-paths
  when:
    path_regex: "^/(\\.env|\\.git/|wp-login\\.php)"
  action: ban
  ban_for: 1h

Log, without refusing, API calls that lack a version header:

yaml
- name: api-without-version
  when:
    paths: ["/api/*"]
  expr: '!("x-api-version" in request.headers)'
  action: log
  severity: low

Allow sign-up only from the countries you serve:

yaml
- name: signup-countries
  when:
    paths: ["/signup"]
    methods: [POST]
    not_countries: [DE, AT, CH]
  action: block

Limits ​

LimitValue
Access rules per application1000
Paths and methods per rule100 each
Path length2048 bytes
Path pattern length1024 bytes
Expression length2048 bytes
Expression costbounded per evaluation; an expression over the bound fails and does not match
Ban for1s to 168h

Troubleshooting ​

Preview refuses the rule with a field name ​

  • Cause: the rule is invalid; the message names the field, for example access.rules[1].when.ip_lists[0]: unknown list "office".
  • Fix: by message: unknown list: define the address list first. requires geoip.database: configure the country database. ban_for ... required for ban or only allowed with action ban: set Ban for only with ban. skip ... only allowed with action trust. duplicate rule name: names are unique in the list. invalid expression: the message shows where the CEL fails.

A later rule never decides ​

  • Cause: a rule above it matches first, often a broad trust or allow.
  • Check: the event (or a trace of an allowed request) names the rule that decided; the order is the list order on the tab or in waap rules get.
  • Fix: move the narrower rule up, then preview and apply.

Block rules only log ​

Every client looks like the same address ​

  • Cause: a proxy in front of the product is not a trusted proxy.
  • Fix: add it under Traffic > Trusted proxies.