Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Edge Security: Unifying WAF, Bots, and DDoS

Hello! Welcome to the twelfth and final lesson of our course on architecting security products.

In our last module, we completed a deep dive into Runtime Application Self-Protection (RASP), designing a system that provides security from within the application itself. We concluded by architecting a centralized console to manage a distributed fleet of RASP agents, a classic control plane problem.

Today, we shift our focus from the application's core back to the network's edge. This lesson brings together many of the individual products we've studied—WAF, DDoS mitigation, and Bot Management—into a single, cohesive system. Our learning outcome is to: Architect a unified security platform at the network edge, integrating WAF, Bot Management, and DDoS mitigation.

We will explore why this convergence is happening and, more importantly, how to design the architecture that makes it possible. You will see how a request is processed through a multi-stage pipeline and how a dynamic orchestration engine can reconfigure this pipeline in real time to respond to threats. This lesson serves as the capstone for the course, integrating isolated security functions into a powerful, unified platform.


1. The Blueprint: A Unified Edge Processing Pipeline

Modern edge security platforms, like those from Cloudflare or AWS, don't operate as a loose collection of separate products. Instead, they function as a single, integrated reverse proxy that processes incoming traffic through a well-defined pipeline. This unification provides significant benefits:

  • Performance: Traffic is decrypted (TLS termination) only once at the edge.
  • Shared Context: Information gleaned at one stage (e.g., a TLS fingerprint or IP reputation) can be used by all subsequent stages.
  • Efficiency: Common tasks like request parsing and normalization are done once.

The foundation of this architecture is a global network that directs users to the nearest Point of Presence (PoP).

How Cloudflare Works Under the Hood

To understand this foundational model, let's look at a high-level overview of how Cloudflare's platform is structured. This article provides a clear, technical breakdown of their architecture.

Please read the first three sections: 'Cloudflare’s Position in the Internet Stack': This establishes the core reverse proxy model. 'Anycast Global Network: The Secret Weapon': Understand how Anycast routing gets traffic to the nearest edge PoP. 'Cloudflare as a Reverse Proxy (Deep Internals)': Pay close attention to the sequence of steps: TLS Termination, HTTP Normalization, and then the application of security layers. This is our architectural blueprint.

As the reading describes, every request arriving at an edge PoP goes through a standardized processing pipeline.

Cloudflare Edge Security Architecture
This diagram from Cloudflare's blog illustrates the high-level flow. A client request undergoes TLS termination, then passes through an integrated security module (containing WAF, Rate Limiting, and Bot Management) before being cached or forwarded to the origin server.

This sequential flow is the essence of a unified platform. Let's break down the design of the key security stages within this pipeline.


2. Architecting the Integrated Security Modules

The "Security" block in the diagram isn't a single monolith. It's a series of distinct inspection stages, ordered logically from coarsest to finest to maximize efficiency. An effective pipeline processes traffic in this order:

  1. Layer 3/4 DDoS Mitigation: Filter out high-volume, low-complexity network floods.
  2. Layer 7 DDoS & Bot Mitigation: Filter out high-rate application floods and automated clients.
  3. Web Application Firewall (WAF): Perform deep inspection of the request payload for specific attack patterns.

Layer 3/4 DDoS Mitigation: The First Line of Defense

Before we even look at an HTTP request, we must survive network-level floods designed to saturate bandwidth or exhaust server resources.

Defending from DDoS Attacks - Cloudflare

This deep-dive talk from a Cloudflare engineer explains the first-principles techniques used to defeat massive DDoS attacks at the network and kernel level. This aligns perfectly with your interest in understanding the low-level internals.

Please watch the following segments: Network Congestion (00:03:50 - 00:05:15): Understand how BGP null-routing is used as a last resort when network pipes are saturated. BPF Filtering (00:07:21 - 00:11:12): This is a key section. Focus on how BPF allows for high-speed, programmable packet filtering in the kernel to drop malicious packets before they consume significant resources. Kernel Bypass (00:11:29 - 00:15:06): Grasp the concept of partial kernel bypass (using tools like netmap) to achieve even higher packet processing rates, scaling BPF filtering to millions of packets per second on a single CPU.

The key architectural takeaway is that L3/4 DDoS mitigation is not a single feature but a layered defense system:

  • BGP-based Traffic Engineering: To handle volumetric attacks that exceed a PoP's bandwidth, traffic for the targeted IP is rerouted (via BGP announcements) to specialized, high-capacity "scrubbing centers" or null-routed (dropped) entirely.
  • Programmable Packet Filtering: For attacks that don't saturate pipes but aim to overwhelm the OS kernel (e.g., SYN floods, UDP floods), a high-performance filtering engine is used. As the video details, modern systems use eBPF to run bytecode directly in the kernel's packet processing path, allowing for stateless filtering at multi-million packets-per-second rates. This is where basic IP reputation and protocol validation happen.
  • Stateful Filtering: For attacks that require some connection state (e.g., ACK floods against an invalid connection), kernel features like conntrack are used, but they are significantly slower than stateless BPF filters.

Only packets that survive this gauntlet are passed up to the application layer for further processing.

Layer 7 DDoS, Bot Management, and WAF

Once a packet is reassembled into a decrypted HTTP request, it enters the application-aware stages of the pipeline.

  • Layer 7 DDoS & Bot Management: This stage focuses on the behavior and identity of the client.
    • Rate Limiting: Implements rules to block clients exceeding request thresholds. We've discussed the underlying algorithms (token bucket, etc.) in the DDoS module.
    • Client Fingerprinting: Uses techniques like TLS JA3 fingerprinting and JavaScript challenges to identify headless browsers and automated scripts.
    • Behavioral Analysis: Looks for non-human patterns like rapid form submissions or sequential endpoint scraping.
  • Web Application Firewall (WAF): This is typically the final inspection stage. It focuses on the content of the request.
    • Signature Matching: Applies a rule set (like the OWASP Core Rule Set) to the request URI, headers, and body to find patterns of known attacks (SQLi, XSS, etc.).
    • Anomaly Scoring: Uses heuristics and ML models to score requests based on deviations from normal traffic.

The power of the unified pipeline is that these modules share context. For example, if the Bot Management module assigns a high "bot score" to a request, the WAF can use that signal to apply a much stricter set of rules or block the request outright, even if no specific WAF signature matches.


3. The Orchestration Engine: Architecting for Dynamism

A static pipeline is useful, but a truly powerful platform must be dynamic. It needs to adapt its security posture based on the real-time threat landscape. How can we build a system that can dynamically insert, remove, or reconfigure security functions in the pipeline on the fly?

This requires a sophisticated orchestration system.

A Security Orchestration System for CDN Edge Servers

This research paper presents a formal architecture for a dynamic security orchestration system on CDN edge servers. It provides the 'first-principles' blueprint for building the control plane of our unified platform.

This is a critical resource. Please read the following sections carefully: Section III: 'SYSTEM DESIGN AND IMPLEMENTATION': This is the core of the lesson. Study the three main components: Orchestrator, Virtual Infrastructure Manager (VIM), and Security Monitoring Analytic System (SMAS). Understand their roles and interactions. Focus on how the VIM uses Service Function Chaining (SFC) with tools like Docker and Open vSwitch (OVS) to build the pipeline. Grasp the Event-Condition-Action (ECA) model used by the Orchestrator to define security policies. Section IV: 'USE-CASE SCENARIOS': See how the ECA policies are used to dynamically respond to two attacks: Rate Limiting Use-case: An example of deploying a Bot Management function. Mitigating HTTPS DDoS Use-case: A brilliant example of a multi-stage response, first deploying a Layer 3 firewall, and then escalating to a Layer 7 WAF chain.

The paper provides a formal architecture for the "brain" of our unified platform. Let's map its concepts to our design:

  • Virtual Infrastructure Manager (VIM): This is the hands-on component that manages the security functions, which are virtualized as containers (e.g., Docker). It uses a virtual switch (OVS) and a service chaining protocol (like NSH) to dynamically steer traffic through a sequence of these containers. This is the component that actually builds and modifies the pipeline.
  • Security Monitoring & Analytics System (SMAS): This is the sensory system. It monitors resource utilization (CPU, memory, bandwidth) and security logs. When a metric crosses a predefined threshold (e.g., CPU > 90%), it generates an event.
  • Orchestrator: This is the brain. It subscribes to events from SMAS and executes policies based on an Event-Condition-Action (ECA) model.

Let's trace the "Mitigating HTTPS DDoS" use case from the paper:

  1. Event: SMAS detects sustained high CPU usage and sends a cpu_high event to the Orchestrator.
  2. Rule 1 Triggered:
    • Condition: not chain(u) (the initial firewall chain doesn't exist).
    • Action: The Orchestrator calls the VIM to create_chain(u:<“ip”, 1, 2>, {f:Firewall}). This deploys a container with a simple L3/L4 firewall and steers all IP traffic through it.
  3. Rule 2 Triggered (Escalation):
    • A timer is also started. If the CPU is still high after the timer expires, an event timeout(td) is generated.
    • Condition: not chain(l) and chain(u) (the L7 chain doesn't exist but the L3 chain does).
    • Action: The Orchestrator calls the VIM to create_chain(l: ..., {t:TLS-Term, w:WAF}). This deploys two new containers (TLS termination and WAF) and steers suspicious traffic from the firewall through this new, more intensive inspection chain.

This architecture provides a programmable, closed-loop system that integrates DDoS, Bot, and WAF capabilities and deploys them only when needed, minimizing performance overhead on legitimate traffic.


4. A Real-World Implementation on AWS

The architecture described in the paper is a general model. In a public cloud environment, you would implement it using managed services.

Unified Edge Security Platform Architecture with AWS
This diagram shows a practical implementation of a unified edge platform on AWS. It combines AWS WAF and Shield for initial protection with a custom feedback loop for intelligent, dynamic rate-limiting based on ML analysis.

Let's look at the feedback loop in this diagram, which is a concrete example of the orchestration logic we just discussed:

  1. Data Collection (SMAS): CloudFront and WAF send access logs to a data pipeline (Kafka, Druid). This is analogous to the data collection part of SMAS.
  2. Analysis (SMAS): An ML model analyzes the data to identify malicious IPs or attack patterns. This is the analysis part of SMAS.
  3. Policy Update (Orchestrator): The ML model outputs a list of IPs to block or rate-limit into a database (DynamoDB or S3). A Lambda function is triggered by this update. This function and database act as our Orchestrator.
  4. Enforcement (VIM): The Lambda function makes an API call to AWS WAF to update its IP blocklists or rate-limiting rules. AWS WAF and the underlying network infrastructure act as our VIM.

This demonstrates how the same architectural principles—Collect, Analyze, and Act—can be implemented using different technologies to build a dynamic, unified security platform.


Conclusion and Course Wrap-Up

In this final lesson, we have designed the architecture for a unified edge security platform, seeing how individual security products converge into an integrated, multi-stage processing pipeline. This represents the current state-of-the-art in perimeter security.

Key Takeaways:

  • Unified Architecture: Edge security platforms are built as integrated reverse proxies with a sequential processing pipeline, typically ordered: L3/4 DDoS -> L7 DDoS/Bot -> WAF.
  • Layered Defense: Each stage acts as a filter, removing a class of threats so that subsequent, more resource-intensive stages can focus on harder problems.
  • Dynamic Orchestration: The core of a modern platform is a control plane that can dynamically build and modify this pipeline. The Event-Condition-Action (ECA) model provides a powerful paradigm for this.
  • Service Function Chaining (SFC): At a low level, the dynamic pipeline is realized by chaining virtualized security functions (e.g., containers) using a programmable data plane like Open vSwitch.
  • Feedback Loops: Real-world systems use closed feedback loops to continuously analyze traffic and automatically update security policies, creating an adaptive defense.

This lesson completes your journey through the architecture of modern security products. We started with core architectural patterns, then built our way through WAFs, DDoS and Bot mitigation systems, identity platforms, ZTNA, various scanners, and RASP. We have now come full circle, integrating many of these components into a single, intelligent platform.

You set out with the goal to understand how to architect and build these systems from first principles, and you have now covered the design of nearly every major category of security product. Congratulations on completing the course! I hope this has equipped you with a deep, foundational understanding that will serve you well in your career.

Can't find a good explanation? Sign up and we'll make it for you

Sign up