Rules file
Every key a vulnboxd-rules.yml can hold. For explanations and examples, see Rules.
end_of_tick: allow # service-wide settings, overridable per port
on_undecidable: block # the default: stop what the rules cannot decide on; log lets it through
intercept: true
pool_upstream: true
rules: [] # rules for every port whose protocol they fit
bypass: {} # {header: exact value}: http requests with all of them skip every rule
grpc_schema: [] # .proto files and descriptor sets, relative to this file: gRPC field names
ports:
"8080": # published port; "53/udp" for udp
protocol: http # tcp | http | ftp on tcp ports, udp | dns on udp ports
end_of_tick: allow
on_undecidable: block
intercept: true
pool_upstream: true
rules: []File and port settings
| key | where | default | |
|---|---|---|---|
end_of_tick | file, port | allow | what happens to new connections and datagrams in the end-of-tick window: allow lets them through, drop refuses them, stall holds them open until timeouts.stall |
on_undecidable | file, port | block | what happens to a message the rules cannot decide on: block stops it as a block rule would (fail closed), log lets it through; both report a hit of the rule on_undecidable, logged at warn level. Unset is block |
intercept | file, port | true | false leaves the port exposed as it is, with no proxy and no rules; applied at the next deploy |
pool_upstream | file, port | true | reuse connections to the service between clients (http only) |
rules | file, port | [] | the rules, evaluated in order: service-wide first, then the port's |
bypass | file | {} | {header: value}; http requests carrying all of them, with exactly these values, skip every rule, and the headers are removed before the service sees them. Values need at least 12 characters |
ports | file | {} | per-port settings, keyed by "<port>" or "<port>/udp" |
grpc_schema | file | [] | the service's gRPC schema: .proto files and descriptor sets (protoc --include_imports -o), relative to the rules file, which let grpc_field name fields. A file that is missing or does not parse is logged and left out |
protocol | port | tcp / udp | how the port's traffic is parsed |
Rule keys
| key | default | |
|---|---|---|
name | #<position> | shown in logs and metrics |
enabled | true | false keeps the rule in the file, loaded and checked, but it never fires |
dir | in | in (to the service), out (to the client) or both |
match | always | conditions that must all hold |
not | never | skip the rule when all of these hold; head conditions only |
action | see below | block, stall, replace or log |
replace | {regex: replacement}, applied to the payload (http: the body) | |
set_status | 403 | http: status of the answer to a blocked message, or the new status of a response |
set_body | http: body of the answer to a blocked message, or the new body | |
set_headers | http: headers of the answer to a blocked message, or headers to set | |
remove_headers | http: header names to remove; case-insensitive, may end in * | |
keep_headers | http: header names to keep, removing the rest; Host and framing headers always stay | |
route | http: send matching requests here instead; host:port or a bare port | |
mirror | http: also send a copy here and log when the answers differ | |
grpc_error | {status: permission_denied, message: blocked} | http, block: what a blocked gRPC or Connect call is answered with; status a name or number other than OK |
action defaults to replace if the rule has replace, remove_headers or keep_headers, and to block otherwise. stall answers nothing and holds the connection; it is for tcp, http and ftp ports, and cannot be combined with anything that changes the message.
Conditions
For match, and for not where marked.
| key | protocols | in not | |
|---|---|---|---|
contains | all | the payload contains this text | |
regex | all | the payload matches | |
method | http | ✓ | regex over the method; WEBSOCKET for websocket messages |
path | http | ✓ | regex over path and query |
headers | http | ✓ | {name: regex}; the header must be present |
headers_opt | http | ✓ | {name: regex}; a missing header also passes |
headers_absent | http | ✓ | [name, ...]; none of these headers is sent |
header_order | http | ✓ | {exact | in_order | starts_with: [name, ...], case_sensitive: false}: the header names in the order sent are exactly these, contain these one after the other, or begin with these |
body | http | regex over the body alone; needs the whole body | |
status | http | ✓ | response status code |
qname | dns | ✓ | regex over the lower-cased query name; a message with several questions matches when one of them fits qname and qtype together |
qtype | dns | ✓ | query type, such as A or TXT |
larger_than | all | size in bytes, with K, M or G | |
distinct | all | {pattern: regex, over: n}: more than n different matches on one connection | |
anomalies | http | ✓¹ | a group or rule id, [name, ...], or {ids: [name, ...], min_severity, in: [target, headers, body]}: an anomaly of the anomaly rules that fits; by group (request_smuggling), rule id, or prefix.* |
grpc_method | http | ✓ | a glob (*, ?) or a list of them over the gRPC/Connect call's /package.Service/Method |
grpc_status | http | a status name or number, or a list: the call ended with it | |
grpc_field | http | {path | name: '1.3' | note.body, contains | equals | regex: value}, or a list that must all hold in one message | |
grpc_messages | http | {over: n}: more than n messages in the rule's direction | |
grpc_larger_than | http | a message, decompressed, larger than this size | |
decoded | http | ✓ | true or [layer, ...]: contains, regex, path, header values and body of this block also match the decoded message (layers: url, json, html, unicode, utf7, base64, hex, charset) |
¹ Only one that does not look at the body: in without body, or rules never about the body.
contains, regex, path, body and each header value of headers and headers_opt can be written as {value: <pattern>, decoded: true | false | [layer, ...]} to set decoded for that condition alone, over the block's.
route and mirror rules can only use method, path, headers, headers_opt, headers_absent, header_order and an anomalies condition that does not look at the body, since they are decided before the body is read.
- name: scripted clients
match:
headers_absent: [accept-language]
header_order: { starts_with: [Host, User-Agent], case_sensitive: true }
route: 9001Replacements
A replacement is either text or a transformation:
replace:
'password=\S+': 'password=***' # text; $1, ${name}, $$ for a literal $
'FLAG\{(\w+)\}': { encrypt: flags } # encrypt group 1 with key "flags"
'flag_([0-9a-f]{32})': { decrypt: hex, alphabet: 0123456789abcdef }See Encrypted flags.