]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http2: reject overly many push-promise headers
authorDaniel Stenberg <daniel@haxx.se>
Sun, 5 Jun 2022 09:41:49 +0000 (11:41 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 6 Jun 2022 09:53:49 +0000 (11:53 +0200)
Getting more than a thousand of them is rather a sign of some kind of
attack.

Reported-by: Harry Sintonen
Bug: https://hackerone.com/reports/1589847
Closes #8962

lib/http2.c

index cb17fe3ad6bd60eb97fb88e40f46fe2440a93911..0fd91a920f24e58c88e3cfe93dace5b85952add2 100644 (file)
@@ -1050,6 +1050,12 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
     else if(stream->push_headers_used ==
             stream->push_headers_alloc) {
       char **headp;
+      if(stream->push_headers_alloc > 1000) {
+        /* this is beyond crazy many headers, bail out */
+        failf(data_s, "Too many PUSH_PROMISE headers");
+        Curl_safefree(stream->push_headers);
+        return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
+      }
       stream->push_headers_alloc *= 2;
       headp = Curl_saferealloc(stream->push_headers,
                                stream->push_headers_alloc * sizeof(char *));