liveBook · Manning

Web application firewall

As explained in Secure APIs

A web application firewall filters HTTP traffic to protect web applications and APIs from malicious requests.

A web application firewall (WAF) is an application-level firewall that usually runs as a reverse proxy in front of APIs. It inspects HTTP requests and blocks or cleans content that appears malicious, adding a security layer between clients and the application. section 2.3.4 section 9.4

WAFs are especially useful against recognized web threats such as SQL injection, cross-site scripting (XSS), SSRF, suspicious requests, and bots. Modern products may also support API-specific validation, zero-day protection, and attacks across lower networking layers. section 2.3.4 section 9.5

Blocking a malicious payments query

Consider GET /payments?filter=' or 1=1--. If the endpoint inserts filter into a database query, the payload can disable the user_id constraint and expose records belonging to other users. A WAF can recognize the injection and block the request or remove the malicious content. Cleaning is not automatically safe: an obfuscated request such as GET /payments?filter='+o//r+1=1-- can bypass some implementations and become executable after sanitization. section 9.4

Use a WAF as one part of a broader API security design:

  • Place it in front of APIs, commonly alongside an API gateway, to inspect incoming traffic and apply an additional protection layer. section 2.3.4 section 9.4
  • Feed modern WAFs an API specification when supported so their protections can match the API’s particular needs. section 2.3.4
  • Prefer carefully evaluated detection rules or probabilistic methods, recognizing that overly permissive rules miss attacks and overly strict rules can cause problems. section 9.4
  • Do not treat the WAF as a substitute for secure authorization: it does not prevent every API weakness, including BOLA, where users access data belonging to others. section 2.3.4
Figure 9.13 The OSI model breaks the elements required to enable communication between systems into seven layers. Layer 1 describes the physical medium, such as switches and cables, and layer 7 describes the application layer, such as APIs. Many API attacks target layers 3–6 and demand special security measures.
figure

Use the OSI-layer figure to place WAF protection in the application layer while distinguishing it from defenses for lower-layer attacks. section 9.3

How Secure APIs covers it

How deep it goes
Explains deployment, detection, blocking, sanitization, bypasses, and limitations, but stops short of product-specific configuration.
Examples
Uses payments-endpoint SQL injection payloads, obfuscation-based WAF bypass, and an OSI-layer figure.
What it assumes
Assumes basic awareness of APIs, HTTP requests, infrastructure, and application vulnerabilities such as SQL injection.
What you can do after
Evaluate WAF placement and coverage while testing injection defenses without mistaking perimeter filtering for complete API security.
How it connects
Connects WAFs with API gateways, reverse proxies, API specifications, SQL injection, XSS, SSRF, DoS, DDoS, and authorization weaknesses.

Also explained in

Compare how 2 books explain web application firewall →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.