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
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)
Creating and Managing Model Proxies - Overview of model proxies and routing
LLM Token Based Rate Limit Policy - Token-based rate limiting for model proxies