The Web Application Firewall (WAF) is a security solution designed to protect web applications from malicious attacks such as SQL Injection, Cross-Site Scripting (XSS), and DDoS attacks. This firewall inspects, filters, and monitors incoming HTTP/HTTPS requests to ensure only legitimate traffic reaches the server.
- Filters incoming requests based on IP addresses, URLs, and User-Agent headers.
- Maintains a blacklist and whitelist for access control.
- Detects and blocks SQL Injection (SQLi) and Cross-Site Scripting (XSS) attacks using predefined patterns and regex-based detection.
- Identifies unusual request patterns and potential zero-day attacks by analyzing request frequency, payload size, and behavior.
- Implements rate limiting to restrict excessive requests from a single IP.
- Mitigates Distributed Denial-of-Service (DDoS) attacks by monitoring and blocking suspicious traffic.
- Stores and enforces a list of blocked and allowed IPs to control access dynamically.
- Ensures incoming requests follow proper HTTP/HTTPS standards.
- Blocks malformed requests, unexpected HTTP methods, and protocol violations.
- Scans request bodies and responses for sensitive data exposure.
- Prevents leakage of critical information such as credit card numbers, passwords, and PII.
- Captures detailed logs of all incoming requests and blocked attacks.
- Provides real-time monitoring through a dashboard.
- Ensures encrypted communication between clients and the server using HTTPS.
- Can be integrated with Nginx as a reverse proxy for SSL termination.
- Node.js (v16+)
- MongoDB (for logging and blacklisting features)
- Nginx (for optional reverse proxy & SSL termination)
# Clone the repository
git clone https://github.com/SagarMaddela/Web-Application-Firewall.git
cd waf
# Install dependencies
npm install
# Configure environment variables
cp .env.example .env
# Update .env with MongoDB credentials and JWT secret
# Start the server
npm start
Use Postman or CURL to send malicious payloads:
curl -X GET "http://localhost:5000/?search=SELECT * FROM users"
curl -X POST "http://localhost:5000/submit" -d "<script>alert('XSS')</script>"
Expected Result: The WAF should block the request and return a 403 Forbidden response.
for i in {1..20}; do curl -X GET "http://localhost:5000/api/resource"; done
Expected Result: Requests exceeding the threshold should be blocked with 429 Too Many Requests.
✅ Protection against SQL Injection & XSS attacks
✅ Rate limiting to prevent API abuse & DDoS
✅ Logging & monitoring for real-time threat detection
✅ IP whitelisting/blacklisting for access control
✅ SSL/TLS support for secure communication
- 🔍 Machine Learning-based Threat Detection (AI-driven anomaly detection)
- 📊 Admin Dashboard for managing security rules & logs
- 🏢 Multi-Tenant Support for cloud-based WAF deployment
This project is licensed under the MIT License.
We welcome contributions! Feel free to submit pull requests or open issues.
For inquiries or support, contact us at mrsunday0708.23@gmail.com.