Skip to content

Repository files navigation

LLM Detection Rules

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.

What's in here

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

OWASP Coverage

ID Risk Detected
LLM01 Prompt Injection
LLM02 Sensitive Information Disclosure
LLM06 Excessive Agency (unauthorized tool calls)
LLM07 System Prompt Leakage

How to run

# 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.jsonl

False positive note

Pattern 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.

Personal project — independent research

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages