Skip to content

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: operator for 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: log

Start 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.

FindingRuleWhen
Skipped stepflow.skipped_stepA step its after steps did not precede, or no run at all.
Out of orderflow.out_of_orderA step comes back after a step that follows it already completed.
Too fastflow.too_fastLess than min_gap since the latest of the steps it needs.
Expiredflow.expiredThe run started longer than max_duration ago (the step counts as skipped).
Replayflow.replayA 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 SPRING24

The 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 ​

SettingWhat it doesDefaultAllowed valuesApplies in
Business flow mode (flows.mode)Whether flows set to refuse refuse.empty (same as API protection)detect, block, emptydetect wins over the application's block
Keep progress for (flows.state_ttl)How long progress is kept after a client's last step.1h1m to 720hall
Clients followed (flows.max_identities)Clients each node follows at once.1000001000 to 5000000all
Suggest flows (flows.learning.enabled)Counts step orders for suggestions.falsetrue, falseall
Clients before a suggestion (flows.learning.min_identities)Clients that must reach a step before an order into it is suggested.205 to 100000suggestions on

Flow ​

SettingWhat it doesDefaultAllowed valuesApplies in
nameIdentifies the flow.none (required)lowercase letters, digits, dashesall
stepsThe ordered steps.none (required)2 to 16all
steps[].nameNames the step.none (required)textall
steps[].endpointThe endpoint, written like positive model rules.none (required)METHOD /path/{var}all
steps[].afterSteps that must be done first.the step before itstep namesall
steps[].min_gapLeast time since the steps it needs.none0s to 1hall
max_durationLongest time from first to last step.none1s to 720hall
onceValues that may be used once.noneup to 4all
once[].valueWhere the value is.none (required)json:/pointer, query:name, form:name, header:Name, path:variableall
once[].scopeWho shares the value.identityidentity, globalidentity needs a client identity
once[].ttlHow long a used value stays used.720h1m to 87600hall
on_violationWhat a finding does.loglog, refuserefuse 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 ​

LimitValue
Flows per application32
Steps per flow2 to 16
Once values per flow4
Flows an endpoint may be a step of4
Runs per client32
Once value length read256 bytes (longer values are cut and the cut value counts)
Used once values in memory per node1,000,000
Learning counts5,000 pairs per application, day and node, kept 30 days
Memoryabout 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.