Prompt & response guardrails

How AI-FW inspects every prompt and response, built-in rules, custom rules, evaluation order, and rule actions.

AI-FW inspects inbound prompts (before they reach the model) and outbound responses (before they reach the client). The built-in rules cover the most common attack and compliance vectors out of the box; custom rules extend them to your own policy.

Built-in rules#

RuleDirectionActionWhat it catches
Jailbreak detectioninboundblock"Ignore previous instructions", system-override prompts, DAN mode, safety bypass
PII maskinginboundmaskSocial security numbers, credit cards, emails, API keys → [REDACTED_*]
Toxicity filteroutboundblockHate, discrimination, and harassment patterns
Data exfiltration guardoutboundblockLeaked system prompts, internal IPs, credentials, private keys

Built-in rules can be enabled or disabled individually from the Rules Manager (shown as "System" rules). Custom rules can be added, edited, enabled, disabled, and deleted.

How rules are evaluated#

Every request is evaluated in a fixed order, left to right. The first decisive outcome wins; later steps only run while the request is still undecided:

#StepWhat happens on a match
1Built-in rulesSystem rules run first, jailbreak, PII mask, toxicity, exfiltration.
2Block rulesReject with 400 guardrail_violation. A block always wins, even if an accept rule would also match.
3Mask rulesFirst match rewrites the content and short-circuits the group.
4Accept / Log rulesFirst match passes the request; log_only also suppresses preview persistence.
5Semantic tierScores the request against natural-language policies, see the semantic analysis guide.
6Implied ruleTerminal step: apply the configured default action, allow, or block (deny-by-default).
A block always wins

Deny-overrides are absolute: if a block rule matches, nothing else runs, even an accept rule that would also match. Only text-type rules (regex / keyword / token limits / model / user) can match in the block group.

Rule actions#

Every custom rule has one of four actions:

ActionEffect
blockReject with 400 guardrail_violation (always wins over other actions)
maskRewrite matching text with a replacement value before forwarding
log_onlyAccept & no log, pass through; the match is recorded but no content is persisted
acceptAccept & log, pass through; prompt and response previews are stored in the audit trail

Per-rule options#

  • Skip semantic check, when enabled and the rule matches, the request bypasses the semantic intent tier.
  • Source IP / subnet, the rule applies only when the client's IP is inside the CIDR (e.g. 10.0.0.0/8, 192.168.1.5).
  • Destination IP / subnet, the rule applies only when the resolved backend IP of the model is inside the CIDR.
  • Key mode & streaming override, a rule can pin the upstream key behavior and streaming mode for requests it matches (see the identity guide).

What a blocked request looks like#

Blocked transactions return HTTP 400 with a structured error:

HTTP 400
{
  "error": {
    "message": "The transaction was intercepted and blocked by corporate AI security policy.",
    "type": "guardrail_violation",
    "code": "prompt_injection_detected",
    "details": {
      "policy_id": "BUILTIN-JAILBREAK",
      "timestamp": "2025-01-15T10:00:00Z"
    }
  }
}

plus the X-Gateway-Security: Violated response header.

Structure-preserving rewrites#

When PII masking or the default-model substitution rewrites a request, the rewrite is structure-preserving: replacements are applied to JSON string values and the model field only. Tool calls, function calls, streaming options, and every other field pass through byte-identical, so assistant(tool_calls)tool(tool_call_id) sequences survive untouched to the backend.

Fail-open options (opt-in escape hatches)#

The gateway is fail-closed by default: a scanner exception or missing configuration blocks the request rather than forwarding it unguarded. For teams that must prioritize availability over safety in specific situations, Settings -> Fail-open Options exposes three admin toggles, all default OFF:

ToggleWhen ON
Scanner exceptionsA prompt-scanner exception allows the request with an audit entry instead of blocking it
Response-scan exceptionsA response-scanner exception forwards the response unscanned (never cached)
Compression gateIf the semantic gate is unavailable, compression is applied ungated instead of keeping the original (a below-threshold drift is still rejected)

Every fail-open event is logged with a warning and audited, so you can always see when the safety net was lifted.

Related