AI Security Rules
Standard Security Group rules match on fixed conditions — IP, country, headers, and so on. AI Security Rules instead route a request through an LLM, using natural-language instructions to make a judgment call that's genuinely subjective — whether a written answer is plausible, whether a submission looks like a real application, and so on.
Setup
- Finish installing Sentinel.
- Configure an AI Provider.
- In a Security Group, switch to Advanced view.
- Add a rule with action Set, field AI Prompt.
- Write your evaluation instruction.
[{ "action": "set", "set": [{ "field": "ai", "value": "Allow if the field..." }] }]How it works
The AI evaluator receives the submitted fields as structured JSON — kept separate from your instruction, to resist prompt injection — and must respond with strictly true or false. Sentinel then allows or denies the request accordingly.
Writing prompts
Be explicit and closed-ended rather than open-ended:
- "Allow only if the answer in field
security_answercontains a correct answer to thesecurity_question." - "Deny if
countryCodeis not in Europe."
Context
The prompt automatically has access to these built-in fields:
browser— e.g. Chrome, Firefox.countryCode— ISO country code, resolved from IP/timezone.device—desktop,mobile,tablet,smartTV,wearable, orbot.penalty— the request's accumulated penalty score (0–10), if any.
For anything beyond these, use Context Override to pass additional context statically or dynamically.
Use cases
- Security questions — validate a free-text answer against the expected one.
- Job applications — flag low-effort or clearly irrelevant submissions.
- Event registrations — screen for plausible, on-topic responses.
- Scholarship/grant applications — check written responses meet basic criteria.
- High-value form submissions — add a judgment layer beyond pattern-based rules.
Usage with redirects
AI Security Rules can gate a Links and Redirects destination — add a field with a security question to the redirect page, then write a prompt evaluating the answer before allowing the redirect through.
Testing
Use the Classifier API endpoint to submit sample fields and see how your AI rule responds before enabling it in production.
Tips
- Expect latency: evaluation against a hosted provider (e.g. ChatGPT, Gemini) can take several seconds.
- For privacy or latency-sensitive setups, consider a self-hosted model (e.g. LLaMA via Ollama) instead of a hosted provider.
Related
- AI Providers — required setup before writing an AI rule.
- Custom Parameters & Context Override — passing extra context into the prompt.
- Security Groups — where AI rules live alongside standard rules.