Getting started Community Training Tutorials Documentation APIs, AI & Tools
Pattern Name
Policy Name |
Regex Prompt Guard |
Summary |
Blocks LLM requests that match deny-list regex patterns |
Category |
LLM |
First Omni Gateway version available |
v1.11.4 |
Release Notes |
|
Returned Status Codes |
403 - Forbidden: Request blocked because prompt content matched one or more denied patterns |
| This policy supports OpenAI and Anthropic input formats. |
The Regex Prompt Guard policy scans LLM prompts and blocks requests when prompt content matches regex deny-list patterns.
The policy uses the Rust regex crate which supports RE2-style expressions to guarantee linear-time matching and eliminate the backtracking risk.
For example, you can use the policy to block attacks such as:
Prompt injection
Jailbreak attempts
SQL injection patterns
HTML script injection
The Regex Prompt Guard policy processes only requests. Responses pass through unchanged.
The policy buffers the full body of POST requests with a JSON body in a supported LLM format so it can match the prompt against the deny patterns. Other requests pass through without scanning.
Buffered payloads count toward the Omni Gateway payload limit, which is 1 MB by default. To change the limit on a self-managed Omni Gateway, set the FLEX_DOWNSTREAM_CONNECTION_BUFFER_LIMIT_BYTES environment variable. In Connected Mode, you can also set Global connection buffer limit in Runtime Manager. For more information, see Configure Global and Routing Settings in Runtime Manager. For more information about the limit, see Omni Gateway Limits and Performance Metrics.
When you apply the policy from the UI, the following parameters are displayed:
| Element | Required | Description |
|---|---|---|
Pattern Name |
Yes |
Human-readable pattern name. The policy includes this value in the blocked-response details. |
Regex Pattern |
Yes |
RE2-style regex expression used to match prompt content. Use |
When a request is blocked, the policy returns a response body containing the matched deny patterns:
{
"error": "Request blocked - content matches denied pattern",
"matched_patterns": [
"prompt-injection"
]
}
The Regex Prompt Guard Policy uses the Rust regex crate which supports RE2-style expressions to guarantee linear-time matching and eliminate the backtracking risk. This ensures that customer-supplied regex patterns can’t negatively impact gateway performance or availability.
The Regex Prompt Guard policy doesn’t support Perl Compatible Regular Expressions (PCRE), but supports these PCRE features:
Standard character classes
Alternation
Grouping
Greedy or lazy quantifiers
Anchors
Inline flags, such as (?i), for case-insensitivity.
These PCRE-specific features aren’t supported:
Lookaround assertions: (?=…), (?!…), (?⇐…), (?<!…)
Backreferences: \1, \2, (?P=name)
Recursive or subroutine calls: (?R), (?1)
Possessive quantifiers: a*`, `a+
Special constructs: \G, \K, and conditional patterns (?(1)yes|no)
Create and Manage Model Proxies - Overview of model proxies and routing
LLM Token Based Rate Limit Policy - Token-based rate limiting for model proxies