What Is a Web Application Firewall (WAF) and How Does It Work?

Your public website runs on the open internet every hour of every day. Attackers scan it without pause, probing login forms, search boxes, and API endpoints for one weak input. A network firewall waves this traffic through, because the request looks like normal web traffic on port 443. A web application firewall reads the request itself, spots the attack hidden inside, and blocks it before your application ever sees it. If you run anything customer-facing, you need to understand how this control works.
A web application firewall, or WAF, sits in front of your web applications and inspects every HTTP and HTTPS request. It applies a set of rules to each request and response. When a request matches a known attack pattern, the WAF blocks it. When a request looks safe, it passes through to your application. OWASP describes a WAF as an application firewall for HTTP traffic, often deployed as a reverse proxy in front of the server it protects.
Why Web-Facing Applications Draw Attacks
Your web applications face the internet by design, so they sit exposed around the clock. Attackers favour them because one flaw in your code reaches straight into your data. The 2025 Verizon Data Breach Investigations Report found exploitation of vulnerabilities rose to 20 percent of breaches as an initial access route, a sharp climb year over year. Web application attacks rank among the top breach patterns across finance, retail, and the public sector. The Canadian Centre for Cyber Security places the protection of web-facing applications in its Top 10 IT security actions for a reason. A WAF is a frontline part of the answer.
How a WAF Differs From a Network Firewall
A network firewall works at the network layer. It decides which ports, protocols, and IP addresses to allow. It knows nothing about the content of a web request. A WAF works at the application layer, Layer 7 in the OSI model. It reads the full HTTP request, including headers, cookies, form fields, and the URL. This difference matters. An attacker sends a malicious database command through a login form over port 443. Your network firewall allows it, because port 443 stays open for your website. A WAF inspects the form input, recognizes the attack, and stops it. A network firewall guards the doors and windows. A WAF reads the mail coming through them.
What Attacks a WAF Blocks
A WAF targets the attacks aimed at your application logic. It blocks SQL injection attempts, where an attacker slips database commands into an input field. It blocks cross-site scripting, where an attacker plants malicious scripts to run in a visitor’s browser. It filters out path traversal, command injection, and many of the risks named in the OWASP Top 10. It also throttles automated abuse, from credential stuffing against your login page to bots scraping your data. These are the attacks a traditional firewall never sees, because they hide inside traffic a network firewall treats as normal.
Positive and Negative Security Models
A WAF enforces rules in two ways. A negative security model blocks known bad patterns. It carries a signature list of attack strings and rejects any request matching one. This model deploys fast and catches common attacks. A positive security model works the other way. It defines what good traffic looks like and rejects everything else. This model runs stronger, because it stops attacks no signature has seen yet, but it demands careful tuning for each application. Most mature deployments blend both, starting with signatures and adding positive rules over time.
Where You Deploy a WAF
You run a WAF in one of three places. A network-based WAF sits as hardware or a virtual appliance inside your own data centre, close to the application, with low latency. A host-based WAF installs as a module on the web server itself, which gives deep integration but consumes server resources. A cloud-based WAF runs as a service in front of your site, filtering traffic before it reaches your infrastructure. Cloud WAFs scale fast and need no hardware, which makes them a common choice for smaller teams. The Canadian Centre for Cyber Security recommends web application firewalls within its guidance on isolating web-facing applications, the ninth of its Top 10 IT security actions.
A WAF Is Not a Complete Defence
A WAF reduces risk. It does not erase it. A misconfigured WAF blocks real users or lets real attacks through. Attackers study WAF rules and shape payloads to slip past them, so a WAF alone never replaces secure code. OWASP notes a WAF needs tuning to each application and ongoing maintenance as the application changes. Treat it as one layer in a defence-in-depth approach. Secure development, input validation, patching, and vulnerability testing all sit alongside it. The Canadian Centre for Cyber Security also advises isolating web-facing applications and applying least privilege, so an exploit stays contained even when it lands.
The Skills Behind Web Application Defence
A WAF performs only as well as the people who configure and test it. Someone has to write the rules, tune the policies, read the alerts, and confirm the application behind it stays sound. Mile2 builds those skills through role-based training. The Certified Secure Web Application Engineer teaches developers to build applications resistant to the attacks a WAF screens, so your defence starts in the code. The Certified Web Security Engineer develops the hands-on skills to secure and defend web systems end to end. For the offensive view, the Certified Penetration Testing Engineer trains your team to test a WAF the way a real attacker would, finding the gaps before someone else does.
A web application firewall gives your public-facing systems a reading brain at the front door. It inspects every request, blocks the attacks your network firewall misses, and buys your team time to patch and respond. Deploy it as one layer, keep it tuned, and pair it with secure code and trained people. Do the work, and the login form an attacker treats as a way in becomes the wall stopping them cold.
