Detection logic for monitoring and identifying abuse patterns in locally hosted LLM deployments.
Covers prompt injection attempts, system prompt leakage, request volume abuse, and unauthorized tool calls — mapped to OWASP Top 10 for LLM Applications 2025.
| File | What it detects |
|---|---|
logger.py |
Logs every prompt + response to structured JSONL |
detect.py |
Runs detection rules against the log file |
rules/LLM01-prompt-injection.py |
Known injection phrasing in user input |
rules/LLM02-volume-abuse.py |
Unusual request volume from single user |
rules/LLM07-prompt-leakage.py |
Responses that resemble system prompt leakage |
sample-logs/example.jsonl |
Sample log file to test detection against |
| ID | Risk | Detected |
|---|---|---|
| LLM01 | Prompt Injection | ✅ |
| LLM02 | Sensitive Information Disclosure | ✅ |
| LLM06 | Excessive Agency (unauthorized tool calls) | ✅ |
| LLM07 | System Prompt Leakage | ✅ |
# 1. Install dependencies
pip install ollama
# 2. Start logging (wraps your local Ollama model)
python logger.py
# 3. Run detections against the log
python detect.py --log sample-logs/example.jsonlPattern matching on injection phrases will fire on users legitimately discussing AI security. Known FP sources are documented in each rule file. A detection that volunteers its own false positive rate is more useful than one that does not.