Skip to content

Prompt Safety Rules

Four rules cover adversarial and policy-violating language: prompt injection, harmful content judging, banned terms, and system prompt leakage. The first two combine local analysis with an optional model judge; the latter two are fully local.

Prompt injection#

provon.guard.injection is input-only and supports audit and block. It runs a two-layer defense so cheap pattern matching settles clear attacks while borderline phrasing escalates instead of hard-blocking benign conversation.

Layer 1 — local heuristics#

Bounded pattern matching over a normalised copy of the text produces two confidence tiers:

  • block — high-confidence combinations: an override paired with an extraction goal, an unrestricted-persona jailbreak, or indirect injection in fetched content pairing an override with an exfiltration channel.
  • suspicious — weaker standalone markers such as a bare override phrase, fake system delimiters, or encoded blobs. Suspicious signals accumulate weight and escalate to the judge once they cross suspiciousThreshold (default 3).

Signals carry five closed categories:

Category Covers
instruction_override Requests to ignore, replace, or reveal instructions
role_play_jailbreak Unrestricted persona and DAN-style framing
encoded_payload Obfuscated or encoded instruction blobs
indirect_injection Overrides hidden in fetched or tool-returned content
delimiter_manipulation Fake system delimiters and framing tricks

Evidence records categories, weights, and snippet hashes — never the inspected text.

Layer 2 — model judge#

Suspicious targets are judged by the configured model through the internal Gateway path; the judge call skips guardrails and cannot recurse. Verdicts are content-hash cached unless caching is false.

Settings:

  • model — Gateway model route used as the judge. Without a model, escalation targets follow the failure policy instead of being judged.
  • onCheckerError — closed (default) blocks when the judge is unavailable, times out, or returns an unparseable verdict; open records the failure and allows the exchange.
  • checkerTimeoutMs — hard abort timeout for one judge call (default 15000).
  • maxCheckerOutputTokens — judge output cap (default 256).
  • caching — cache judge verdicts by content hash (default on).
  • scanUserMessages / scanToolResults — select which input surfaces are inspected.
  • categories — optional allowlist restricting the heuristics that may fire.

Untrusted tool results#

Tool output is untrusted content. The same injection rule inspects text blocks, embedded text resources, and structuredContent of tool results before they return to the caller — never image or audio payloads. With an explicitly configured reviewer model, tool-result text is reviewed even without heuristic keywords. Audit records the result without withholding it; enforcement withholds the result on a block. This does not undo an already executed tool, and no injection rule or reviewer is enabled automatically. The same settings apply across Chat Completions, Responses, and Messages requests.

Harmful content#

provon.guard.content-safety runs on both directions and supports audit and block. One LLM judge classifies candidate text against a fixed harm taxonomy:

  • hate
  • harassment
  • sexual
  • violence
  • self-harm
  • weapons
  • illegal drugs

The judge returns a closed {verdict, category} object; categories outside the enum are discarded. Without a configured model the rule records an unavailable verdict and applies onCheckerError (closed blocks, open allows with an alert). Verdicts are content-hash cached unless caching is false. Streaming responses are buffered per segment before judging, reusing the segment buffer limits, so an enforced block never leaks partial bytes.

Banned terms#

provon.guard.word-list is fully local and takes its vocabulary from plugin config — no terms ship in the package. It runs on both directions and supports audit, block, and transform.

Parameters:

  • words (required) — non-empty array of banned words or phrases.
  • maxEditDistance — 0 for exact word-boundary matching only; 1 (default) or 2 also matches single-word terms within that Levenshtein distance, catching typo and spacer bypasses. Multi-word phrases always use exact matching.

Under Transform, each occurrence is spliced to the fixed token [redacted]. Input scans rewrite parsed JSON string leaves, so unicode escapes cannot hide a term.

System prompt leakage#

provon.guard.system-prompt-leak is output-only, fully local, and supports audit and block. It extracts the request's system instruction and scores every response sentence with a normalised Levenshtein similarity from 0–100. Any sentence above similarityThreshold (default 70) triggers the rule. The rule returns not_evaluated when the request carries no system message.

Choosing a failure policy#

Policy Choose when Cost of a false verdict
closed (default) Leakage or harm is unacceptable A benign exchange is blocked and retried
open Availability outranks the covered risk A harmful exchange passes with an alert

Failure policies apply only to model-backed checks. Local deterministic rules have no external dependency and do not fail open.