I Tried Out ddos_protection and AWS WAF Integration with Elastic Load Balancing for Envoy

I Tried Out ddos_protection and AWS WAF Integration with Elastic Load Balancing for Envoy

With ddos_protection's SYN cookie mode set to continuous, the SYN-ACK format changed and SYN-ACKs are no longer resent for invalid ACKs. Blocking via AWS WAF Block rules (IP-based and rate-based) was also confirmed.
2026.11.27

This page has been translated by machine translation. View original

Introduction

On November 25, 2026, the general availability of Elastic Load Balancing for Envoy (ELB for Envoy) was announced.

https://aws.amazon.com/about-aws/whats-new/2026/11/elastic-load-balancing-for-envoy-generally-available/

ELB for Envoy is a load balancer type in which AWS operates open-source Envoy, and you can add AWS integrations such as AWS WAF.

In this article, I check the differences when switching among the three values of SYN cookie mode, blocking with AWS WAF IP restrictions and rate rules, and the records left in the proxy logs and WAF logs when a request is blocked.

Test environment

  • Region: Tokyo (ap-northeast-1)
  • aws-cli: 2.42.4
  • Proxy version: 1.40
  • Proxy configuration: internet-facing, IPv4, 2 AZs
  • Listener: HTTP port 80
  • Envoy configuration: fixed response 200 (body Your proxy is running)
  • access_log (HttpConnectionManager): not configured
  • SYN observation source: a local Docker container (behind NAT), sending to the two IPv4 addresses returned by the proxy's DNS name
  • web ACL during SYN observation: associated (IP set empty, rate rule present)

I tested with one newly created proxy for this verification. The steps to create the proxy are summarized in the following article.

https://dev.classmethod.jp/articles/aws-elb-for-envoy-ga-create-proxy/

Setting the attribute

SYN cookie mode is configured with the attribute ddos_protection.syn_cookie.mode. There are three values: reactive, continuous, and off, and the default is reactive. reactive enables mitigation only when a SYN flood is detected, and continuous keeps it enabled at all times.

https://docs.aws.amazon.com/elasticloadbalancing/latest/elbproxy/proxy-attributes.html

Right after creation, get-proxy-attributes showed this attribute as reactive. Switch the value with the following command.

aws elb-proxy update-proxy-attributes \
  --proxy-identifier <proxy-arn> \
  --attributes key=ddos_protection.syn_cookie.mode,value=continuous

In the response, this attribute had the following value.

{
    "key": "ddos_protection.syn_cookie.mode",
    "value": "continuous",
    "defaultValue": "reactive"
}

The new value was shown in the update response and in get-proxy-attributes immediately afterward. I updated the SYN cookie mode and waf.fail_open.enabled with update-proxy-attributes a total of 6 times at roughly 10-second intervals. During that time, I sent HTTP requests on new connections 73 times at 1-second intervals, and all of them returned 200.

Differences in SYN-ACK

To the proxy created for verification, I sent observation SYNs and ACKs at no more than a few packets per second per destination IP.

I sent SYNs with MSS 1460, SACK, Timestamp, and WScale 7. The returned SYN-ACK was one of the following two types.

Item reactive, off continuous
TCP option order MSS 1420, SACK, Timestamp, NOP, WScale 7 MSS 1420, NOP, WScale 8, NOP, NOP, SACK, NOP, NOP, Timestamp
Timestamp value Different for each connection 0
window 62643 64240
IP TTL 122 250

The IP TTL is the value seen from my local machine through NAT, and it varies depending on the path. The SYN-ACKs of reactive and off were indistinguishable.

After switching modes, the form of the SYN-ACK changed within 1 minute for both IPs. All SYNs sent during the switch received a SYN-ACK.

Responses to invalid ACKs

After receiving the SYN-ACK, I sent an ACK and an HTTP GET. I varied the ACK acknowledgment number and tried 5 times per mode. So that the kernel would not return an RST and close the half-open connection, I dropped RST transmission only inside the container.

When I sent the correct ACK (SYN-ACK seq + 1), HTTP 200 was returned in 5 out of 5 attempts in all modes. The results when the acknowledgment number was changed are shown in the table (one attempt lasts 3 seconds).

ACK sent continuous off, reactive
ACK shifted by +12345 No response in 5/5 SYN-ACK retransmitted twice in 4/5, no response in 1/5
Random ACK No response in 4/5, RST in 1/5 RST and SYN-ACK retransmission in 3/5, SYN-ACK retransmission only in 2/5

The full set of probes used for observation is placed in the collapsible section. The proxy at the time of observation had the web ACL created in the AWS WAF integration section (rate rule of 10 requests / 60 seconds) associated. For that reason, the probe limits attempts that send HTTP to at most 8 per 60 seconds.

Probe files and run commands

Save the following three files in a working directory.

syn_probe.py

#!/usr/bin/env python3
"""SYN cookie の観察用プローブ(flood にならない低レート)。

使い方: syn_probe.py <dst-ip> <label> <variants> [trials]
  variants: カンマ区切り。
    synack   SYN を送り SYN-ACK の中身(seq、window、TCP オプション)だけ記録する
    valid    SYN → SYN-ACK → 正しい ACK(ack = SYN-ACK の seq + 1)→ HTTP GET
    badack   SYN → SYN-ACK → ずらした ACK(ack = 正しい値 + 12345)→ HTTP GET
    randack  SYN → SYN-ACK → 乱数の ACK → HTTP GET
    bareack  SYN なしで乱数の seq / ack の ACK + HTTP GET
出力は 1 行 1 JSON。毎秒数パケット以下(試行ごとに sleep)。レートルール(10 req / 60 秒)を避けるため、
HTTP を送る試行は直近 60 秒で 8 件を超えないよう待つ。
"""
import json, random, sys, time
from scapy.all import IP, TCP, Raw, sr1, send, AsyncSniffer, conf  # type: ignore

conf.verb = 0
DST = sys.argv[1]
LABEL = sys.argv[2]
VARIANTS = sys.argv[3].split(",")
TRIALS = int(sys.argv[4]) if len(sys.argv) > 4 else 5
PORT = 80
HTTP = b"GET /syn-probe HTTP/1.1\r\nHost: probe\r\nConnection: close\r\n\r\n"
http_times = []

def throttle_http():
    now = time.time()
    while len([t for t in http_times if now - t < 60]) >= 8:
        time.sleep(1)
        now = time.time()
    http_times.append(time.time())

def _v(x):
    if isinstance(x, bytes):
        return x.hex()
    if isinstance(x, tuple):
        return [_v(i) for i in x]
    return x

def opts_to_list(opts):
    return [[o[0], _v(o[1])] for o in opts]

def send_syn(sport, isn):
    syn = IP(dst=DST) / TCP(
        sport=sport, dport=PORT, flags="S", seq=isn, window=64240,
        options=[("MSS", 1460), ("SAckOK", b""), ("Timestamp", (int(time.time()) & 0xFFFFFFFF, 0)),
                 ("NOP", None), ("WScale", 7)])
    return sr1(syn, timeout=3)

def start_sniffer(sport):
    s = AsyncSniffer(filter=f"tcp and src host {DST} and dst port {sport}")
    s.start()
    time.sleep(0.3)
    return s

def collect_after(sniffer, secs=3):
    """送信後に返ってくるパケット(HTTP 応答、RST など)を集める"""
    time.sleep(secs)
    pkts = sniffer.stop()
    out = []
    for p in pkts:
        t = p[TCP]
        out.append({"flags": str(t.flags), "len": len(bytes(t.payload)),
                    "head": bytes(t.payload)[:15].decode("latin1") if len(bytes(t.payload)) else ""})
    return out

def trial(variant):
    rec = {"label": LABEL, "variant": variant, "t": time.strftime("%Y-%m-%dT%H:%M:%S%z")}
    sport = random.randint(20000, 60000)
    isn = random.randint(1, 2**31)
    if variant == "bareack":
        throttle_http()
        seq, ack = random.randint(1, 2**31), random.randint(1, 2**31)
        sn = start_sniffer(sport)
        send(IP(dst=DST) / TCP(sport=sport, dport=PORT, flags="PA", seq=seq, ack=ack, window=64240) / Raw(HTTP))
        rec["after"] = collect_after(sn)
        return rec
    sa = send_syn(sport, isn)
    if sa is None or not sa.haslayer(TCP) or "S" not in str(sa[TCP].flags) or "A" not in str(sa[TCP].flags):
        rec["synack"] = None if sa is None else {"flags": str(sa[TCP].flags)}
        return rec
    t = sa[TCP]
    rec["synack"] = {"flags": str(t.flags), "seq": t.seq, "ack": t.ack, "window": t.window,
                     "options": opts_to_list(t.options), "ttl": sa[IP].ttl, "ip_id": sa[IP].id}
    rec["ack_ok"] = (t.ack == isn + 1)
    if variant == "synack":
        send(IP(dst=DST) / TCP(sport=sport, dport=PORT, flags="R", seq=isn + 1))
        return rec
    good_ack = (t.seq + 1) & 0xFFFFFFFF
    if variant == "valid":
        ack = good_ack
    elif variant == "badack":
        ack = (good_ack + 12345) & 0xFFFFFFFF
    else:
        ack = random.randint(1, 2**32 - 1)
    rec["sent_ack_delta"] = (ack - good_ack) & 0xFFFFFFFF
    throttle_http()
    sn = start_sniffer(sport)
    send(IP(dst=DST) / TCP(sport=sport, dport=PORT, flags="PA", seq=isn + 1, ack=ack, window=64240) / Raw(HTTP))
    rec["after"] = collect_after(sn)
    send(IP(dst=DST) / TCP(sport=sport, dport=PORT, flags="R", seq=isn + 1 + len(HTTP)))
    return rec

for v in VARIANTS:
    n = 1 if v == "bareack" and TRIALS > 1 else TRIALS
    for _ in range(n):
        print(json.dumps(trial(v)), flush=True)
        time.sleep(1.5)

syn-probe/Dockerfile

FROM python:3.12-slim
RUN apt-get update && apt-get install -y --no-install-recommends iptables libpcap0.8 && rm -rf /var/lib/apt/lists/* \
 && pip install --no-cache-dir scapy
COPY entry.sh /entry.sh
ENTRYPOINT ["/entry.sh"]

syn-probe/entry.sh

#!/bin/sh
# When DROP_RST=1, drop RST transmission only in this container's netns so that the kernel does not return an RST to the SYN-ACK
# (Used for valid / badack / randack / bareack, which proceed as far as HTTP. For synack only, RST is allowed through so no half-open connections remain)
if [ "${DROP_RST:-0}" = "1" ]; then iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP; fi
exec python3 /app/syn_probe.py "$@"

Build the image and get the IPs returned by the proxy's DNS name.

chmod +x syn-probe/entry.sh
docker build -t syn-probe syn-probe/
getent ahostsv4 ddos-waf-verify-<proxy-id>.elb-proxy.ap-northeast-1.on.aws | awk '{print $1}' | sort -u

Using the obtained IPs (<proxy-ip-1>, <proxy-ip-2>) as destinations, observe the SYN-ACK.

docker run --rm --cap-add NET_RAW --cap-add NET_ADMIN -v "$(pwd):/app:ro" syn-probe <proxy-ip-1> <label> synack 5

To measure the time until the SYN-ACK form switches, I sent synack 320 times each to the two IPs in parallel (at 1.5-second intervals). During that time, I used update-proxy-attributes to switch in the order continuous, off, reactive at intervals of about 140 seconds.

docker run --rm --cap-add NET_RAW --cap-add NET_ADMIN -v "$(pwd):/app:ro" syn-probe <proxy-ip-1> timeline synack 320 > ip1.jsonl &
docker run --rm --cap-add NET_RAW --cap-add NET_ADMIN -v "$(pwd):/app:ro" syn-probe <proxy-ip-2> timeline synack 320 > ip2.jsonl &

To observe responses to invalid ACKs, add -e DROP_RST=1.

docker run --rm --cap-add NET_RAW --cap-add NET_ADMIN -e DROP_RST=1 -v "$(pwd):/app:ro" syn-probe <proxy-ip-1> <label> valid,badack,randack 5

AWS WAF integration

I newly created a dedicated web ACL, associated it with the proxy, and blocked requests with an IP restriction and a rate rule.

Associating the web ACL

Creating the IP set, rules, and web ACL

First, create an empty IP set.

aws wafv2 create-ip-set \
  --name ddos-waf-verify-block-ips \
  --scope REGIONAL \
  --ip-address-version IPV4 \
  --addresses '[]' \
  --description "ddos-waf-verify block list"

Put Summary.ARN from the response into <ip-set-arn> in the following rule definition waf-rules-ip.json. This file contains only the rule block-listed-ip (priority 0), which blocks source IPs included in the IP set. The web ACL's default action is set to Allow in the following create-web-acl.

[
  {
    "Name": "block-listed-ip",
    "Priority": 0,
    "Statement": { "IPSetReferenceStatement": { "ARN": "<ip-set-arn>" } },
    "Action": { "Block": {} },
    "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "block-listed-ip" }
  }
]

Pass this file to create the web ACL.

aws wafv2 create-web-acl \
  --name ddos-waf-verify-acl \
  --scope REGIONAL \
  --default-action Allow={} \
  --rules file://waf-rules-ip.json \
  --visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=ddos-waf-verify-acl

Specify Summary.ARN (the web ACL's ARN) from the create-web-acl response and associate it with the proxy.

aws wafv2 associate-web-acl \
  --web-acl-arn <web-acl-arn> \
  --resource-arn <proxy-arn>

You can verify the association with the following three commands.

aws wafv2 get-web-acl-for-resource --resource-arn <proxy-arn>
aws wafv2 list-resources-for-web-acl --web-acl-arn <web-acl-arn> --resource-type ELB_PROXY
aws elb-proxy get-proxy-attributes --proxy-identifier <proxy-arn> --query "attributes[?key=='waf.web_acl_arn']"

waf.web_acl_arn contained the ARN of the associated web ACL.

IP restriction

Add the source global IP to the IP set. Replace <your-global-ip> with the source IP of the client that sends curl. <ip-set-id> is Summary.Id from the create-ip-set response, and <lock-token> is the LockToken from the same response.

aws wafv2 update-ip-set \
  --name ddos-waf-verify-block-ips \
  --scope REGIONAL \
  --id <ip-set-id> \
  --lock-token <lock-token> \
  --addresses <your-global-ip>/32

From about 13 seconds after the update, requests to the proxy returned 403.

$ curl -si --max-time 10 http://ddos-waf-verify-<proxy-id>.elb-proxy.ap-northeast-1.on.aws/
HTTP/1.1 403 Forbidden
content-length: 9
content-type: text/plain
date: Thu, 26 Nov 2026 13:39:22 GMT
server: envoy

Forbidden

With the source IP in the IP set and requests being blocked, I disassociated the web ACL.

aws wafv2 disassociate-web-acl --resource-arn <proxy-arn>

About 5 seconds after disassociation, requests started passing, and when I associated it again, blocking returned after about 7 seconds.

Rate rule

I also tried a rate rule.

Added rule and update command

I applied waf-rules-ip-rate.json, which adds the following rule after block-listed-ip, with update-web-acl.

{
  "Name": "rate-limit-per-ip",
  "Priority": 1,
  "Statement": { "RateBasedStatement": { "Limit": 10, "EvaluationWindowSec": 60, "AggregateKeyType": "IP" } },
  "Action": { "Block": {} },
  "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "rate-limit-per-ip" }
}
aws wafv2 update-web-acl \
  --name ddos-waf-verify-acl \
  --scope REGIONAL \
  --id <web-acl-id> \
  --lock-token <lock-token> \
  --default-action Allow={} \
  --rules file://waf-rules-ip-rate.json \
  --visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=ddos-waf-verify-acl

When I sent curl at 1-second intervals immediately after adding the rate rule, requests returned 403 after about 40 seconds.

fail open

The setting that lets requests through without inspection when WAF is unavailable is configured in ELB for Envoy with the attribute waf.fail_open.enabled. The attribute name, values (true or false), default value (false), and behavior when enabled (requests pass without inspection) are the same as in ALB.

https://docs.aws.amazon.com/elasticloadbalancing/latest/elbproxy/waf.html

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-integrations.html

Records available when AWS WAF blocks a request

Proxy logs

Proxy logs are output to the CloudWatch Logs log group /aws/elb-proxy/<name>.

Application logs and log levels are introduced in the following article.

https://dev.classmethod.jp/articles/aws-elb-for-envoy-process-log-level-format/

From the debug log, I extracted the part from the WAF call to the response. /goku_enhanced is the path of the call to WAF, and the end of goku-meta is the request ID. Log times are in UTC.

[2026-11-26 13:42:14.130][2299][debug][router] [external/envoy+/source/common/router/router.cc:605] [Tags: "ConnectionId":"0","StreamId":"13023735777873375821"] cluster 'awselb/waf' match for URL '/goku_enhanced'
...
'goku-meta', '2,203.0.113.10,arn:aws:wafv2:ap-northeast-1:123456789012:regional/webacl/ddos-waf-verify-acl/<web-acl-id>,e8da430c-981a-4003-9411-05868c31b652'
...
[2026-11-26 13:42:14.134][2299][debug][http] [external/envoy+/source/common/http/async_client_impl.cc:190] async http request response headers (end_stream=true):
':status', '403'
...
[2026-11-26 13:42:14.134][2299][debug][http] [external/envoy+/source/common/http/filter_manager.cc:1191] [Tags: "ConnectionId":"1290","StreamId":"5841474173623103092"] Sending local reply with details
[2026-11-26 13:42:14.134][2299][debug][http] [external/envoy+/source/common/http/conn_manager_impl.cc:2253] [Tags: "ConnectionId":"1290","StreamId":"5841474173623103092"] encoding headers via codec (end_stream=false):
':status', '403'

WAF logs

In the web ACL logs output to CloudWatch Logs, I confirmed the block for the same request ID.

{
  "timestamp": 1795700534136,
  "formatVersion": 1,
  "webaclId": "arn:aws:wafv2:ap-northeast-1:123456789012:regional/webacl/ddos-waf-verify-acl/<web-acl-id>",
  "terminatingRuleId": "block-listed-ip",
  "terminatingRuleType": "REGULAR",
  "action": "BLOCK",
  "terminatingRuleMatchDetails": [],
  "httpSourceName": "ELB_PROXY",
  "httpSourceId": "arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:proxy/ddos-waf-verify:<proxy-id>",
  "ruleGroupList": [],
  "rateBasedRuleList": [],
  "nonTerminatingMatchingRules": [],
  "requestHeadersInserted": null,
  "responseCodeSent": null,
  "httpRequest": {
    "clientIp": "203.0.113.10",
    "country": "JP",
    "headers": [
      {
        "name": ":authority",
        "value": "ddos-waf-verify-<proxy-id>.elb-proxy.ap-northeast-1.on.aws"
      },
      {
        "name": ":path",
        "value": "/debug-block-1"
      },
      {
        "name": ":method",
        "value": "GET"
      },
      {
        "name": ":scheme",
        "value": "http"
      },
      {
        "name": "user-agent",
        "value": "curl/8.18.0"
      },
      {
        "name": "accept",
        "value": "*/*"
      },
      {
        "name": "x-forwarded-proto",
        "value": "http"
      },
      {
        "name": "x-request-id",
        "value": "e8da430c-981a-4003-9411-05868c31b652"
      }
    ],
    "uri": "/debug-block-1",
    "args": "",
    "httpVersion": "HTTP/1.1",
    "httpMethod": "GET",
    "requestId": "e8da430c-981a-4003-9411-05868c31b652",
    "fragment": "",
    "scheme": "http",
    "host": "ddos-waf-verify-<proxy-id>.elb-proxy.ap-northeast-1.on.aws"
  }
}

Summary

When SYN cookie mode in ELB for Envoy's ddos_protection was set to continuous, the form of the SYN-ACK changed, and SYN-ACKs were no longer retransmitted in response to invalid ACKs.

Blocking by AWS WAF rules associated with ELB for Envoy also worked, and specifying fail open was possible as with ALB.

Envoy's debug logs include the request ID, which could be matched against the WAF logs. With Envoy's debug logs alone, it was difficult to identify things such as the reason for a block. If you introduce rules that Block in AWS WAF, I recommend configuring WAF logging.

Share this article

AWSのお困り事はクラスメソッドへ