Skip to content

About

Minimal prompt-injection leak detector for local LLMs via Ollama

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

LLM-leak-detector — Prompt-Injection Leak Detector

A minimal tool for testing whether a local LLM leaks a secret it was told to protect.

What it does

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.

Requirements

  • Python 3
  • requests — install with pip install requests
  • Ollama running locally with a model pulled (https://ollama.com)

Usage

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.

Limitations

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.

About

Minimal prompt-injection leak detector for local LLMs via Ollama

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages