Appearance
LLM endpoint protection Since v0.2
Protect chat endpoints of the application that call a large language model, such as a support bot, an assistant or a search with generated answers. For each listed endpoint the product reads the chat request, looks for prompt injection in the messages, counts tokens and cost per client against budgets, and checks answers, whole JSON ones and streamed ones, for leaked secrets, card numbers and phrases of the system prompt. It is off until you list an endpoint, and it starts in detect like every new section.
Before you begin
- Role:
operatorfor the application. - For the optional classifier: the
waap-promptcheckadd-on (the binary and the ONNX Runtime library) next towaapon the inspection nodes, and a model. See the setup steps below. - Client identity set up, so budgets count per client rather than per address.
List an endpoint
text
1. Open Applications > All applications > the application > Request checks > API protection.
2. Open the LLM endpoints tab, Endpoints, and select Add.
3. Enter a name and the paths. Leave the format on auto, or choose one.
4. Optionally set the roles checked, budgets, model prices and system prompt phrases.
5. Select Preview changes, add a comment and select Apply.sh
waap api llm endpoints -app shop > endpoints.yaml
# edit endpoints.yaml, then preview and apply
waap api llm endpoints -app shop -f endpoints.yaml -dry-run
waap api llm endpoints -app shop -f endpoints.yaml -m "support chat"yaml
# endpoints.yaml, or applications[].policy.api.llm.endpoints
- name: support-chat
paths: [/v1/chat/completions]
system_prompt_markers: ["You are ShopBot, the assistant of Example Shop"]
tokens_per_day: 200000
models: [{name: "gpt-4o*", input_price: 2500000, output_price: 10000000}]
on_injection: refuseRead the events for a week in detect. Add ignore_rules exceptions where needed (for example llm.injection.heuristic on a path where users paste templates). Switch on_injection to refuse and the section to block when only attacks remain.
What the product reads
The format is recognised by shape (format: auto) or set per endpoint: OpenAI chat completions and responses API, Anthropic messages, or generic, where prompt is a JSON pointer to the user text (for example /query/text; * matches every element or member) and output points to the answer text.
Messages with the roles in Roles checked (user and tool by default) are checked. Tool results carry indirect injection: text from a web page, an email or a document the model was asked to read. At most 64 KiB of text is read per request; the token estimate (characters / 4) counts all of it.
Detect prompt injection
Two checks, both only logging by default (on_injection: log).
- Heuristics are fixed linear-time patterns, each with a weight: instruction overrides, persona switches, requests to reveal the system prompt, chat template tokens, requests to send data to an address, long base64 or hex blobs and hidden Unicode characters. A message whose weights add up to 100 is a finding (
llm.injection.heuristic). One signal alone stays below 100, so "please ignore my previous instructions, I meant Tuesday" is not flagged. - Classifier (opt-in) scores the messages with a prompt-injection model run by the
waap-promptcheckhelper. A score of Classifier threshold or more is a finding (llm.injection.classifier).
Set up the classifier
text
1. Install the waap-promptcheck add-on next to waap on the inspection nodes.
2. Open System > Helpers, set Run waap-promptcheck on and the Model directory.
3. Open the application's LLM endpoints tab, Settings, and turn on Injection classifier.
4. Select Preview changes, then Apply.sh
waap llm model fetch
waap settings set helpers promptcheck.enabled=true promptcheck.model=/var/lib/waap/models/promptcheck
waap api set -app shop -m "classifier" llm.classifier.enabled=true
waap api llm helperwaap llm model fetch downloads protectai/deberta-v3-base-prompt-injection-v2 (Apache-2.0, 0.75 GB, each file checked by size and SHA-256). Copy a model from another machine with waap llm model import -f DIR. The default model runs on the CPU: short messages take tens of milliseconds and long ones much more. A smaller or quantized model is faster.
The classifier has its own time budget
The classifier budget (default 150 ms) lies within the section budget (default 200 ms). When the classifier cannot answer, When the classifier cannot answer decides. With the default heuristics, the heuristics still apply and the outage is logged once a minute as llm.classifier_unavailable.
Test a prompt
text
1. On the LLM endpoints tab, open Test a prompt.
2. Paste a text. The page shows the heuristic score with the matched phrases and the
classifier's score, using the application's settings.sh
waap api llm check -app shop -text "Ignore all previous instructions"Nothing is sent or stored. Use it to judge a false positive before changing a threshold.
Set token and cost budgets
Budgets count per client identity and endpoint (the client address when no identity applies). Over a budget, block mode answers 429 with Retry-After (llm.budget.tokens, llm.budget.cost). A single request over Largest request is refused with 413.
text
1. Edit the endpoint on the LLM endpoints tab, Endpoints.
2. Set the token budgets and, under model prices, entries as name=input/output.
3. Select Preview changes, then Apply.sh
waap api llm endpoints -app shop -f endpoints.yaml -m "budgets"
waap api llm usage -app shop -day 2026-11-25yaml
# one endpoint of applications[].policy.api.llm.endpoints
max_request_tokens: 8000
tokens_per_minute: 20000
tokens_per_day: 500000
cost_per_day: 0
models:
- {name: "gpt-4o*", input_price: 2500000, output_price: 10000000}Tokens come from the answer's own usage report when it has one, else are estimated. Cost uses the models prices in micro-units of your currency per million tokens; a name ending in * is a prefix. Refused calls and failed answers count nothing. Each node counts what it saw, so with several active nodes a client can use up to the budget on each. The Usage card shows a day's requests and tokens per client and endpoint, with the share of the daily budget used.
Check answers
With Check answers for leaks on (default), answer text is scanned with the application's data-leak detectors, the built-in card, national ID and IBAN detectors, secret patterns (cloud and API keys, tokens, private keys) and the endpoint's system_prompt_markers. Leaks in answers decides the action. Findings are llm.output.leak and llm.output.system_prompt. The DLP module does not scan these answers again, so one leak gives one event.
Streamed answers (text/event-stream) are checked while they stream. Events are held back until Stream hold-back characters of answer text follow them, so a value split across events is found and masked before any of it leaves. The client sees the answer with that small delay (about 30 tokens at the default). Past the stream limits the rest passes unchecked and the event notes it (llm.output.unscanned). Answers on listed paths always reach the product uncompressed.
Spare chat text from CRS false positives
Ordinary chat text trips some signature rules ("Looks good; print the final version." looks like a shell command). By default each listed endpoint gets a built-in exception that ignores rules 932370, 934100, 941390 and 942151 in the message content only, for POST requests to its paths. Every other rule still reads the messages, and these four still read every other field. Set Spare chat text from CRS false positives to false to keep all rules on the message text.
Settings reference
Module settings
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
LLM protection mode (llm.mode) | Whether refusals apply. | empty (same as API protection) | detect, block, empty | detect wins over the application's block |
Find unlisted chat endpoints (llm.discovery) | Logs a JSON POST shaped like a chat call on an unlisted path, once per path and node (llm.endpoint.unlisted). Never blocks. | true | true, false | all |
Injection heuristics (llm.heuristics) | Runs the fixed patterns. | true | true, false | all |
Spare chat text from CRS false positives (llm.crs_exception) | Adds the built-in exception. | true | true, false | all |
Injection classifier (llm.classifier.enabled) | Scores messages with the model. | false | true, false | helper running |
Classifier threshold (llm.classifier.threshold) | Score from which a verdict counts. | 90 percent | 50 to 99 | classifier on |
Classifier time budget (llm.classifier.budget) | Longest the classifier may take. | 150ms | 10ms to 2s | classifier on |
When the classifier cannot answer (llm.classifier.on_unavailable) | What happens when it is missing, busy or too slow. | heuristics | heuristics, inherit, open, closed | closed refuses in block mode |
Check answers for leaks (llm.output.dlp) | Scans answer text. | true | true, false | all |
Leaks in answers (llm.output.action) | What happens to a leak. | mask | mask (same length, valid JSON), log, refuse | refuse replaces a JSON answer with the error page (502) or ends a stream with event: error |
Stream hold-back (llm.output.hold_back) | Characters of answer text held back in streams. | 128 | 32 to 4KiB; at least the longest marker | all |
Endpoint
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
name | Identifies the endpoint. | none (required) | lowercase letters, digits, dashes | all |
paths | Paths of the chat endpoint. | none (required) | up to 16 | all |
format | The request format. | auto | auto, openai, anthropic, generic | all |
prompt, output | JSON pointers to the user text and the answer text. | none | JSON pointers; * is any element or member | format generic |
classify_roles | Roles whose messages are checked. | user, tool | user, tool, system, assistant | all |
system_prompt_markers | Distinctive sentences of your system prompt. | none | up to 16; 8 to 256 bytes each; matched ignoring case and spacing | answers checked |
max_request_tokens | Largest single request. | 8000 | positive number | over it: 413 |
tokens_per_minute | Tokens per client and minute. | 20000 | positive number | over it: 429 in block mode |
tokens_per_day | Tokens per client, sliding 24 hours. | 500000 | positive number | over it: 429 in block mode |
cost_per_day | Cost per client per day. | 0 (no limit) | micro-units of your currency | over it: 429 in block mode |
models | Prices per model. | none | up to 32 entries of name, input_price, output_price | all |
on_injection | What an injection finding does. | log | log, refuse | refuse in block mode |
Limits
| Limit | Value |
|---|---|
| Endpoints per application | 32 |
| Paths per endpoint | 16 |
| System prompt markers per endpoint | 16 |
| Text read per request | 64 KiB |
| Messages classified per request | 8 (latest user message and tool results first) |
| One streamed event | 64 KiB |
| Held in a stream | 256 KiB |
| Scanned per streamed answer | 16 MiB |
| Usage kept | 90 days, 1,000 identities per application, day and node (others summed as other) |
Troubleshooting
Normal chats trip a signature rule
- Cause: chat text resembles code or commands.
- Fix: keep Spare chat text from CRS false positives on, and list the endpoint.
llm.classifier_unavailable appears
- Cause:
waap-promptcheckis not installed, not enabled, or too slow for the text. - Check:
waap api llm helper, or System > Helpers. - Fix: install and enable it, or raise the classifier time. The heuristics still apply.
A legitimate prompt is flagged
- Cause: a heuristic or the classifier scored it high.
- Check: Test a prompt shows the score and the matched phrases.
- Fix: add an
ignore_rulesexception for that path, or raise Classifier threshold.