A security-focused full-stack application that detects and blocks malicious HTTP requests while providing JWT-based authentication and protected API access.
This project implements a custom Web Application Firewall (WAF) that inspects incoming HTTP requests before they reach application routes.
It detects threats such as SQL injection, XSS, path traversal, and suspicious requests, while also providing dynamic IP blocking, rate limiting, security logging, and JWT authentication.
Frontend:
https://waf-jwt-frontend.vercel.app
Backend API:
https://waf-jwt.onrender.com
The WAF operates as middleware within the Express.js backend and analyzes incoming HTTP requests before they reach application routes.
Suspicious or malicious requests can be blocked automatically, with the source IP temporarily added to a dynamic block list.
The application also includes JWT-based authentication, protected routes, and refresh-token handling.
User
β
βΌ
React Frontend
(Vercel)
β
βΌ
Express Server
(Render)
β
βΌ
Custom WAF Middleware
β
βββ Request Inspection
βββ Threat Detection
βββ Rate Limiting
βββ IP Blocking
β
βΌ
JWT Authentication
β
βΌ
MongoDB Atlas
- SQL Injection detection
- XSS detection
- Path traversal protection
- Suspicious user-agent detection
- Request payload inspection
- Dynamic IP blocking
- Rate limiting
- Security logging
- JWT access tokens
- Refresh token system
- Protected API routes
- Automatic token refresh using Axios interceptors
- Express REST API
- Middleware-based WAF filtering
- MongoDB user storage
- Helmet security headers
- CORS protection
- React + Vite
- Login and registration pages
- Axios interceptors for authentication
- Protected dashboard route
- React
- Vite
- Axios
- React Router
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- Vercel β Frontend
- Render β Backend
- MongoDB Atlas β Database
POST /api/auth/register
POST /api/auth/login
POST /api/auth/logout
POST /api/auth/refresh
GET /api/users/me
GET /health
The WAF inspects incoming requests for suspicious patterns associated with common web attacks.
Example malicious input:
' OR 1=1 -- UNION SELECT DROP TABLE
Example:
<script> onerror= javascript:Example:
../
%2E%2E
When a malicious request is detected, the request can be blocked:
{
"ok": false,
"reason": "malicious_payload"
}Incoming Request
β
βΌ
WAF Middleware
β
βΌ
Request Inspection
β
βββ Malicious βββΊ Block / Log
β
βββ Safe
β
βΌ
JWT Authentication
β
βΌ
Protected Route
β
βΌ
Database
git clone https://github.com/Developer-Sohail786/WAF-JWT.git
cd WAF-JWTcd Backend
npm installOpen another terminal:
cd Frontend
npm installCreate:
Backend/.env
Add:
MONGO_URL=your_mongodb_uri
ACCESS_TOKEN_SECRET=your_secret
REFRESH_TOKEN_SECRET=your_secret
ACCESS_TOKEN_EXPIRY=1d
REFRESH_TOKEN_EXPIRY=7d
WAF_ENABLED=truenpm startInside the Frontend directory:
npm run devWAF-JWT/
β
βββ Backend/
β βββ ...
β βββ ...
β
βββ Frontend/
β βββ ...
β βββ ...
β
βββ README.md
The project combines multiple security mechanisms:
- Custom WAF middleware
- SQL injection detection
- XSS detection
- Path traversal protection
- Dynamic IP blocking
- Rate limiting
- Security logging
- JWT authentication
- Refresh tokens
- Protected routes
- Helmet security headers
- CORS protection
Sohail Khan
Full-Stack Developer | Backend | Web Security
This project is licensed under the MIT License.