Appearance
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:
operatorfor the application (viewercan 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: highA 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 winsUse 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 statusyaml
geoip:
database: /var/lib/waap/country.mmdb # absolute path, on every nodeThe 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
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Access protection mode (policy.access.mode) | Whether block and ban rules refuse requests or only log. | empty (same as the application) | detect, block, empty | all; detect wins over the application's block |
Rule
| Setting | What it does | Default | Allowed values | Applies 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 list | all |
Action (action) | What happens to a matching request. See What each action means. | none (required) | block, log, allow, trust, ban | block, ban refuse only in block mode |
Skip modules (skip) | Modules that do not run for a matching request. | none | bots, signatures, rate_limits | action trust only; skipped in every mode |
Ban for (ban_for) | How long a matching client is banned. | none | duration, 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. | medium | info, low, medium, high, critical | all |
Conditions
Every condition that is set must hold. An empty condition matches anything.
| Setting | What it does | Default | Allowed values | Applies 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 each | all |
Path pattern (when.path_regex) | Matches the path with a regular expression. | none | RE2 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 POST | all |
Client networks (when.cidrs) | Matches the client address against addresses or networks. | none (any client) | IPv4 or IPv6 addresses or CIDRs | all |
Client in lists (when.ip_lists) | Matches when the client is in at least one of these address lists. | none | names of defined address lists | all |
Client not in lists (when.not_ip_lists) | Matches when the client is in none of these lists. | none | names of defined address lists | all |
Countries (when.countries) | Matches when the client's country is one of these. | none | two-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. | none | two-letter uppercase codes | needs the country database |
Expression (CEL) (expr) | A condition written in CEL that must also be true. | none | at most 2048 bytes; must return true or false | all |
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.
| Variable | Type | Meaning | Since |
|---|---|---|---|
request.method, request.path, request.host | string | method, path without query, host | v0.1 |
request.query | map of string lists | query parameters | v0.1 |
request.headers | map of strings | headers by lowercase name; repeated headers joined with , | v0.1 |
client.ip, client.country | string | client address, two-letter country (empty if unknown) | v0.1 |
client.lists | list of strings | names of the address lists the client is in | v0.1 |
now | timestamp | time of the request | v0.1 |
request.ja4h, request.referer_host | string | HTTP fingerprint, host of the Referer header | v0.2 |
client.asn, client.as_org | int, string | network number and organisation (needs the ASN database) | v0.2 |
tls.version, tls.sni, tls.ja3, tls.ja4 | string | TLS details, empty on plain HTTP | v0.2 |
attack_score, attack_class, attack_sqli, attack_xss, attack_cmd, attack_file, attack_other, automation_score, automation_class | scores | scores from the signatures and bot checks | v0.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: highLet 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: 1hLog, 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: lowAllow sign-up only from the countries you serve:
yaml
- name: signup-countries
when:
paths: ["/signup"]
methods: [POST]
not_countries: [DE, AT, CH]
action: blockLimits
| Limit | Value |
|---|---|
| Access rules per application | 1000 |
| Paths and methods per rule | 100 each |
| Path length | 2048 bytes |
| Path pattern length | 1024 bytes |
| Expression length | 2048 bytes |
| Expression cost | bounded per evaluation; an expression over the bound fails and does not match |
| Ban for | 1s 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 banoronly allowed with action ban: set Ban for only withban.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
trustorallow. - 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
- Cause: the application or Access protection mode is in
detect. - Fix: set both to
block(see Switch access rules to block).
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.