The vulnerability is an uncontrolled resource consumption issue in the hackney library's handling of HTTP/3 responses. The core of the vulnerability is in the hackney_h3:await_response_loop/6 function. This function was responsible for receiving and buffering the response body. It used a per-chunk timeout and had no limit on the size of the buffered body. This allowed a malicious server to send a stream of small data chunks, continuously resetting the timeout and causing the application's memory usage to grow indefinitely, eventually leading to an out-of-memory error.
The patch addresses this by introducing two key changes:
- Maximum Body Size: A
max_body_size limit is introduced (defaulting to 512 MiB). The await_response_loop function now checks the size of the accumulated body after receiving each data chunk and returns an error if the limit is exceeded.
- Absolute Timeout: The per-chunk timeout is replaced with an absolute wall-clock deadline for the entire response. This prevents a slow-drip attack from keeping the connection alive indefinitely.
The primary vulnerable function is hackney_h3:await_response_loop. The function hackney_h3:do_request is also identified as it directly calls the vulnerable function and is a necessary part of the call stack to trigger the vulnerability.