Skip to content

Commit d133271

Browse files
committed
Add config sample
1 parent 3105ecb commit d133271

File tree

1 file changed

+27
-0
lines changed
  • app/_kong_plugins/ai-prompt-guard

1 file changed

+27
-0
lines changed

app/_kong_plugins/ai-prompt-guard/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,30 @@ The matching behavior is as follows:
7373
* If any `allow` expressions are set, but the request matches none of the allowed expressions, the caller also receives a 400 response.
7474
* If any `allow` expressions are set, and the request matches one of the `allow` expressions, the request passes through to the LLM.
7575
* If there are both `deny` and `allow` expressions set, the `deny` condition takes precedence over `allow`. Any request that matches an entry in the `deny` list will return a 400 response, even if it also matches an expression in the `allow` list. If the request does not match an expression in the `deny` list, then it must match an expression in the `allow` list to be passed through to the LLM.
76+
77+
## Best practices
78+
79+
Configure the AI Prompt Guard plugin to detect hidden Unicode characters that attackers commonly use to embed malicious instructions in user input:
80+
81+
{% entity_examples %}
82+
entities:
83+
plugins:
84+
- name: ai-prompt-guard
85+
config:
86+
deny_patterns:
87+
# Zero Width Characters (U+200B-U+200D, U+FEFF)
88+
- (\xE2\x80[\x8B-\x8D]|\xEF\xBB\xBF)
89+
90+
# Bidirectional Text Controls (U+202A-U+202E)
91+
- \xE2\x80[\xAA-\xAE]
92+
93+
# Format Controls (U+2060-U+206F)
94+
- \xE2\x81[\xA0-\xAF]
95+
96+
# Unicode Tag Characters (U+E0020-U+E007F)
97+
- \xF3\xA0\x80[\xA0-\xBF]|\xF3\xA0\x81[\x80-\xBF]
98+
formats:
99+
- deck
100+
{% endentity_examples %}
101+
102+
These patterns block invisible characters that can hide prompt injection attempts. Zero-width and bidirectional control characters render as blank space in most interfaces but remain visible to the LLM, allowing attackers to insert hidden commands.

0 commit comments

Comments
 (0)