guardrails
Rejects requests matching string, regex, or PII rules against headers and/or body content.
On this page
Rejects requests matching string, regex, or PII rules against headers and/or body content.
Configuration Notes
Body rules match the raw body text. Non-negated body rules are also evaluated against decoded JSON object keys and string values, so JSON escapes (\u0020) cannot hide blocked content.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
action | reject | flag | no | What to do when a rule matches (default: reject). |
reject_oversized | bool | no | Reject bodies of 1 MiB or more with 413 instead of inspecting them. Bodies larger than the pipeline’s effective buffer limit (the largest limit any filter in the pipeline requests) are always rejected with 413 by the buffer, regardless of this flag; there is no silent truncation. Without this flag, bodies of 1 MiB or more that fit within the effective limit are inspected in full. |
rules | RuleConfig[] | yes | List of rules to evaluate. |
rules[].name | string | no | Header name (required when target is [Header]). |
rules[].contains | string | (ssn | credit_card | phone | email)[] | no | Literal substring (case-insensitive) or PII category list. |
rules[].negate | bool | no | Invert the match: reject when the content does NOT match. For negated header rules, a missing header also triggers rejection. Defaults to false. |
rules[].pattern | string | no | Regex pattern match. |
rules[].target | header | body | yes | What to inspect: header or body. |
Example
filter: guardrails
action: flag # or "reject" (default)
rules:
# Detect PII in a header
- target: header
name: "Authorization"
contains: [ssn, credit_card, email]
# Detect PII in body
- target: body
contains: [ssn, credit_card, phone, email]
# Block SQL injection in body
- target: body
contains: "DROP TABLE"
# Block requests from bad bots
- target: header
name: "User-Agent"
pattern: "bad-bot.*"
# Require body to look like JSON (reject if NOT matching)
- target: body
pattern: "^\\{.*\\}$"
negate: true