Appearance
Enforce the rules Since v0.1
As soon as positive.rules holds at least one rule, every request to the application is checked against it. Without rules nothing is checked.
Before you begin
- Role:
operator. - Approved rules (Approve and preview) and a preview that shows an acceptable false-positive rate.
What is checked
The checks run in this order: the endpoint (the most specific rule whose template matches path and method), the content type (none is a request without a body), then each parameter. For a parameter: unknown parameters first, then the value checks (type, length, characters, enum, and the pattern of a manual rule), then missing required parameters. A request reports at most 8 reasons.
| Rule ID | Meaning | Action |
|---|---|---|
pos.endpoint.unknown | No rule covers the endpoint. | unknown_endpoints (default log) |
pos.method | The path has rules, not for this method. | unknown_endpoints |
pos.content_type | Content type not in the rule. | refuse |
pos.param.unknown | Parameter not in the rule. | unknown_parameters (default log) |
pos.param.missing | Required parameter missing. | refuse |
pos.param.type, .length, .charset, .enum | Value outside the rule. | refuse; with confirm_anomalies only when an attack class is found, otherwise log |
pos.param.pattern | Value does not match a manual rule's pattern. | refuse |
"Refuse" means block in block mode. In detect mode, set on the module or the application, the request is recorded as "would block" and passes.
Change the enforcement settings
text
1. Open Request checks > Learned model > Settings and reset, group Enforcement.
2. Change a setting. Use default (shown only when overridden) removes an explicit value.
3. Select Preview changes, review the diff, add a comment and select Apply.
Any edit after the preview needs another preview.sh
waap learning set -app shop -m "refuse unknown parameters" unknown_parameters=refuseyaml
# applications[].policy.positive in the configuration
positive:
mode: block
unknown_endpoints: log
unknown_parameters: log
confirm_anomalies: trueEnforcement
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Protection mode (mode) | detect records what rules would refuse; block refuses. | application's mode | detect, block | all |
Endpoints without a rule (unknown_endpoints) | Action for a request to an endpoint or method no rule covers. | log | log, refuse | once rules exist |
Parameters not in the rule (unknown_parameters) | Action for a parameter the rule does not name. | log | log, refuse | once rules exist |
Refuse odd values only when they look like an attack (confirm_anomalies) | Refuses a type, length, character or enum violation only when it also looks like an attack. | true | true, false | block mode |
Staged rules (staged_rules) | Rules that only log until the date below. | none | pos.param.type, pos.param.*, pos.*; at most 16 | until the date |
Staged until (staged_until) | When staged rules start to refuse. | none | a time, or a duration such as 168h | staged rules set |
Missing required parameters, content types outside the rule, and patterns are refused without confirmation.
Confirm value anomalies
With confirm_anomalies on, the first 4 KiB of an out-of-profile value are checked for SQL injection and XSS (libinjection) and, with fixed RE2 expressions, for path traversal, command injection and template injection. The event keeps the profile violation and adds confirmed: sqli, xss, path_traversal, cmdi or ssti. A value with no matched class passes with unconfirmed: no attack class matched in the reason. A value inside the profile is not classified.
Markers, not every attack
Ordinary placeholders such as are unconfirmed, and an attack beyond the first 4 KiB cannot confirm a violation. To refuse every value outside a profile, preview with -no-confirm, then set confirm_anomalies=false. Keep the default while tuning a new profile.
Signatures run after the positive checks; a later signature score does not confirm a positive finding. Values over 4 KiB have no known type and match no enum or pattern, but their length is always checked in full.
Stage new rules
text
1. Open Learned model > Settings and reset, group Enforcement.
2. Add rule names under Staged rules and set Staged until.
3. Select Preview changes, then Apply.sh
waap learning set -app shop -m "Watch new rules for a week" staged_rules=pos.param.* staged_until=168hUntil the date, refusals of those rules are logged with staged in the event and message. Afterwards they refuse.
Add an exception
Ignore positive rules for a path or one parameter with an ordinary exception (Access and rate limits > Exceptions, or waap except). Name the rules in ignore_rules; for one parameter add param:LOCATION.NAME.
yaml
# exceptions in the application's policy
exceptions:
- name: free-text-notes
when: { paths: ["/api/orders/*"] }
ignore_rules: [pos.param.charset]
in: ["param:json.note"]To fix a false positive for good, edit the rule instead: widen the length, add the character class or the enum value that the event shows.
Events and learning while enforcing
Each event names module positive, the rule ID, the parameter location as the variable (query, form, multipart, json, xml, path, header, cookie), the parameter name as key, a snippet (masked under policy.logging.mask: pci), the action, the mode and the expectation, for example POST /api/orders/{id}: expected integer, 1 to 3 characters (learned rule).
Learning keeps running: requests that only have log-only unknown endpoints or parameters are still learned. Requests a rule refused, would refuse or recorded as unconfirmed are not learned. A rule may name headers and cookies, which are read case-insensitively for checking; only those in learning.headers and learning.cookies count as unknown parameters.
Troubleshooting
- Normal requests are refused. Open the event, read the expectation and use Violations and false positives.
- Nothing is refused in block mode. Check the module
mode, that rules exist, and that the rules are not staged.