WAF: Wrong Approach Firewall
slink
Gulaschprogrammiernacht 24 (GPN24) · Day 4 · ZKM Medientheater
Overview
In his GPN24 talk, "WAF: Wrong Approach Firewall," independent developer and consultant slink delivers a passionate and technically detailed critique of conventional Web Application Firewall (WAF) implementations, particularly those adhering to a negative security model. Drawing upon his extensive experience as a maintainer of the open-source reverse proxy software Vinyl Cache (formerly Varnish Cache) and his work with large-scale CDNs, slink argues that the prevailing approach to WAFs is fundamentally flawed, offering a false sense of security and failing to address modern web application threats effectively. He champions a radical shift towards a positive security model, advocating for explicit allowance of known good traffic rather than attempting to block all known bad.

Key moments
- 0:00 Introduction to the talk and digital sovereignty
- 10:30 Why traditional network firewalls are no longer sufficient
- 14:40 Critiquing the 'Wrong Approach Firewall' (negative security model)
- 20:50 The 'Right Approach': Positive security model WAF
- 28:50 Using cryptographic signatures for robust web security
- 44:50 Efficiently building a positive WAF with pattern matching
- 53:00 A simple yet highly effective positive security WAF
- 59:00 Q&A: Preventing malicious values in allowed parameters
WAF: Wrong Approach Firewall
Speakers: slink
Conference: GPN24
YouTube: https://www.youtube.com/watch?v=BOGUwO2kPLo
Overview
In his GPN24 talk, "WAF: Wrong Approach Firewall," independent developer and consultant slink delivers a passionate and technically detailed critique of conventional Web Application Firewall (WAF) implementations, particularly those adhering to a negative security model. Drawing upon his extensive experience as a maintainer of the open-source reverse proxy software Vinyl Cache (formerly Varnish Cache) and his work with large-scale CDNs, slink argues that the prevailing approach to WAFs is fundamentally flawed, offering a false sense of security and failing to address modern web application threats effectively. He champions a radical shift towards a positive security model, advocating for explicit allowance of known good traffic rather than attempting to block all known bad.
The talk is not merely a criticism but a blueprint for a more robust and proactive security posture. Slink emphasizes digital sovereignty, urging organizations to regain control over their technology stack, moving away from centralized cloud oligopolies that often necessitate breaking TLS (Transport Layer Security) for traffic inspection. He proposes a WAF design centered on cryptographic signing of URLs and cookies, combined with stringent, application-specific pattern matching using regular expressions (regex). This approach, he contends, offers superior protection, including against zero-day vulnerabilities, while simultaneously improving caching efficiency and overall system resilience.
Slink's presentation is a call to action for developers and security professionals to rethink their WAF strategies. By demonstrating how to build a truly effective WAF using readily available tools and a deep understanding of HTTP, he empowers the audience to implement more secure, efficient, and self-controlled web infrastructures. The principles discussed are not tied to any specific software, though Vinyl Cache serves as a practical example, making the insights broadly applicable across diverse technology stacks.
Background
▶ Watch: Introduction to the talk and digital sovereignty (0:00)
The evolution of network security has seen a continuous arms race between defenders and attackers. Traditionally, network firewalls operated at layers three and four of the OSI model, filtering traffic based on IP addresses and ports. This approach was effective for its time, allowing administrators to define a positive security model by explicitly permitting essential services like DNS (port 53 UDP) and HTTP/HTTPS (ports 80/443 TCP/UDP) and implicitly denying everything else. However, as the internet matured, this model began to break down.
Slink highlights a "vicious circle" where network firewalls, by blocking most protocols, inadvertently pushed all application traffic onto HTTP and HTTPS. This trend means that the vast majority of relevant traffic flows over a single port (443), often encrypted. The advent of technologies like HTTP/2 and HTTP/3 further consolidates this, while Encrypted Client Hello (ECH) now even obfuscates the hostname during the TLS handshake, making deeper packet inspection increasingly difficult for traditional network firewalls. Consequently, the network firewall's ability to provide meaningful application-layer security has diminished, rendering it insufficient for protecting modern web services.
This inadequacy necessitated the rise of Web Application Firewalls (WAFs), designed to inspect and filter traffic at the HTTP layer. However, slink argues that most commercial WAFs have adopted a negative security model. These WAFs attempt to identify and block malicious patterns, often relying on massive rule sets like the Core Rule Set (CRS), which aim to catch known attack vectors such as SQL injection, cross-site scripting, and remote code execution. Slink vehemently criticizes this approach, presenting a daunting, single-line regular expression from CRS intended to detect remote code execution as a prime example of its inherent complexity and fragility. He also dismisses "self-learning" WAFs, which attempt to build rules from observed traffic, questioning their ability to distinguish legitimate from adversarial traffic during the training phase and their general lack of transparency and explainability. The core problem, as slink sees it, is that these negative security models are inherently reactive, slow, prone to bypasses through encoding tricks, and ultimately provide a false sense of security, leading administrators to disable protective rules to maintain application functionality.
Key Findings
▶ Watch: Critiquing the 'Wrong Approach Firewall' (negative security model) (14:40)
Slink's talk unveils several critical findings that challenge conventional wisdom in web application security:
- The Negative Security Model is Flawed for WAFs: The prevalent approach of trying to block all "bad" traffic through extensive, complex rule sets (like those found in the ModSecurity Core Rule Set) is inherently reactive, inefficient, and easily bypassed. Such WAFs often lead to false positives, forcing administrators to disable security rules and creating a false sense of security.
- The Positive Security Model is Superior: The only truly effective WAF strategy is to define and explicitly allow all "known good" traffic, denying everything else. This proactive approach inherently provides protection against unknown or zero-day vulnerabilities because anything that deviates from the legitimate application behavior is automatically blocked.
- Cryptographic Signing is a Game Changer: Leveraging cryptographic signatures for URLs, cookies, and API tokens (like JSON Web Tokens (JWTs) or Akamai off tokens) fundamentally shifts the security paradigm. By signing legitimate requests, the application can cryptographically guarantee that incoming requests have not been tampered with and were explicitly generated by a trusted source. This makes it impossible for attackers to forge valid requests or guess URLs.
- Mastering Regular Expressions is Essential: Implementing a positive security model WAF requires precise and efficient pattern matching. Slink emphasizes that regular expressions (regex) are the indispensable tool for this task, allowing granular control over paths, query parameters, headers, and even request bodies. He highlights common regex pitfalls and best practices, such as exempting delimiters in path matching.
- Efficient Pattern Matching is Achievable: Naive sequential matching of patterns can be extremely slow. Slink demonstrates that using optimized matching structures, such as "selectors" or "retox" (regex-like matchers) that process a string once and then dispatch to specific code, can reduce complexity from N\*L (number of patterns times string length) to O(L) (order of string length), making large-scale, fine-grained WAF policies practical.
- WAFs Enhance Caching: By strictly normalizing and validating incoming requests, a positive security model WAF reduces request variance. This consistency significantly improves the effectiveness of HTTP caching, making the application faster and more resilient against certain types of denial-of-service attacks.
- Digital Sovereignty is Key to Effective WAFs: Deploying WAFs on infrastructure controlled by the organization, rather than relying on third-party cloud CDNs that often act as an "adversary in the middle" by decrypting and re-encrypting traffic, is crucial for maintaining security and data privacy.
Technical Deep Dive
▶ Watch: Using cryptographic signatures for robust web security (28:50)
Slink's technical deep dive into building an effective WAF begins with the fundamental structure of HTTP requests and responses. He outlines the key components of an HTTP/1.1 request: the method (e.g., GET, POST), the path (which can include origin form, absolute form, authority form, or star form), the protocol version, headers, and an optional body. He stresses that while HTTP/2 and HTTP/3 introduce different encodings and framing, the logical structure of methods, paths, and headers remains consistent, allowing WAF logic to abstract away transport-layer specifics. A crucial element he highlights is URL encoding (e.g., %20 for space), which attackers frequently exploit to obfuscate malicious payloads and bypass WAF rules.
The cornerstone of slink's proposed positive security model WAF is the use of cryptographic signatures. He introduces two main types:
- Symmetric Signatures: These use a shared secret key for both signing and verification. They are exceptionally fast (millions per second on a CPU core) and ideal for scenarios where the signer and verifier are both under the organization's control (e.g., an application signing for a WAF proxy). However, because the verifier knows the secret, it can also sign, making it unsuitable for untrusted verification environments. Slink strongly advises against "rolling your own" crypto and recommends using HMAC (Keyed-Hash Message Authentication Code), specifically HMAC-SHA256, to prevent guessable signatures.
- Asymmetric Signatures: These use a public/private key pair. The private key signs, and the public key verifies. This allows verification anywhere without revealing the signing secret, making it suitable for broader deployments where the verifier is not fully trusted (e.g., verifying client-generated tokens). Examples include RSA and elliptic curve cryptography (ECC).
Slink demonstrates the practical application of signatures through:
- Signed URLs: Appending a signature as a query parameter to a URL (e.g.,
?fu=bar&sig=...). This guarantees that the URL, including its parameters, was generated by a trusted entity and hasn't been tampered with. Attackers cannot guess valid URLs. - Signed Cookies: Embedding a signature into a cookie's value. The WAF can validate the signature upon receiving the cookie, stripping it off before forwarding to the application, or dropping the cookie if invalid. This prevents clients from forging cookies.
- JSON Web Tokens (JWTs): These are self-contained, cryptographically signed tokens that include a JSON header (metadata) and a JSON payload (arbitrary data), often with a timestamp to define a lifespan. JWTs are base64-encoded and then signed, providing a secure, tamper-proof way to convey information and grant temporary access rights, commonly used in content delivery networks (CDNs) for video streaming protection.
For implementing the positive security model, slink outlines a structured approach using regular expressions for granular control:
- Path-based Matching: The WAF first identifies the specific application path (e.g.,
/api/users,/images/) and then applies rules tailored to that path. He illustrates the complexity of correct regex for paths, demonstrating how.*or[^/]+can lead to incorrect matches, and advocating for precise patterns that correctly handle delimiters like/and?. For instance, a robust regex for a path segment that does not contain a slash or a question mark might look like[^/?]+. - Method Validation: For each path, only explicitly allowed HTTP methods (e.g., GET, HEAD, POST) should be permitted.
- Query Parameter Validation: Allowed query parameters and their expected value patterns are defined. Anything else is stripped or denied.
- Request Header Filtering: Only explicitly permitted headers are allowed to pass. All other headers are stripped. Slink provides a VCL (Varnish Configuration Language) example that retains essential headers like
Host,Accept-Encoding, and conditional request headers (If-Modified-Since,If-None-Match) while removing everything else. This significantly reduces the attack surface by eliminating vectors that rely on unexpected headers. - Body Content Validation: For requests with bodies (e.g., POST requests), the content can also be validated using regex. Slink gives a powerful example of using regex to check the "magic bytes" at the beginning of a file upload to verify if it "looks like an image," demonstrating that regex engines treat binary data like any other sequence of bytes.
To address performance concerns with large-scale pattern matching, slink introduces the concept of sets or selectors. Instead of a naive sequential matching (N\*L complexity), these systems run one large pattern matcher against the incoming string, which then dispatches to specific code blocks or sub-rules. This reduces the complexity to O(L), making sophisticated positive security WAFs performant even for complex applications. He highlights VCL's ability to call code directly from matchers as a powerful feature for this architecture.
Demo / Proof of Concept
▶ Watch: Efficiently building a positive WAF with pattern matching (44:50)
Slink's presentation culminates in a concise yet impactful demonstration of a "simple WAF on two slides" that embodies the core principles of a positive security model. While acknowledging that this ultra-strict configuration would likely break complex, existing applications beyond a simple blog, it serves as a powerful proof of concept for the "right thing" in WAF design.
The demonstration outlines a WAF that implements the following highly restrictive policies:
- Allow Only GET and HEAD Methods: All other HTTP methods (e.g., POST, PUT, DELETE, OPTIONS) are explicitly denied. This immediately shuts down common attack vectors that rely on altering data or exploiting server-side logic through non-GET/HEAD requests.
- Deny All Request Bodies: The WAF checks for the presence of
Content-LengthorTransfer-Encodingheaders, which indicate a request body. If a body is detected, the request is denied. This eliminates an entire class of attacks that inject malicious payloads into the request body. - Strip All Query Parameters: Any query parameters appended to the URL are automatically removed. This prevents attacks that manipulate application logic or inject malicious code via query strings.
- Remove Almost All Headers: Only a very limited set of essential headers are allowed to pass through. All other request headers are stripped. Slink provides a VCL snippet showing how to retain
Host,Accept-Encoding,If-Modified-Since, andIf-None-Match, while discarding everything else. This drastically reduces the attack surface by ensuring the application only receives expected header information.
The VCL pseudo-code illustrates this logic:
- Check if the
Hostheader matches an expected value. - Validate the request method against
GETorHEAD. - Check for
Content-LengthorTransfer-Encodingto detect request bodies and deny if present. - Remove all query parameters (
req.url.query = "";). - Apply a header filter that explicitly keeps only a few known-good headers, dropping all others.
This "two-slide WAF" is a stark contrast to the complex, reactive rule sets of negative security model WAFs. It highlights the power of a "deny by default, allow by exception" approach, offering robust protection at the cost of requiring meticulous design and understanding of the application's legitimate traffic. While not a ready-to-deploy solution for every scenario, it effectively demonstrates the security benefits of extreme minimalism and explicit control.
Defensive Implications
▶ Watch: Q&A: Preventing malicious values in allowed parameters (59:00)
The insights from slink's talk have profound implications for web application security, urging defenders to fundamentally rethink their WAF strategies:
- Embrace the Positive Security Model: The most critical defensive implication is the shift from blocking known bad to explicitly allowing known good. Defenders should meticulously analyze their applications' legitimate HTTP traffic (methods, paths, query parameters, headers, body structure) and construct WAF rules that permit only these defined patterns. While this requires significant upfront effort in reverse engineering application traffic, it offers inherent protection against unknown (zero-day) attacks and reduces the maintenance burden of constantly updating negative rule sets.
- Integrate Cryptographic Signing: For critical application components, defenders should implement cryptographic signatures for URLs, cookies, and API tokens. Utilizing HMAC-SHA256 for symmetric signing between trusted internal components (e.g., application and WAF) or asymmetric cryptography for broader use cases (e.g., public key validation of JWTs), ensures that requests are authentic and untampered. This effectively eliminates URL guessing, cookie forging, and unauthorized access attempts.
- Master Regular Expressions: Security professionals and developers must invest in mastering regular expressions (regex). Regex is the indispensable tool for crafting precise and efficient rules for positive security WAFs, allowing granular control over every part of the HTTP request. Understanding regex nuances, including character classes, quantifiers, and delimiters, is crucial for both accurate matching and preventing bypasses.
- Strict Data Sanitization and Filtering: Proactively strip all unnecessary or unknown data from incoming requests. This includes removing unknown headers, query parameters, and even rejecting entire request bodies if they are not expected for a given path/method. This "minimalist" approach drastically reduces the attack surface, as attackers cannot exploit data points that are simply not present or are not processed by the application.
- Leverage Caching as a Security Layer: By enforcing a positive security model and reducing the variance of incoming requests, WAFs can significantly improve HTTP caching efficiency. A well-configured cache, like Vinyl Cache, not only speeds up content delivery but also acts as a robust defense mechanism, shielding origin servers from direct attacks and improving resilience against Denial of Service (DoS) attacks, especially those targeting application logic (e.g., "DoS method on POSTs").
- Prioritize Digital Sovereignty: Whenever possible, organizations should deploy their WAFs and related infrastructure on systems they control, rather than relying solely on third-party CDN or cloud WAF providers. This maintains digital sovereignty, prevents third parties from decrypting and inspecting all traffic (acting as an "adversary in the middle"), and ensures full control over security policies and data privacy.
- Seek Open Standards for WAF Definitions: Slink's call for an open definition of WAF rules that can be shipped with applications (similar to OpenAPI for APIs) is a forward-looking implication. Defenders should advocate for and contribute to such initiatives, enabling a more standardized and framework-agnostic approach to generating positive security WAF configurations.
Key Takeaways
- Shift to Positive Security: Abandon reactive, negative security model WAFs for a proactive approach that explicitly allows only known-good HTTP traffic, inherently protecting against zero-day vulnerabilities.
- Cryptographic Signing is Essential: Implement cryptographic signatures (e.g., HMAC-SHA256 for symmetric, RSA/ECC for asymmetric) for URLs, cookies, and API tokens to prevent forging and tampering, guaranteeing authenticity.
- Master Regular Expressions: Develop strong regex skills for precise and efficient pattern matching across HTTP paths, query parameters, headers, and request bodies to enforce strict positive security policies.
- Strip Unnecessary Data: Aggressively filter and remove all unexpected or unneeded HTTP headers, query parameters, and request body content to drastically reduce the application's attack surface.
- Caching as a Defense Layer: Leverage HTTP caching to not only improve performance but also serve as a security mechanism, reducing request variance and bolstering resilience against DoS attacks.
- Embrace Digital Sovereignty: Regain control over your security infrastructure by deploying WAFs on self-controlled systems, avoiding reliance on third-party CDNs that often act as "adversaries in the middle."
About the Speaker(s)
slink is an independent developer and consultant who has been working with a small company since 2009. He is a passionate advocate for Free and Open-Source Software (FOSS), crediting much of his knowledge to the FOSS community. Currently, slink is one of three maintainers for the open-source reverse proxy software Vinyl Cache, which was previously known as Varnish Cache. His primary work involves configuring, customizing, and improving this software for CDNs and large websites. Slink is deeply committed to digital sovereignty, advocating for individuals, organizations, and states to control their own technology and become independent of the dominant tech oligopolies. He aims to make enterprise-grade tools and functionalities, typically found in commercial CDNs, accessible through open-source solutions.
Reviews
Dr. Zero (Offensive Security Researcher) — SOLID
A competent advocacy talk for positive-security WAFs with some good practical intuitions, but nothing here would surprise anyone who's actually built one. The 'two-slide WAF' is cute but trivial; the real work—mapping actual application traffic to allowlists at scale—gets hand-waved.
Heather Calloway (CISO) — SOLID
A practitioner's manifesto for positive-security WAF design. The core argument is sound and the architectural principles are correct, but the talk stays at advocacy level rather than delivering operationally deployable guidance. Worth the time for teams rethinking their WAF strategy; not a drop-in playbook.