LLMSec is a local Large Language Model (LLM) security console and guardrail firewall built using FastAPI and Ollama. It intercepts prompts and model responses in real-time, enforcing security policies to prevent prompt injections, system prompt leakages, and jailbreak attempts.
The application features a professional, modern security dashboard organized across multiple core modules:
- Description: Provides real-time request metrics, an interactive block-rate gauge, live execution pipeline telemetry, a prompt testing interface, and a live threat inspection log.
- Description: A dedicated audit view providing a full historical record of all processed prompts, latency metrics, and reason codes for blocked requests.
- Description: Displays the active regex pattern lists and phrase checks configured for both input screening and output guardrail validation.
- Description: An interactive tracking matrix mapping the firewall's current coverage against the OWASP Top 10 for LLM Applications (2025).
- Description: Monitors local model server availability, connectivity health, and currently pulled model variants.
- Input Guard: Inspects user prompts against a regex-based blocklist of known prompt injection phrases, jailbreak instructions, and extraction attempts.
- Canary Token Insertion: Dynamically generates and embeds a unique hidden canary token within the system prompt to detect unauthorized system instruction leaks.
- Output Guard: Scans model outputs for leaked canary tokens and sensitive phrase disclosures before sending them downstream.
- Pipeline Telemetry: Transparently monitors request execution stages (
input_guard,canary,model,output_guard) with latency tracking. - OWASP Alignment: Integrated guidance mapping the defense suite against critical risks like Prompt Injection (LLM01) and System Prompt Leakage (LLM07).
Before setting up LLMSec, make sure you have:
- Python: v3.8 or higher
- Ollama: Installed and running locally (
ollama serve) - Llama 3.2 Model: Pulled locally (
ollama run llama3.2:1b)
git clone https://github.com/MuhammadHamdan35/llmsec.git
cd llmsecInstall the required packages using pip:
pip install -r requirements.txtIn a separate terminal window, start your local Ollama server:
ollama serveAnd make sure the model is available:
ollama run llama3.2:1bStart the application server using Uvicorn:
uvicorn main:app --reloadOpen your web browser and navigate to:
http://127.0.0.1:8000
Muhammad Hamdan
- BS Cyber Security Undergraduate
- Specializing in AI security, LLM guardrails, and secure software architecture.




