WAF

On this page 7

A WAF (web application firewall) is a security control that inspects HTTP and HTTPS traffic at the application layer and blocks, logs or challenges requests that match attack patterns before they reach a web application or API. Unlike a network firewall, which decides on addresses, ports and protocols, a WAF understands URLs, headers, cookies, parameters and request bodies.

In infrastructure defense within cybersecurity, a WAF sits in front of web servers as a reverse proxy, a cloud edge service or a server module. It reduces exposure to injection, cross-site scripting, protocol abuse and automated attacks, and it gives teams a place to apply virtual patches while the underlying code is being fixed.

How a web application firewall inspects traffic

A WAF terminates or decrypts TLS so it can read the full request, then normalizes it by decoding URL encoding, Unicode and compression to defeat evasion. It evaluates the normalized request against rules and assigns a verdict: allow, block, challenge, rate-limit or log only.

Most rule engines use either pattern signatures for known attack strings or anomaly scoring, where each suspicious feature adds points and the request is blocked once the total crosses a threshold. The OWASP Core Rule Set for ModSecurity-compatible engines is the best-known example of anomaly scoring, with paranoia levels from 1 to 4 that trade coverage for false positives.

ApproachHow it decidesStrengthWeakness
Negative security modelBlocks requests matching known attack signaturesQuick to deploy, broad coverageMisses novel or obfuscated payloads
Positive security modelAllows only requests matching a defined schemaStrong against unknown attacksHigh maintenance as the application changes
Anomaly scoringSums risk points across many rulesTunable sensitivityThresholds need careful calibration
Behavioral and ML modelsCompares traffic with learned baselinesCatches bots and abuse patternsOpaque decisions, possible drift
WAF detection approaches

Deployment models

Where the WAF runs determines latency, visibility and operational ownership. Many organizations combine a cloud edge WAF for volumetric and bot traffic with a closer control for internal or API traffic.

DeploymentPlacementBest fitMain trade-off
Cloud or CDN WAFAt the provider edge before the originPublic sites, global trafficOrigin must be locked to the provider
Appliance or virtual applianceReverse proxy in the data centerRegulated on-premises environmentsCapacity planning and hardware cost
Host-based moduleInside the web server processSingle applications, low costConsumes application server resources
Ingress or sidecar WAFKubernetes ingress or service meshMicroservices and internal APIsRule consistency across many instances
WAF deployment options

A common mistake with cloud WAFs is leaving the origin server reachable directly. Attackers who discover the origin address bypass every rule, so the origin should accept traffic only from the WAF provider’s ranges or through an authenticated tunnel.

WAF compared with other infrastructure defenses

A WAF is one layer among several, and its value comes from application-layer context that other controls lack. It does not replace a network firewall, an intrusion prevention system or DDoS mitigation.

ControlLayerPrimary focus
Network firewallLayers 3 and 4Addresses, ports, connection state
IPSMostly layers 3 to 7Exploit signatures across many protocols
WAFLayer 7, HTTP onlyWeb attacks, virtual patching, bot control
DDoS mitigationLayers 3 to 7Absorbing and filtering traffic floods
API gatewayLayer 7Authentication, quotas, routing for APIs
WAF and neighboring defensive controls

Next-generation firewalls often include web inspection features, but a dedicated WAF usually offers deeper HTTP parsing, request body inspection and finer rule tuning for specific applications.

Tuning and operating a WAF

A WAF delivers protection only after tuning against real traffic. The standard rollout starts in detection-only mode for one to several weeks, reviews the logged matches, writes exclusions for legitimate patterns and then switches to blocking.

  • Scope exclusions narrowly: disable a rule for one parameter on one path, never globally.
  • Raise sensitivity gradually: move to a higher paranoia level only after false positives at the current level are resolved.
  • Use virtual patches with expiry: a temporary rule for a known vulnerability should be removed once the code is fixed.
  • Inspect API payloads: enable JSON and XML parsing and enforce schemas where they exist.
  • Send logs to the SIEM: correlate WAF events with authentication and endpoint data.

Request body inspection usually has a size limit, often in the range of 8 KB to 128 KB. Payloads beyond the limit are either passed uninspected or rejected, and that setting must be chosen deliberately.

Limitations and common misconceptions

A WAF is a compensating control, not a fix for insecure code. It sees requests but rarely understands business logic, so several classes of weakness pass through it unchallenged.

WeaknessWAF effectivenessReason
SQL injection and XSSGood with tuned rulesPayloads have recognizable structure
Credential stuffingPartialNeeds bot detection and rate limits
Broken access controlPoorValid-looking requests for unauthorized objects
Business logic abusePoorRequires knowledge of application rules
Encoded or novel payloadsVariableDepends on normalization and rule quality
What a WAF can and cannot address

Put simply

A web application firewall is like a security guard at the entrance of a shop who checks every parcel before it goes in. The guard knows what dangerous parcels tend to look like and turns away anything suspicious before it reaches the shelves.

The guard does not fix weak locks inside the shop, and a clever visitor with a normal-looking parcel may still get through. It is a valuable first check, not a replacement for a well-built shop.

In practice

An online retailer learns on a Friday evening that the plugin powering its product search has a critical SQL injection flaw, and the vendor fix will not be available until the following week. The security team writes a virtual patch in its cloud WAF that blocks SQL metacharacters in the search parameter on that single path and deploys it in under an hour.

Over the weekend, the WAF logs several thousand blocked exploitation attempts from automated scanners, while normal searches continue to work because the rule is scoped narrowly. When the vendor patch arrives, the team applies it, confirms the fix with a scan and removes the temporary rule so that the WAF configuration does not accumulate outdated exceptions.