Elixir-grpc grpc
Memory exhaustion via compressed Erlang terms in the elixir-grpc Erlpack codec
Improper Handling of Highly Compressed Data (Data Amplification) vulnerability in elixir-grpc grpc_core and grpc allows unauthenticated attackers to exhaust server memory via a compressed Erlang external term in a gRPC message body. GRPC.Codec.Erlpack.decode/2 (grpc_core/lib/grpc/codec/erlpack.ex, and lib/grpc/codec/erlpack.ex before the package split) passes the message body to :erlang.binary_to_term/2. That function inflates a compressed term in full before it returns. The codec sets no limit on the decoded size, and its type checks run only on the decoded term. The server's max_body_size limit counts the compressed bytes of the request. A request with Content-Type: application/grpc+erlpack can therefore make the server allocate a term much larger than the request body. This issue affects grpc: from 0.4.0 before 1.0.0; grpc_core: from 1.0.0 before 1.1.0.
Affected versions and mitigation
From the CVE record and the vendor's references.Affected
- >= 0.4.0, < 1.0.0
Fixed in 1.0.0
- >= 25bcc569fe2cc4478531a6c546c923205fc751c9, < 0332faae5f5e132314794dbfdae5edecbccea292
Fixed in 0332faae5f5e132314794dbfdae5edecbccea292
- >= 1.0.0, < 1.1.0
Fixed in 1.1.0
- >= 0332faae5f5e132314794dbfdae5edecbccea292, < d6bc56ac75dfb6c02db2099909210a37c9be8db6
Fixed in d6bc56ac75dfb6c02db2099909210a37c9be8db6
Mitigation
Upgrade grpc to 1.0.0 or later.
Upgrade grpc to 0332faae5f5e132314794dbfdae5edecbccea292 or later.
Upgrade grpc_core to 1.1.0 or later.
Upgrade grpc_core to d6bc56ac75dfb6c02db2099909210a37c9be8db6 or later.
Workaround
Remove GRPC.Codec.Erlpack from the server's codecs list if the codec is not needed. If the codec is needed, register a wrapper codec in its place. The wrapper implements the GRPC.Codec behaviour, returns "erlpack" from name/0, raises in decode/2 when the body starts with the bytes 131, 80 (the compressed term tag), and delegates all other calls to GRPC.Codec.Erlpack.
References
- Vendor advisory github.com/elixir-grpc/grpc/security/advisorie…
- Patch github.com/elixir-grpc/grpc/commit/25bcc569fe2…
- Patch github.com/elixir-grpc/grpc/commit/0332faae5f5…
1 more
Timeline
Days relative to CVE publicationNo public PoC found yet; not in CISA KEV.
PoC repositories
Found on GitHub.No PoC repositories found yet.