Ver código fonte

Fix: Potential Vulnerability in Cloned Function (#689)

* http: unset F_CHUNKED on new Transfer-Encoding

Duplicate `Transfer-Encoding` header should be a treated as a single,
but with original header values concatenated with a comma separator. In
the light of this, even if the past `Transfer-Encoding` ended with
`chunked`, we should be not let the `F_CHUNKED` to leak into the next
header, because mere presence of another header indicates that `chunked`
is not the last transfer-encoding token.

CVE-ID: CVE-2020-8287
PR-URL: nodejs-private/node-private#235
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>

* Update http_parser.c
tabudz 9 meses atrás
pai
commit
9a3c19c639
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      http/http_parser.c

+ 6 - 0
http/http_parser.c

@@ -1335,6 +1335,12 @@ reexecute:
                 parser->header_state = h_general;
               } else if (parser->index == sizeof(TRANSFER_ENCODING)-2) {
                 parser->header_state = h_transfer_encoding;
+                /* Multiple `Transfer-Encoding` headers should be treated as
+                 * one, but with values separate by a comma.
+                 *
+                 * See: https://tools.ietf.org/html/rfc7230#section-3.2.2
+                 */
+                parser->flags &= ~F_CHUNKED;
               }
               break;