Skip to main content
Menu
Advisories

Unbounded request body accumulation on streaming RPCs causes memory exhaustion in grpc_server

GHSA-VX6Q-CR5Q-945GPublished Updated GitHub

Description

grpc_server does not enforce its configured max_body_size on request-streaming or bidirectional-streaming gRPC calls. An unauthenticated remote client can open any streaming RPC method and send an unbounded amount of data across many small HTTP/2 DATA frames, causing the server to buffer all of it in memory and eventually exhaust the BEAM's memory and crash the node.

Details

GRPC.Server.Adapters.Cowboy.Handler enforces max_body_size on single-request/single-response calls but not on the streaming read path, which buffers every inbound chunk with no upper bound. The commit that introduced max_body_size applied the check only to non-streaming requests, so any service exposing a streaming RPC method inherited an unbounded-buffering path even though non-streaming calls on the same server are protected.

PoC

  1. Start a grpc server exposing any request-streaming or bidirectional-streaming RPC (a client-streaming method is sufficient).
  2. Open an HTTP/2 connection and send a request to that streaming method.
  3. Send the request body across many small HTTP/2 DATA frames without the final END_STREAM flag, continuing well past the server's configured max_body_size.
  4. Observe the server accepts and buffers all of it, memory growing without bound, instead of rejecting the call once the cap is exceeded (as the equivalent non-streaming call does).

Impact

An unauthenticated attacker can crash a grpc_server-based service by exhausting its memory through a single streaming RPC connection, so long as the target exposes at least one streaming RPC method; services with only single-request/single-response calls are not reachable this way.

References

Affected versions

References

GitHub · elixir-grpc/grpc