Skip to content

Repository files navigation

LLMSec :: LLM Security Console

FastAPI Python Ollama Security

📌 Overview

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.

🖥️ Graphical User Interface (GUI) Showcase

The application features a professional, modern security dashboard organized across multiple core modules:

1. Tactical Dashboard

  • 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.
LLMSec Dashboard

2. Live Request Log

  • Description: A dedicated audit view providing a full historical record of all processed prompts, latency metrics, and reason codes for blocked requests.
Live Request Log

3. Guard Rules

  • Description: Displays the active regex pattern lists and phrase checks configured for both input screening and output guardrail validation.
Guard Rules View

4. OWASP Top 10 for LLMs Matrix

  • Description: An interactive tracking matrix mapping the firewall's current coverage against the OWASP Top 10 for LLM Applications (2025).
OWASP Top 10 Matrix

5. Ollama Health & Connection Status

  • Description: Monitors local model server availability, connectivity health, and currently pulled model variants.
Ollama Status View

✨ Core Features

  • 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).

📋 Prerequisites

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)

🛠️ Installation & Setup

Step 1: Clone the Repository

git clone https://github.com/MuhammadHamdan35/llmsec.git
cd llmsec

Step 2: Install Dependencies

Install the required packages using pip:

pip install -r requirements.txt

Step 3: Ensure Ollama is Running

In a separate terminal window, start your local Ollama server:

ollama serve

And make sure the model is available:

ollama run llama3.2:1b

Step 4: Launch the FastAPI Application

Start the application server using Uvicorn:

uvicorn main:app --reload

Step 5: Access the Console

Open your web browser and navigate to:

http://127.0.0.1:8000

👨‍💻 Author

Muhammad Hamdan

  • BS Cyber Security Undergraduate
  • Specializing in AI security, LLM guardrails, and secure software architecture.

About

A local LLM security console and guardrail framework built with FastAPI, Ollama, and a clean web UI. Features real-time prompt injection detection, output canary token checks, pipeline monitoring, and an OWASP Top 10 for LLMs tracking matrix.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages