Vulnerability Event and Security Systems Analysis
A self-hosted WAF with DistilBERT-based threat detection for developers who need customizable security
Features β’ Quick Start β’ Documentation β’ Architecture β’ Contributing
VESSA is an experimental, open-source Web Application Firewall that combines traditional pattern-based detection with machine learning models. It's designed for developers, security researchers, and teams looking for a self-hosted, customizable WAF solution.
- π¬ ML-Enhanced: Uses DistilBERT models for attack classification alongside regex patterns
- ποΈ Flexible Deployment: Reverse proxy, FastAPI middleware, or WSGI integration
- π Open Source: Apache 2.0 license - inspect, modify, and deploy however you want
- π Full Dashboard: React-based analytics UI for real-time threat monitoring
- π³ Docker-Ready: Deploy in minutes with Docker Compose
VESSA is functional and suitable for:
- Development/staging environments
- Security research and experimentation
- Small-to-medium traffic applications (<10K req/min)
- Learning WAF concepts and ML integration
Not recommended for:
- Production systems with critical data
- High-traffic applications without extensive testing
- Compliance-required environments (SOC 2, ISO 27001)
- β Inline Request Blocking - Real-time interception and blocking
- β
Multiple Deployment Modes
- Reverse proxy (protect any backend)
- FastAPI middleware (drop-in protection)
- WSGI integration (Flask, Django compatible)
- β Configurable Actions - Block, monitor, simulate, or challenge modes
- β IP Whitelist/Blacklist - Simple access control
- β Request Caching - Performance optimization with 5-minute TTL
- β
Dual-Model System
- Binary classifier (benign vs. malicious)
- Multi-class classifier (attack type identification)
- β DistilBERT Architecture - Pre-trained on ~50K samples
- β OOD Detection - Energy-based scoring for novel attacks
- β Async Processing - Optional background ML analysis for speed
- β SQL Injection - 15+ patterns with encoding variants
- β XSS - 15+ patterns (script tags, event handlers, etc.)
- β Path Traversal - 25+ patterns (URL encoded, double encoded)
- β Command Injection - Shell metacharacters and piping
- β NoSQL Injection - MongoDB operator detection
- β React 19 + TypeScript - Modern, type-safe frontend
- β Real-Time Metrics - Live threat detection statistics
- β Interactive Charts - Historical data visualization (Recharts)
- β Incident Management - Track and resolve security events
- β Dark/Light Themes - Responsive, accessible UI
- β FastAPI Backend - Async Python with Pydantic validation
- β MySQL + Redis - Persistent storage and caching
- β JWT Authentication - Secure API access
- β Database Migrations - Alembic-managed schema changes
- β Gunicorn + Nginx - Production deployment ready
- β Audit Logging - Comprehensive security event tracking
- Docker & Docker Compose (easiest option)
- OR Python 3.9+ with Poetry + Node.js 18+ + MySQL 8.0+ + Redis 6.0+
Get VESSA running in 5 minutes with Docker:
# 1. Clone the repository
git clone https://github.com/yourusername/vessa.git
cd vessa
# 2. Start all services (this will take a few minutes on first run)
docker compose up --build
# 3. Wait for services to start, then access:
# - Frontend Dashboard: http://localhost:5173
# - Backend API: http://localhost:8000
# - API Documentation: http://localhost:8000/docsFirst Time Setup:
- Register a new account at http://localhost:5173
- Login and generate an API key from Settings
- Start protecting your applications!
Verify Detection is Working:
# Option A: Inside Docker container
docker compose exec backend python verify_detection.py
# Option B: Locally (requires Poetry)
cd firewall-app
poetry install
poetry run python verify_detection.pyAlready have an app running? Protect it without code changes:
# 1. Install VESSA backend
cd firewall-app
poetry install
# 2. Start the WAF in reverse proxy mode
poetry run python -m services.waf.reverse_proxy \
--backend http://localhost:3000 \
--port 8080 \
--mode block
# 3. Your app is now protected!
# Access it through: http://localhost:8080
# All requests are analyzed and malicious ones are blockedFor developers who want full control:
# 1. Clone and setup infrastructure
git clone https://github.com/yourusername/vessa.git
cd vessa
docker compose up -d db redis # Start MySQL and Redis only
# 2. Setup backend
cd firewall-app
poetry install
cp env.example .env
# Edit .env with your database credentials
poetry run alembic upgrade head # Run migrations
poetry run uvicorn main:app --reload
# 3. Setup frontend (in a new terminal)
cd www/vite-project
npm install
echo "VITE_API_BASE_URL=http://localhost:8000" > .env
npm run dev
# 4. Access the application
# Frontend: http://localhost:5173
# Backend: http://localhost:8000
# API Docs: http://localhost:8000/docs-
Test the WAF: Use the verification script to ensure detection is working
cd firewall-app poetry run python verify_detection.py -
Configure Detection: Edit
firewall-app/.envto adjust WAF behaviorWAF_MODE=block # block, monitor, simulate, or challenge STATIC_ANALYSIS_ENABLED=1 # Pattern-based detection (recommended) DYNAMIC_ANALYSIS_ENABLED=0 # ML-based detection (optional, slower)
-
Integrate with Your App: See Integration Guide for:
- FastAPI middleware integration
- WSGI integration (Flask, Django)
- Reverse proxy configuration
-
Monitor Threats: Access the dashboard at http://localhost:5173 to view:
- Real-time threat detection
- Attack analytics and trends
- Incident management
vessa/
βββ absolution/ # ML Detection Engine
β βββ src/absolution/
β β βββ model_loader.py # DistilBERT model interface
β β βββ Models/ # Pre-trained binary & multi-class models (~50K samples)
β βββ pyproject.toml
β
βββ firewall-app/ # WAF Backend (FastAPI)
β βββ services/
β β βββ waf/ # WAF engine, middleware, reverse proxy
β β βββ incident/ # Threat analysis & incident management
β β βββ auth/ # JWT authentication
β β βββ common/ # Middleware, models, utilities
β βββ alembic/ # Database migrations
β βββ main.py # FastAPI application entry
β βββ gunicorn.conf.py # Production server config
β
βββ www/vite-project/ # Dashboard Frontend (React 19)
β βββ src/
β β βββ pages/ # Dashboard, incidents, alerts, settings
β β βββ components/ # Reusable UI components (Radix UI)
β β βββ lib/ # API clients, state, services
β βββ package.json # React 19, Vite 6.2, TypeScript
β
βββ docker-compose.yml # Full-stack deployment
Client Request
β
βββββββββββββββββββββββββββββββββββββββ
β WAF Middleware / Reverse Proxy β
β - Extract request features β
β - Check IP whitelist/blacklist β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Static Analysis (Fast Path) β
β - Regex pattern matching β
β - SQL injection, XSS, etc. β
β - ~1-5ms latency β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β ML Analysis (Optional) β
β - DistilBERT inference β
β - Binary + Multi-class models β
β - Energy-based OOD detection β
β - ~50-100ms latency (sync mode) β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Decision Engine β
β - Combine static + ML scores β
β - Apply threshold rules β
β - BLOCK / ALLOW / CHALLENGE β
βββββββββββββββββββββββββββββββββββββββ
β
Blocked (403) OR Forward to Backend
| Component | Description | Documentation |
|---|---|---|
| WAF Backend | FastAPI server, WAF engine, ML integration | firewall-app/README.md |
| Frontend | React dashboard for monitoring | www/vite-project/README.md |
| ML Models | DistilBERT classifiers | absolution/README.md |
| Deployment | Production setup guide | firewall-app/DEPLOYMENT_GUIDE.md |
| Metric | Status | Notes |
|---|---|---|
| Test Coverage | ~25% | Backend only; target: 80%+ |
| Performance | Untested | No load testing published |
| Throughput | Unknown | Needs benchmarking with wrk or locust |
| ML Accuracy | Untested in prod | Models trained on ~50K samples |
| False Positive Rate | Unknown | Requires real-world testing |
# Backend tests (limited coverage)
cd firewall-app
poetry run pytest --cov=services tests/
# Frontend linting
cd www/vite-project
npm run lintRequired:
DB_PASSWORD=your_secure_password
JWT_SECRET_KEY=$(openssl rand -hex 32) # Generate securely!
REDIS_URL=redis://localhost:6379/0Optional:
WAF_ENABLED=true # Enable inline WAF middleware
WAF_MODE=block # block, monitor, simulate, challenge
STATIC_ANALYSIS_ENABLED=1 # Enable pattern matching
DYNAMIC_ANALYSIS_ENABLED=1 # Enable ML modelsSee firewall-app/env.example for full config.
VITE_API_BASE_URL=http://localhost:8000
VITE_WS_BASE_URL=ws://localhost:8000- Docker & Docker Compose (recommended)
- Python 3.9+ with Poetry
- Node.js 18+ with npm/pnpm
- MySQL 8.0+ and Redis 6.0+ (or use Docker)
# 1. Clone repository
git clone https://github.com/yourusername/vessa.git
cd vessa
# 2. Start infrastructure (MySQL + Redis)
docker-compose up -d db redis
# 3. Backend setup
cd firewall-app
poetry install
cp env.example .env # Edit with your config
poetry run alembic upgrade head
poetry run uvicorn main:app --reload
# 4. Frontend setup (new terminal)
cd www/vite-project
npm install
echo "VITE_API_BASE_URL=http://localhost:8000" > .env
npm run devAccess:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
β οΈ Test Coverage: Only ~25% backend coverage; extensive testing neededβ οΈ Threat Intelligence: Demo data only; integrate real feeds (AbuseIPDB, etc.)β οΈ Performance: No published load testing resultsβ οΈ Bot Detection: Not implemented (planned feature)β οΈ DDoS Protection: L7 flood detection not availableβ οΈ Model Retraining: No pipeline documented; pre-trained models onlyβ οΈ False Positive Rate: Unknown; requires production validation
- Increase test coverage to 80%+
- Publish performance benchmarks (latency, throughput)
- Integrate commercial threat feeds
- Add bot detection and CAPTCHA challenges
- Document model retraining process
- Add Kubernetes deployment manifests
- Create learning mode (auto-rule generation)
We welcome contributions! Here's how you can help:
- Testing: Increase test coverage (especially WAF engine)
- Performance: Load testing and optimization
- Threat Intel: Real feed integrations
- Documentation: Tutorials, deployment guides
- ML Models: Adversarial testing, retraining pipelines
# 1. Fork and clone
git clone https://github.com/YOUR_USERNAME/vessa.git
cd vessa
# 2. Create feature branch
git checkout -b feature/amazing-feature
# 3. Make changes and test
cd firewall-app
poetry run pytest
# 4. Commit with clear message
git commit -m "feat: add amazing feature"
# 5. Push and create PR
git push origin feature/amazing-feature- Follow PEP 8 for Python code
- Use TypeScript strictly in frontend (no
anytypes) - Add tests for new features
- Update documentation
- Run linters before committing
Apache License 2.0 - see LICENSE file for details.
This allows you to:
- β Use commercially
- β Modify and distribute
- β Use privately
- β Use patent claims
Under conditions:
- βΉοΈ License and copyright notice
- βΉοΈ State changes made
Created by:
- Jash Naik (@infernus007) - jashnaik2004@gmail.com
- Raj Shekhar - infojar001@gmail.com
Built with:
- FastAPI - Modern Python web framework
- Hugging Face Transformers - DistilBERT models
- React - Frontend framework
- Radix UI - Accessible components
Inspired by:
- ModSecurity (pattern-based WAF)
- Cloudflare WAF (ML-powered detection)
- OWASP Core Rule Set
Open an Issue β’ Start a Discussion β’ Read the Docs
β Star this repo if you find it useful!
Built with β€οΈ by the VESSA team