Appearance
Business flows Since v0.2
The business-flow guard catches clients that use the application's steps in a way no normal user does: paying without a cart, confirming an order that was never paid, applying one coupon twice, or finishing a three-page form in a few milliseconds. You describe each flow as an ordered list of steps, each an endpoint. The guard follows every client through them by its client identity (the API consumer, the session user or the address).
Before you begin
- Role:
operatorfor the application. - Set up client identity first. Without a source other than the address, clients behind one NAT share a run.
- The feature is off while there are no definitions and Suggest flows is off.
Add a flow
text
1. Open Applications > All applications > the application > Request checks > API protection.
2. Open the Business flows tab and select Add flow.
3. Enter a name, the longest duration and the action on violation.
4. Add steps: name, endpoint, the steps needed first and the minimum gap. Use Move up and
Move down to order them.
5. Optionally add a once value (step, where the value is, scope, how long it is remembered).
6. Select Preview changes, add a comment and select Apply.sh
waap api flows -app shop > flows.yaml
# edit flows.yaml, then preview and apply
waap api flows -app shop -f flows.yaml -dry-run
waap api flows -app shop -f flows.yaml -m "coupon flow"yaml
# flows.yaml, or applications[].policy.api.flows.definitions
- name: coupon
steps:
- name: validate
endpoint: POST /community/api/v2/coupon/validate-coupon
- name: apply
endpoint: POST /workshop/api/shop/apply_coupon
after: [validate]
min_gap: 0s
max_duration: 30m
once:
- step: apply
value: json:/coupon_code
scope: global
ttl: 8760h
on_violation: logStart on log
Keep flows on log until you have watched them for a while. Progress is per node: in a pair, a client whose requests move between nodes mid-flow can be flagged with a skipped step. Use session affinity if you need to refuse.
How a request is judged
The first step always starts a new run (a client may start over at any time). Any other step is checked against the client's current run.
| Finding | Rule | When |
|---|---|---|
| Skipped step | flow.skipped_step | A step its after steps did not precede, or no run at all. |
| Out of order | flow.out_of_order | A step comes back after a step that follows it already completed. |
| Too fast | flow.too_fast | Less than min_gap since the latest of the steps it needs. |
| Expired | flow.expired | The run started longer than max_duration ago (the step counts as skipped). |
| Replay | flow.replay | A once value was already used, by this client or, with scope: global, by anyone. |
A step counts as done when its answer is below 400 and the request was not refused. A failed attempt, such as a declined payment, can be retried and does not spend its once value. Repeating a completed step is not a finding. A step that was flagged but still answered counts as done, so one attack gives one event. A flow left unfinished is forgotten after Keep progress for without an event.
after may name several steps. List steps in an order where each comes after the steps it needs. An endpoint may be a step of at most 4 flows and appears once per flow. {name} path segments match any value, and path:name reads that segment as a once value. A changed flow definition starts every client's run over.
Release a used once value
A support case may need a coupon code to be usable again.
text
1. On the Business flows tab, select Release a used once value.
2. Enter the flow and the value. For a value used once per client, also enter the identity.sh
waap api flows forget -app shop -flow coupon -value SPRING24The value is sent to the server only to compute its keyed hash and is not written to the audit log.
Take suggestions
With Suggest flows on, each node counts which endpoints every client called before each endpoint it reached. The control plane suggests "B after A" when at least Clients before a suggestion different clients reached B and at least 99.9% of the arrivals at B had called A before.
text
1. On the Business flows tab, open Suggestions.
2. Tick the ones to take, select Preview changes, then Apply.sh
waap api set -app shop -m "suggest flows" flows.learning.enabled=true
waap api flows suggestions -app shop
waap api flows suggestions -approve all -app shop -m "take suggestions"Approving extends a flow whose last step is A (or whose first step is B), or creates a flow named suggested-.... Unusual sequences are not flagged by themselves.
Settings reference
Module settings
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
Business flow mode (flows.mode) | Whether flows set to refuse refuse. | empty (same as API protection) | detect, block, empty | detect wins over the application's block |
Keep progress for (flows.state_ttl) | How long progress is kept after a client's last step. | 1h | 1m to 720h | all |
Clients followed (flows.max_identities) | Clients each node follows at once. | 100000 | 1000 to 5000000 | all |
Suggest flows (flows.learning.enabled) | Counts step orders for suggestions. | false | true, false | all |
Clients before a suggestion (flows.learning.min_identities) | Clients that must reach a step before an order into it is suggested. | 20 | 5 to 100000 | suggestions on |
Flow
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
name | Identifies the flow. | none (required) | lowercase letters, digits, dashes | all |
steps | The ordered steps. | none (required) | 2 to 16 | all |
steps[].name | Names the step. | none (required) | text | all |
steps[].endpoint | The endpoint, written like positive model rules. | none (required) | METHOD /path/{var} | all |
steps[].after | Steps that must be done first. | the step before it | step names | all |
steps[].min_gap | Least time since the steps it needs. | none | 0s to 1h | all |
max_duration | Longest time from first to last step. | none | 1s to 720h | all |
once | Values that may be used once. | none | up to 4 | all |
once[].value | Where the value is. | none (required) | json:/pointer, query:name, form:name, header:Name, path:variable | all |
once[].scope | Who shares the value. | identity | identity, global | identity needs a client identity |
once[].ttl | How long a used value stays used. | 720h | 1m to 87600h | all |
on_violation | What a finding does. | log | log, refuse | refuse in block mode |
Events
Module flows, variable FLOW, key flow/step (for example coupon/apply). The value is the once value for a replay (in full, or masked under policy.logging.mask: pci), otherwise the missing or completed steps. The event names the client's identity. Exceptions accept the rule IDs or flow.*.
Limits
| Limit | Value |
|---|---|
| Flows per application | 32 |
| Steps per flow | 2 to 16 |
| Once values per flow | 4 |
| Flows an endpoint may be a step of | 4 |
| Runs per client | 32 |
| Once value length read | 256 bytes (longer values are cut and the cut value counts) |
| Used once values in memory per node | 1,000,000 |
| Learning counts | 5,000 pairs per application, day and node, kept 30 days |
| Memory | about 200 bytes per client and flow in progress |
Once values are stored as a keyed hash, never as the value, and synced between nodes about every second, so a value replayed on another node within that second can pass once. Rotating the application's identity key forgets every used value and every run. Metrics: waap_flow_identities, waap_flow_once_values, waap_flow_state_dropped_total{kind}.
Troubleshooting
A legitimate customer is flagged flow.skipped_step
- Cause: the step order is stricter than the real flow, or the client moved between nodes mid-flow.
- Check: the event lists the missing and completed steps.
- Fix: loosen
after, or use session affinity.
Everyone behind one office address shares a run
- Cause: no identity source other than the address.
- Fix: set up client identity for authenticated users.