Skip to content

Rules file ​

Every key a vulnboxd-rules.yml can hold. For explanations and examples, see Rules.

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

keywheredefault
end_of_tickfile, portallowwhat 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_undecidablefile, portblockwhat 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
interceptfile, porttruefalse leaves the port exposed as it is, with no proxy and no rules; applied at the next deploy
pool_upstreamfile, porttruereuse connections to the service between clients (http only)
rulesfile, port[]the rules, evaluated in order: service-wide first, then the port's
bypassfile{}{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
portsfile{}per-port settings, keyed by "<port>" or "<port>/udp"
grpc_schemafile[]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
protocolporttcp / udphow the port's traffic is parsed

Rule keys ​

keydefault
name#<position>shown in logs and metrics
enabledtruefalse keeps the rule in the file, loaded and checked, but it never fires
dirinin (to the service), out (to the client) or both
matchalwaysconditions that must all hold
notneverskip the rule when all of these hold; head conditions only
actionsee belowblock, stall, replace or log
replace{regex: replacement}, applied to the payload (http: the body)
set_status403http: status of the answer to a blocked message, or the new status of a response
set_bodyhttp: body of the answer to a blocked message, or the new body
set_headershttp: headers of the answer to a blocked message, or headers to set
remove_headershttp: header names to remove; case-insensitive, may end in *
keep_headershttp: header names to keep, removing the rest; Host and framing headers always stay
routehttp: send matching requests here instead; host:port or a bare port
mirrorhttp: 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.

keyprotocolsin not
containsallthe payload contains this text
regexallthe payload matches
methodhttp✓regex over the method; WEBSOCKET for websocket messages
pathhttp✓regex over path and query
headershttp✓{name: regex}; the header must be present
headers_opthttp✓{name: regex}; a missing header also passes
headers_absenthttp✓[name, ...]; none of these headers is sent
header_orderhttp✓{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
bodyhttpregex over the body alone; needs the whole body
statushttp✓response status code
qnamedns✓regex over the lower-cased query name; a message with several questions matches when one of them fits qname and qtype together
qtypedns✓query type, such as A or TXT
larger_thanallsize in bytes, with K, M or G
distinctall{pattern: regex, over: n}: more than n different matches on one connection
anomalieshttp✓¹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_methodhttp✓a glob (*, ?) or a list of them over the gRPC/Connect call's /package.Service/Method
grpc_statushttpa status name or number, or a list: the call ended with it
grpc_fieldhttp{path | name: '1.3' | note.body, contains | equals | regex: value}, or a list that must all hold in one message
grpc_messageshttp{over: n}: more than n messages in the rule's direction
grpc_larger_thanhttpa message, decompressed, larger than this size
decodedhttp✓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.

yaml
- name: scripted clients
  match:
    headers_absent: [accept-language]
    header_order: { starts_with: [Host, User-Agent], case_sensitive: true }
  route: 9001

Replacements ​

A replacement is either text or a transformation:

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