A minimal tool for testing whether a local LLM leaks a secret it was told to protect.
Sends test prompts to a model running locally through the Ollama API, then checks the model's response for a secret string it was instructed to guard. It inspects only the model's output, independently of the input prompt — a minimal output-side guardrail.
Built as a hands-on study of prompt injection: one side sets up a defense (the system instruction), one side attacks it (the prompt), and the detector judges whether the attack got through.
- Python 3
- requests — install with pip install requests
- Ollama running locally with a model pulled (https://ollama.com)
Fill in the placeholders in the script:
- plist — secret string(s) to watch for in the response
- prompts — injection attempts to test
- "system" — instruction telling the model to guard the secret
- "model" — name of your local model
Then run:
python LLM-leak-detector.py
For each prompt the script prints the model's response and reports LEAKAGE if the secret appears, or No leakage or triggers if it holds.
Matches whole words only. A secret leaked character-by-character (e.g. P, A, S, S, W) is not detected. Planned next step: pattern-based detection with regular expressions.