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

FieldTypeRequiredDescription
actionreject | flagnoWhat to do when a rule matches (default: reject).
reject_oversizedboolnoReject 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.
rulesRuleConfig[]yesList of rules to evaluate.
rules[].namestringnoHeader name (required when target is [Header]).
rules[].containsstring | (ssn | credit_card | phone | email)[]noLiteral substring (case-insensitive) or PII category list.
rules[].negateboolnoInvert the match: reject when the content does NOT match. For negated header rules, a missing header also triggers rejection. Defaults to false.
rules[].patternstringnoRegex pattern match.
rules[].targetheader | bodyyesWhat 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