Skip to main content

chaitin-waf

Sends requests to a Chaitin WAF for inspection.

Category SecurityAdd it to Route, Service, Consumer, Consumer group, Global rule, Plugin configEngine plugin chaitin-wafPriority 2700

What it does​

chaitin-waf asks a Chaitin web application firewall about each request on the route before it goes on to the backend. The firewall's nodes are named once for the environment, under Nodes in the plugin metadata. The route sets its Mode and, under Match, the requests the firewall is asked about.

In block mode a request the firewall flags is refused, in monitor mode it is only recorded, and off skips the check. Every route that carries the plugin depends on the nodes in the plugin metadata, whatever its mode.

When to use it​

  • An orders API open to the internet, where requests that carry attacks should stop at the gateway instead of reaching the backend.
  • A firewall rollout in steps: every route starts in monitor mode, and a route moves to block once its verdicts have been watched for a while.
  • Only the writes of an API, POST, PUT, PATCH and DELETE, sent to the firewall under Match by a condition on request_method.
  • A security team that already runs the firewall's nodes, named once in the plugin metadata for every API behind the gateway.

Not for refusing clients by their address — see ip-restriction (Allows or denies clients by IP address or CIDR range), refusing requests to paths you list yourself — see uri-blocker (Blocks requests whose URI matches a rule) or checking requests against the API's own OpenAPI description — see oas-validator (Validates requests against an OpenAPI document; responses are not checked).

Set it up​

Block requests the firewall flags on POST, PUT, PATCH and DELETE​

Needs the firewall nodes named in the plugin's environment-wide settings.

Set Mode to block, fill Match as in the JSON below and turn off Add firewall response headers.

chaitin-waf · as the console saves it
{
"mode": "block",
"match": [
{
"vars": [
[
"request_method",
"in",
[
"POST",
"PUT",
"PATCH",
"DELETE"
]
]
]
}
],
"append_waf_resp_header": false
}

More scenarios​

Name the firewall nodes every route that carries the plugin sends its requests throughenvironment-wide settings

Fill Nodes as in the JSON below and set Mode to monitor.

chaitin-waf environment-wide settings · as the console saves it
{
"nodes": [
{
"host": "10.0.3.10",
"port": 8000
},
{
"host": "10.0.3.11",
"port": 8000
}
],
"mode": "monitor"
}

Things to know​

  • Mode — Until the plugin's environment-wide settings list the firewall's nodes, every request through the route answers 500, even in off mode.
  • The Mode in the plugin metadata applies to every route whose chaitin-waf sets none of its own. With none there and none on the route, the firewall is asked in monitor mode.
  • Plugin metadata that lists no node is refused when you save.
  • Mode — A mode other than block, monitor and off, report for example, is refused when you save.
  • Match — A row of Match that carries no condition is refused when you save.
  • Vars — An operator the gateway does not know, starts_with for example, is refused when you save.
  • AdviceStart each route in monitor mode and read what the firewall flags before you switch it to block.

Settings​

The fields as the console shows them, section by section.

Modemodestring

Block refuses what the firewall flags, monitor only records it, off skips the check. This overrides the mode in the environment-wide settings.

one of block, monitor, off
Matchmatcharray of objects
Each item:
Varsmatch[].varsarrayRequired
conditions on request variables: see Conditions on request variables
Configconfigobject

Overrides the environment-wide settings field by field; a value left blank keeps the environment-wide one.

Log responsesconfig.log_respboolean

Also reports each response to the detector after the client has received it; the response size and the ignored content types below are read only then.

Response body to inspectconfig.resp_body_sizeinteger

Kilobytes of the response body reported to the detector while responses are logged; zero reports the headers alone.

at least 0
Ignored content typesconfig.extra_ignored_content_typesstring

A comma-separated list of response content types, beside the built-in ones, whose responses are not reported at all while responses are logged.

Connect timeoutconfig.connect_timeoutinteger
in milliseconds
Keepalive sizeconfig.keepalive_sizeinteger
Keepalive timeoutconfig.keepalive_timeoutinteger
in milliseconds
Read timeoutconfig.read_timeoutinteger
in milliseconds
Real client IPconfig.real_client_ipboolean

Not set, it follows the environment-wide setting, which is on unless changed there.

Request body to inspectconfig.req_body_sizeinteger

Kilobytes: a longer body is cut to this many before the detector reads it.

Send timeoutconfig.send_timeoutinteger
in milliseconds
Add firewall response headersappend_waf_resp_headerbooleandefault true

Off, the answer carries none of the firewall headers, the error one included.

Add firewall debug headerappend_waf_debug_headerbooleandefault false

Environment-wide settings​

Set once per environment, under Plugins › chaitin-waf. Every chaitin-waf in the environment uses these.

Nodesnodesarray of objectsRequired
at least 1 item
Each item:
Hostnodes[].hoststringRequired
pattern^\*?[0-9a-zA-Z-._\[\]:/]+$
Portnodes[].portintegerdefault 80
at least 1
Configconfigobjectdefault {}
Log responsesconfig.log_respbooleandefault false

Also reports each response to the detector after the client has received it; the response size and the ignored content types below are read only then.

Response body to inspectconfig.resp_body_sizeintegerdefault 4

Kilobytes of the response body reported to the detector while responses are logged; zero reports the headers alone.

at least 0
Ignored content typesconfig.extra_ignored_content_typesstring

A comma-separated list of response content types, beside the built-in ones, whose responses are not reported at all while responses are logged.

Connect timeoutconfig.connect_timeoutintegerdefault 1000
in milliseconds
Keepalive sizeconfig.keepalive_sizeintegerdefault 256
Keepalive timeoutconfig.keepalive_timeoutintegerdefault 60000
in milliseconds
Read timeoutconfig.read_timeoutintegerdefault 1000
in milliseconds
Real client IPconfig.real_client_ipbooleandefault true
Request body to inspectconfig.req_body_sizeintegerdefault 1024

Kilobytes: a longer body is cut to this many before the detector reads it.

Send timeoutconfig.send_timeoutintegerdefault 1000
in milliseconds
Modemodestring

The mode every route that writes no mode of its own runs in; with none here and none on the route the firewall is asked in monitor mode.

one of block, monitor, off

Every plugin also has Enabled, Priority, Filter, Error response and Pre-function: see Plugin execution settings.

G8 dev · Apache APISIX® 3.19.0
Apache, Apache APISIX and APISIX are trademarks of The Apache Software Foundation.
Facts
Category
Security
Add it to
Route, Service, Consumer, Consumer group, Global rule, Plugin config
Engine plugin
chaitin-waf
Priority
2700