Low-Level Ingress Architecture: eBPF Rate Limiting, Fast Signature Verification, and HTTP/3 for Webhook Infrastructure
Protect your webhook infrastructure from L4 amplification and flood attacks. Learn how to implement eBPF Traffic Control (TC) rate limiting before TCP handshakes.

Low-Level Ingress Architecture: eBPF Rate Limiting, Fast Signature Verification, and HTTP/3 for Webhook Infrastructure
Webhook receivers face two kinds of pressure. Legitimate traffic arrives in bursts: a provider recovers from an outage, or your own retry queue drains after an incident. Hostile traffic also targets public webhook URLs with volumetric floods. A conventional ingress stack, such as NGINX or Envoy behind a cloud load balancer, handles both reasonably well until packet rates, per-request CPU cost or deployment churn start to hurt.
This article covers three techniques for tightening the ingress path, along with the limits of each:
- Dropping abusive traffic early in the Linux kernel with eBPF, using XDP (preferred) or TC (a fallback), before it reaches the socket layer.
- Verifying webhook signatures in Rust on hardware-accelerated crypto paths, and being precise about what “zero-copy” can and can’t mean.
- Using HTTP/3 and QUIC at the edge, including
GOAWAY-based draining and connection-ID-aware routing, and where QUIC connection migration actually matters for webhooks.
1. eBPF-Assisted Rate Limiting for Webhook Ingress
The threat model
Webhook endpoints are public URLs by design, so they can’t sit behind a login. Two traffic patterns matter:
- Legitimate bursts. Retry behavior differs a lot between providers. Stripe documents automatic live-mode retries with exponential backoff for up to three days. GitHub documents that it does not automatically redeliver failed deliveries, so failed deliveries must be redelivered manually or by automation. Bursts therefore come from provider-specific retry queues and recovery events, and from your own downstream retries after an outage.
- Volumetric attacks. SYN floods and UDP floods force the kernel to spend CPU on every packet. Strictly speaking, a SYN flood is a resource-exhaustion attack, not an amplification attack. Amplification and reflection refer to attacks that abuse third-party servers, such as open DNS resolvers or memcached, to send you large volumes of traffic.
Linux already has defenses at the TCP level. SYN cookies (net.ipv4.tcp_syncookies) let the kernel survive a SYN flood without allocating per-connection state. But every packet still costs driver, sk_buff, netfilter and TCP processing before it is rejected. At high packet rates that per-packet cost is the bottleneck, so dropping packets earlier is worth the effort.
XDP vs. TC: where to drop
Two eBPF attachment points are relevant, and they are not equivalent.
- XDP (eXpress Data Path) runs in the NIC driver, before the kernel allocates an
sk_buff. This is the earliest point for dropping traffic. - TC ingress (
clsact) runs after the driver has built ansk_buff, but before netfilter and the socket layer. It is cheaper than iptables, and it works on virtual interfaces and drivers without native XDP support. It is not “before any allocation.”
Cloudflare’s published experience shows what the earliest hook can do. Its XDP-based L4Drop system dropped over 8 million packets per second on a single server during an attack. Cloudflare reports that the system can drop more than 10 million packets per second on a single CPU core. Cloudflare moved to XDP in part to replace an earlier kernel-bypass approach that tied it to a specific NIC vendor. Its first production deployment of XDP packet filtering was in November 2018.
The comparison with iptables is also worth stating precisely. An iptables chain is evaluated linearly, so cost grows with the number of rules. Hash-based structures (eBPF maps, nftables sets, ipset) avoid that. eBPF programs are also verified before loading and JIT-compiled to native code, and they must pass the verifier’s bounds checks, which is why every header access in the code below is guarded.
[ NIC ]
│
▼
[ XDP hook (driver, before sk_buff) ] ──(over limit)──► XDP_DROP
│ (under limit)
▼
[ sk_buff allocation → TC ingress → netfilter → TCP stack ]
│
▼
[ Reverse proxy / webhook worker ]
A per-IP SYN rate limiter in XDP
What you limit matters as much as where you drop. Counting every packet per source IP would punish legitimate providers that send large payloads, since a single request can span many packets. Limiting new connection attempts (TCP SYN without ACK) per source IP is a safer default for webhook traffic, because well-behaved senders reuse connections.
The program below is a fixed-window limiter, not a true token bucket. It uses an LRU hash map so that stale entries are evicted automatically.
// syn_ratelimit.bpf.c
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>
#define MAX_ENTRIES 65536
#define WINDOW_NS 1000000000ULL // 1-second window
#define MAX_SYN_PER_WINDOW 200 // tune from your real traffic
struct window {
__u64 start_ns;
__u64 count;
};
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(max_entries, MAX_ENTRIES);
__type(key, __u32); // source IPv4 address
__type(value, struct window);
} syn_limit_map SEC(".maps");
SEC("xdp")
int webhook_syn_ratelimit(struct xdp_md *ctx)
{
void *data = (void *)(long)ctx->data;
void *data_end = (void *)(long)ctx->data_end;
struct ethhdr *eth = data;
if ((void *)(eth + 1) > data_end)
return XDP_PASS;
if (eth->h_proto != bpf_htons(ETH_P_IP))
return XDP_PASS; // IPv6 needs its own parsing path
struct iphdr *ip = (void *)(eth + 1);
if ((void *)(ip + 1) > data_end)
return XDP_PASS;
if (ip->protocol != IPPROTO_TCP)
return XDP_PASS;
__u32 ihl_bytes = ip->ihl * 4;
if (ihl_bytes < sizeof(*ip))
return XDP_PASS;
struct tcphdr *tcp = (void *)ip + ihl_bytes;
if ((void *)(tcp + 1) > data_end)
return XDP_PASS;
// Only count connection attempts: SYN set, ACK not set
if (!(tcp->syn && !tcp->ack))
return XDP_PASS;
__u32 src = ip->saddr;
__u64 now = bpf_ktime_get_ns();
struct window *w = bpf_map_lookup_elem(&syn_limit_map, &src);
if (!w) {
struct window init = { .start_ns = now, .count = 1 };
bpf_map_update_elem(&syn_limit_map, &src, &init, BPF_NOEXIST);
return XDP_PASS;
}
if (now - w->start_ns >= WINDOW_NS) {
// Window reset is not atomic; small races are acceptable for rate limiting.
w->start_ns = now;
w->count = 1;
return XDP_PASS;
}
if (__sync_fetch_and_add(&w->count, 1) >= MAX_SYN_PER_WINDOW)
return XDP_DROP;
return XDP_PASS;
}
char _license[] SEC("license") = "GPL";
Attach it with iproute2 and inspect state with bpftool:
clang -O2 -g -target bpf -c syn_ratelimit.bpf.c -o syn_ratelimit.bpf.o
# Native (driver) mode; use xdpgeneric only for testing
ip link set dev eth0 xdpdrv obj syn_ratelimit.bpf.o sec xdp
bpftool prog show
bpftool map dump name syn_limit_map
ip -s link show dev eth0
If your driver lacks native XDP support, or you are on a virtual interface, the same logic can run at the TC hook. Use SEC("tc"), take a struct __sk_buff *, return TC_ACT_SHOT to drop, and create the clsact qdisc first:
tc qdisc add dev eth0 clsact
tc filter add dev eth0 ingress bpf direct-action obj tc_ratelimit.bpf.o sec tc
Operational considerations
- Shared IPs. Many senders sit behind NAT or shared egress addresses. A per-IP limit can block a whole organization. Start in observe-only mode (count and export, don’t drop), and allowlist known provider ranges where the provider publishes them.
- Counters and contention. A shared hash-map value updated from many CPUs creates cache-line contention.
BPF_MAP_TYPE_LRU_PERCPU_HASHremoves that contention, but limits then apply per CPU, so the effective global limit depends on how traffic is spread across CPUs. Pick one model deliberately. - Map sizing. An LRU map evicts old entries under pressure, which is the desired behavior for spoofed-source floods, but an attacker rotating source addresses can still flush legitimate entries. Size the map for your expected unique-source count.
- IPv6, fragments, and other protocols need their own handling. The example is IPv4/TCP only.
- Rate limiting is not a complete DDoS defense. Volumetric attacks larger than your uplink must be absorbed upstream by your provider or a scrubbing service.
2. Fast Signature Verification in Rust (and What “Zero-Copy” Really Means)
What webhook “decryption” actually is
Most webhook providers do not encrypt payloads at the application layer. They rely on TLS for confidentiality and add an HMAC signature for authenticity. GitHub, for example, signs the payload with HMAC-SHA256 and sends the hex digest with a sha256= prefix in the X-Hub-Signature-256 header. Stripe sends a Stripe-Signature header whose signature includes a timestamp, and its libraries apply a recency tolerance by default.
So the typical hot path is:
- TLS decrypts the stream (AES-GCM or ChaCha20-Poly1305, depending on the negotiated cipher suite).
- The application verifies an HMAC-SHA256 over the raw request body.
- Only then does the application parse the payload.
Hand-rolled “AES block decryption of the raw socket buffer” has no place in that flow. Doing it with raw AES (ECB-style block calls) would be insecure anyway, because it provides no authentication and leaks patterns.
Hardware acceleration: what is accurate
- AES. On x86, AES-NI provides AES round instructions, and VAES extends them to 256- and 512-bit vectors so several blocks are processed per instruction. With 512-bit registers that is four AES blocks. On ARM64 the AES instructions come from the ARMv8 Cryptography Extensions rather than from base Neon. Each instruction operates on a single 128-bit block.
- SHA-256. x86 CPUs with SHA extensions and ARMv8 CPUs with the SHA2 extension can accelerate SHA-256, which is the core of HMAC-SHA256. A single HMAC stream is largely sequential, so wide SIMD registers don’t speed it up the way they do AES in parallelizable modes.
- Rust crates. The RustCrypto
aescrate performs runtime detection of AES-NI and VAES on x86/x86_64 and falls back to a constant-time software implementation. On aarch64 Linux and macOS it can autodetect the ARMv8 AES intrinsics at runtime. Older releases required theaes_armv8cfg flag, so check the documentation for the version you use. Thesha2crate similarly dispatches to SHA-NI or ARMv8 crypto extensions where available.
You rarely need to write intrinsics yourself. In most deployments the right choice is to use well-reviewed crates, confirm the hardware paths are active on your target CPUs, and measure.
Zero-copy verification, honestly
“Zero-copy” here means not duplicating the request body in userspace. Once the HTTP server has the body as a contiguous buffer (&[u8] or Bytes), you can:
- compute the HMAC directly over that borrowed slice;
- compare the result in constant time;
- parse JSON afterwards with borrowed deserialization, so strings point into the same buffer.
What it cannot mean is that no bytes are ever copied between the NIC and your code. TLS decryption necessarily writes plaintext somewhere, and the network stack copies data into socket buffers. Kernel TLS (kTLS) can move record encryption into the kernel, but it is a separate optimization with its own constraints.
// Cargo.toml (API shown is hmac 0.12 / sha2 0.10; newer releases adjust trait imports slightly)
// [dependencies]
// hmac = "0.12"
// sha2 = "0.10"
// hex = "0.4"
use hmac::{Hmac, Mac};
use sha2::Sha256;
type HmacSha256 = Hmac<Sha256>;
#[derive(Debug)]
pub enum VerifyError {
MalformedHeader,
InvalidKey,
BadSignature,
}
/// Verifies a GitHub-style `X-Hub-Signature-256` header over the raw body.
/// Returns the same borrowed body slice on success: no copy, no re-allocation.
pub fn verify_signature<'a>(
secret: &[u8],
signature_header: &str,
raw_body: &'a [u8],
) -> Result<&'a [u8], VerifyError> {
let hex_sig = signature_header
.strip_prefix("sha256=")
.ok_or(VerifyError::MalformedHeader)?;
let expected = hex::decode(hex_sig).map_err(|_| VerifyError::MalformedHeader)?;
let mut mac = HmacSha256::new_from_slice(secret).map_err(|_| VerifyError::InvalidKey)?;
mac.update(raw_body);
// verify_slice performs a constant-time comparison.
mac.verify_slice(&expected)
.map_err(|_| VerifyError::BadSignature)?;
Ok(raw_body)
}
A few rules that matter more than raw speed:
- Verify the raw bytes, not a re-serialized object. Whitespace, key order or escaping changes alter the signature input.
- Never skip or stub the comparison. A placeholder like
let ok = true;silently turns authentication off. - Use constant-time comparison (
verify_slice, orsubtle::ConstantTimeEq) to avoid timing side channels. - Handle replay. For schemes with timestamps, such as Stripe’s, enforce a tolerance window. Deduplicate on the provider’s event or delivery ID (Stripe’s
evt_...ID, GitHub’sX-GitHub-Delivery) because delivery is at-least-once. - Acknowledge fast, process later. GitHub advises returning a 2xx within 10 seconds, and Stripe advises returning a 2xx quickly before complex processing. A common pattern is to verify the signature, record the event durably, enqueue the work, and then respond.
HMAC over a typical webhook body is a small cost next to TLS, queueing and database writes. Profile before optimizing, and treat SIMD-specific tuning as something to justify with measurements.
3. HTTP/3, GOAWAY Draining, and QUIC Connection Migration
What QUIC connection migration actually is
HTTP/3 runs over QUIC, which runs over UDP. QUIC connections are identified by connection IDs (CIDs) rather than the IP/port four-tuple, which allows a connection to survive an address change. A few details are often misstated:
- Each endpoint chooses the CIDs that its peer uses to address it. There is no single immutable CID shared by both sides. Endpoints issue additional CIDs with
NEW_CONNECTION_IDframes and rotate them, partly to prevent observers from linking traffic across network paths. - Migration is client-initiated. After a network change, the client sends from its new address using an unused CID. The server validates the new path with
PATH_CHALLENGE/PATH_RESPONSEbefore committing to it. Servers cannot migrate a connection to a different server address. The protocol’s only server-side mechanism is the optional “preferred address” transport parameter. - Servers can opt out. An endpoint may advertise
disable_active_migration.
Relevance to webhooks: be realistic
Webhook senders such as Stripe, GitHub and Shopify are server-side systems with stable egress addresses. They are not phones hopping from Wi-Fi to cellular. For that reason client-side connection migration is of limited value for most webhook traffic. Webhook senders also commonly speak HTTP/1.1 or HTTP/2, so enabling HTTP/3 helps only senders that support it.
QUIC is more useful on the server side, for operational reasons:
- Graceful draining with
GOAWAY. - CID-aware routing, so packets for one connection keep reaching the right process or backend even if the client’s address or port changes (for example after NAT rebinding).
- Address validation (
Retry) as a mitigation against spoofed-source floods.
Draining an ingress node with HTTP/3 GOAWAY
RFC 9114 defines graceful shutdown via the GOAWAY frame, which a server sends on its control stream. In summary:
- The frame carries a stream ID. The server rejects requests on streams with that ID or higher without processing them, which makes it safe for the client to retry them elsewhere. Requests below that ID are processed to completion.
- A server can announce shutdown early with the largest possible stream ID, which means no requests are rejected yet, and then lower the value in a later
GOAWAYonce it knows which requests it will serve. SubsequentGOAWAYframes may only lower the ID. - Once in-flight requests finish, the endpoint should close the connection with the
H3_NO_ERRORcode.
HAProxy, for example, implemented GOAWAY-based graceful shutdown for its HTTP/3 support. Check how your own proxy signals GOAWAY during a graceful stop, and test it with a real HTTP/3 client rather than assuming.
A sound rolling-deployment sequence looks like this:
- Remove the node from the load balancer’s new-connection pool, or stop advertising it.
- Signal graceful shutdown so the proxy sends
GOAWAYon existing HTTP/3 connections. - Wait for in-flight requests to finish, bounded by a deadline that exceeds your longest expected request.
- Close the remaining connections and stop the process.
One caveat: QUIC connection state cannot simply be handed to another node. TLS keys and transport state live in the process that terminated the connection, and a load balancer without those keys cannot take over the connection. If a node dies abruptly, clients re-handshake, and webhook providers rely on their normal retry logic. What load balancers can do statelessly is route packets consistently. The IETF QUIC working group’s QUIC-LB specification defines how servers encode routing information (such as a server ID) into connection IDs so that low-state load balancers can route packets for a connection to the right server, even as CIDs change. Cloudflare also describes udpgrm, an eBPF-based system for zero-downtime restarts of UDP services, which is relevant when you restart QUIC servers without dropping packets.
NGINX configuration for HTTP/3
NGINX’s HTTP/3 module (ngx_http_v3_module) appeared in version 1.25.0 and is documented as experimental. It requires a TLS library with QUIC support such as BoringSSL, LibreSSL or QuicTLS, or OpenSSL’s compatibility layer, which does not support early data. The quic_bpf directive enables eBPF-based packet routing, which NGINX documents as the mechanism that allows QUIC connection migration to work with multiple workers. It requires Linux 5.7 or newer.
# main context
quic_bpf on; # route QUIC packets by connection ID across reuseport sockets (Linux 5.7+)
http {
server {
# TCP: HTTP/1.1 and HTTP/2
listen 443 ssl;
http2 on;
# UDP: HTTP/3
listen 443 quic reuseport;
http3 on;
ssl_certificate /etc/ssl/certs/webhook_ingress.crt;
ssl_certificate_key /etc/ssl/private/webhook_ingress.key;
ssl_protocols TLSv1.3; # QUIC requires TLS 1.3
# Address validation via Retry tokens; useful against spoofed-source floods
quic_retry on;
# Leave 0-RTT disabled for webhook POSTs (see below)
ssl_early_data off;
# Advertise HTTP/3 to clients that support it
add_header Alt-Svc 'h3=":443"; ma=86400';
location /v1/webhooks {
proxy_pass http://backend_webhook_workers;
proxy_http_version 1.1;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
}
}
Notes on this configuration:
- The
proxy_*_timeoutvalues govern upstream I/O. They are not a drain mechanism. - Only the first
serverblock for a given address should specifyreuseport. - Keep 0-RTT off for webhook endpoints. Early data can be replayed by an attacker, which is unsafe for non-idempotent
POSTrequests. - Test
nginx -s reloadbehavior under load withquic_bpf on. Community reports describe packet-routing issues across reloads in some setups, so validate this in staging. - Envoy also supports downstream HTTP/3, but its feature support and configuration differ. Check its current documentation before relying on specific migration or routing behavior.
Putting It Together
| Layer | Technique | What it buys you | Main caveat |
|---|---|---|---|
| Kernel | XDP (or TC) per-IP SYN limiting | Cheap early drops of abusive connection attempts | Shared/NAT IPs; not a substitute for upstream DDoS protection |
| Application | HMAC-SHA256 over the raw body using hardware-accelerated crypto crates | Fast, constant-time authentication with borrowed buffers | True zero-copy is limited by TLS and socket buffers; measure first |
| Edge | HTTP/3 with GOAWAY draining and CID-aware routing | Cleaner rolling deployments, spoofed-source mitigation | Few webhook senders use HTTP/3; migration mainly helps mobile clients |
Conclusion
Each technique here removes a specific cost or failure mode. XDP removes per-packet kernel overhead for abusive traffic. Hardware-accelerated crypto crates make signature verification cheap without custom assembly. HTTP/3 GOAWAY and CID-aware routing make rolling deployments less disruptive for senders that speak QUIC. None of them removes the need for the fundamentals: fast acknowledgments, durable queues, idempotent consumers and signature plus replay checks. Benchmark each change on your own traffic before treating it as a win.
References
- RFC 9000, QUIC: A UDP-Based Multiplexed and Secure Transport: https://datatracker.ietf.org/doc/rfc9000/
- RFC 9114, HTTP/3: https://www.rfc-editor.org/rfc/rfc9114
- NGINX
ngx_http_v3_moduledocumentation: https://nginx.org/en/docs/http/ngx_http_v3_module.html - Cloudflare, L4Drop: XDP DDoS Mitigations: https://blog.cloudflare.com/l4drop-xdp-ebpf-based-ddos-mitigations/
- GitHub, Validating webhook deliveries: https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries
- RustCrypto
aescrate documentation: https://docs.rs/aes/latest/aes/