Application and Network Security

What Is a WAF? How a Web Application Firewall Works

Nanda Teknoloji Engineering Team · · 7 min read

In brief

A WAF is a security layer that inspects HTTP/HTTPS requests to a web application at the application layer and allows, blocks, or challenges them according to rules. It catches requests a network firewall cannot see, such as SQL injection, XSS, and bot traffic, but it does not replace fixing logic flaws in the application.

A WAF (Web Application Firewall) is a security layer that inspects HTTP and HTTPS requests coming to a web application at the application layer (layer 7 of the OSI model) and, according to predefined rules, lets the request through, blocks it, or routes it to additional verification. A traditional network firewall only looks at “who is connecting to which port.” A WAF looks at the path, parameters, headers, and body inside the request and answers “is this request trying to harm the application?” That is why attacks such as SQL injection, XSS, malicious file upload attempts, and automated bot traffic, which pass the network layer, can be caught at the WAF. A WAF is not sufficient on its own; it is a layer that works together with secure coding and patch management.

Why is a WAF needed?

The moment a web application is exposed to the internet, it faces requests that anyone can send. Port 443 has to be open, and the network firewall cannot close this port. The attack also comes through this very legitimate-looking door: a piece of SQL planted in a search box, password lists automatically tried against a login form, or an unexpected JSON field sent to an API endpoint.

There are three core situations where a WAF delivers value:

  • Cutting off known attack patterns early. SQL injection and XSS attempts have recognizable signatures.
  • Closing the patch gap. When a vulnerability is announced in a component, updating the application can take days. A temporary rule (virtual patch) on the WAF bridges that time.
  • Providing visibility. Seeing from one place which paths are being scanned and which countries and clients abnormal traffic is coming from speeds up incident response.

How does a WAF work?

In most enterprise setups, the WAF is placed in front of the application as a reverse proxy. The client connects not directly to the application but to the WAF; the WAF inspects the request and, if it finds it clean, forwards it to the backend.

  1. Connection termination. The WAF opens the TLS connection at its own end and decrypts the request. This is how it can see the content of encrypted traffic.
  2. Normalization. Attackers try to bypass rules by encoding characters (URL encoding, double encoding, case tricks). The WAF converts the request into a standard form.
  3. Rule evaluation. The request is compared against signature rules, behavior rules, rate limits, and IP reputation checks.
  4. Decision. The result is allow, block, log, or an additional challenge (for example, bot verification).
  5. Forwarding and logging. The request that passes goes to the application, and all decision details are written to the log.

Security models: negative, positive, and behavioral

Model Logic Strength Weakness
Negative (blocklist) Blocks known bad patterns Deployed quickly, provides general protection May miss new and encoded attacks
Positive (allowlist) Accepts only defined valid requests Very tight protection Maintenance burden grows as the application changes
Behavioral Derives anomalies from request rate, sequence, and client characteristics Effective for bots and low-rate scans Getting the thresholds right takes time

In practice, mature setups start with the negative model, add positive rules for critical endpoints (login, payment, API), and use behavioral control for bot management.

What does a WAF block, and what does it not?

If expectations of a WAF are not set correctly, disappointment is inevitable. The table below offers a realistic framework. Our article OWASP Top 10 and WAF, which covers in detail which risk falls into which category, deepens this table.

Threat WAF effect Explanation
SQL injection, XSS, path traversal Strong Caught with signatures and normalization
Automated scanning and credential stuffing Strong Rate limiting and bot challenge
Exploitation of known component vulnerabilities Medium-strong The virtual patch rule must be up to date
Broken access control (accessing someone else’s record) Weak The request looks legitimate; the logic lives in the application
Business logic abuse Weak A design problem, not a rule problem
Volumetric DDoS Insufficient alone Network-level mitigation is needed, see DDoS types

Deployment models

A WAF can run in different locations, and the choice shapes your operating model.

  • Cloud-based (edge) WAF. Traffic is filtered in a distributed network before reaching your application. When it runs in the same layer as a CDN, both caching and protection are managed from a single point.
  • In-network (appliance or virtual) WAF. Runs in your own data center or cloud environment; provides full control over traffic and custom TLS management.
  • In-application (host-based) module. Added to the web server; offers deep visibility, but the performance and maintenance burden falls on the server.

Many organizations use an edge WAF for all internet-facing domains and an additional strict layer for sensitive internal applications. The decision depends on traffic volume, compliance requirements, and the team’s capacity to manage rules.

Deployment: step by step

  1. Take an inventory. Which domains, subdomains, and API endpoints are exposed to the internet? Forgotten test environments are the most commonly missed surface.
  2. Learn the traffic baseline. Plan a monitoring period to learn normal request volume, methods, geography, and client distribution.
  3. Start in monitoring (log-only) mode. Let the rules decide but not block. You see false positives without harming production traffic.
  4. Weed out false positives. Rich-text editors, search queries, and JSON bodies are frequent triggers. Define exceptions narrowly by path and parameter, not by turning the rule off.
  5. Gradual blocking. High-confidence rules (clear SQL injection patterns) are moved to blocking mode first, then the others.
  6. Set up alerts and the log flow. WAF logs should flow to a SIEM or a central logging platform, and alerts should be defined for abnormal spikes.
  7. Review regularly. As the application version changes, the rules change too; add a WAF check to every release cycle.

A scenario: an order form cut off by a false positive

A retail organization enables the WAF directly in blocking mode. Within a few hours, customer service reports that orders containing an apostrophe in the address field are failing. The rule treated the apostrophe as a sign of SQL injection and cut the request. The right approach is not to turn the rule off but to define an exception only for the relevant parameter on this form path; it is also necessary to verify that the application uses parameterized queries. A week spent in monitoring mode would have surfaced this problem before customers saw it.

Common mistakes

  • Installing the WAF and leaving it. Rule sets and the application change over time; an unmaintained WAF both leaves gaps and produces false positives.
  • Switching directly to blocking mode. It causes business loss, as in the scenario above.
  • Leaving the backend IP exposed. If an attacker can bypass the WAF and connect directly to the server, there is no protection. Open the backend only to traffic from the WAF’s IP ranges.
  • Protecting only the main domain. API subdomains and old environments are forgotten.
  • Not reviewing the logs. The number of blocked requests is not a success metric by itself; you need to know what was blocked and why.
  • Over-trusting the WAF and neglecting the code. A virtual patch is temporary; the permanent solution is a code fix.

Decision summary

Question If yes
Do you have an internet-facing application that takes user input? A WAF is necessary
Is your patch cycle slow, or are you running outdated components? Prioritize the WAF for virtual patching
Are you seeing automated attacks on login/payment flows? Add bot management and rate limiting
Is your in-house expertise for managing rules limited? Consider a managed WAF service

The general approach, in short: map the entire internet-facing surface, start in monitoring mode, tighten rules gradually, and review results regularly. To understand attack behavior, you can turn to the WAF glossary entry, and for the list of core security risks, the OWASP Top 10 project.

Moving forward with Nanda Teknoloji

On projects like this, Nanda Teknoloji carries out the discovery, design, migration, and operations steps: an inventory of the internet-facing surface, deployment in monitoring mode, rule tuning, and continuous operations. For our approach that addresses WAF and volumetric attack protection together, take a look at the WAF and DDoS protection page.

Frequently asked questions

What is the difference between a WAF and a network firewall?

A network firewall decides at the IP, port, and protocol level. A WAF looks at the content of the HTTP request: the path, parameters, headers, and body.

Does a WAF require code changes in the application?

Usually not. A WAF sits in front of the application and receives traffic as a proxy; still, you need to know how the application works in order to tune the rules.

Is it safe to enable a WAF directly in blocking mode?

It is not recommended. It is safer to run it first in monitoring (log) mode only, weed out false positives, and then move rules to blocking mode gradually.

How does a WAF inspect TLS traffic?

The WAF terminates the encrypted connection at its own end, decrypts and inspects the request, and re-encrypts it to the backend if needed. That is why certificate management is part of the design.

Related solutions

Related posts

Let's plan your critical systems together

Tell us what you need; our team will work out the right architecture and migration path with you.