A Web Application Firewall (WAF) operates at Layer 7 of the OSI model, inspecting HTTP/HTTPS traffic between the web application and the internet. Unlike network firewalls that filter based on IP and port, a WAF analyzes the payload of requests and responses to identify malicious patterns.
WAF Architectures and Deployment
WAFs can be deployed as network appliances, host-based plugins (e.g., ModSecurity for Nginx/Apache), or cloud-based services (e.g., AWS WAF, Cloudflare). For senior engineers, the choice often involves trade-offs between latency, control, and maintenance overhead.
The OWASP Core Rule Set (CRS)
The OWASP CRS is a set of generic attack detection rules for use with ModSecurity or compatible WAFs. It protects against many common attack categories, including SQL Injection (SQLi), Cross-Site Scripting (XSS), and Local File Inclusion (LFI).
A critical concept in CRS is Anomaly Scoring. Instead of blocking a request immediately upon matching a single rule, the WAF increments an anomaly score. Only when the score exceeds a configured threshold is the request blocked. This reduces false positives compared to a strict 'match-and-block' approach.