Skip to content

HTTP/2 memory leak in nghttp2 codec

High
phlax published GHSA-jfxv-29pc-x22r Jul 12, 2023

Package

Envoy

Affected versions

< 1.27.0

Patched versions

1.26.3, 1.25.8, 1.24.9, 1.23.11

Description

Summary

Envoy’s HTTP/2 codec may leak a header map and bookkeeping structures upon receiving RST_STREAM immediately followed by the GOAWAY frames from an upstream server.

Affected Component

HTTP/2 codec

Details

In nghttp2, cleanup of pending requests due to receipt of the GOAWAY frame skips de-allocation of the bookkeeping structure and pending compressed header.

The error return code path is taken if connection is already marked for not sending more requests due to GOAWAY frame.

The clean-up code is right after the return statement, causing memory leak.

PoC

  • From H/2 server accept the connection from Envoy.
  • Send MAX CONCURRENT STREAMS = 1
  • After receiving request
  • Send RST_STREAM for the request
  • Send GO_AWAY with max stream is = 0.

Envoy needs a steady stream of requests from a client.

Upon receiving RST_STREAM Envoy frees up stream capacity on a connection and submits headers for the next request.
In the same I/O operation it also processes GOAWAY and marks connection to not send any more requests.
When processing outbound request queue nghttp2 enters the error handling branch due to connection marked for not sending more requests. In this branch there is no clean-up for the outbound request.

Impact

Denial of service through memory exhaustion.

Attack vector(s)

Specifically crafter response from an untrusted upstream service.

Mitigation

None, apart from disabling HTTP/2 protocol for upstream services.

Detection

Process termination due to out of memory conditions. If collection of memory profile is allowed, the profile will show memory consumed from the submit_headers_shared function in the nghttp2_submit.c file.

Credits

Yan Avlasov yavlasov@google.com

Severity

High
7.5
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

CVE ID

CVE-2023-35945

Weaknesses

No CWEs

Credits