Skip to content

Commit 570c5d7

Browse files
authored
Avoid failing HTTP/2 requests with upgrade-insecure-requests (#12799)
Motivation: This is a non-standard header that is not _explicitly_ called out as connection related, even though it can be argued that it is. Regardless, Chrome and Firefox do actually send this header in their HTTP/2 requests, so rejecting these is quite troublesome. Safari doesn't send this header. Modification: Remove the check for `upgrade-insecure-requests` in the header validation in HpackDecoder. Also update tests to match. Result: HTTP/2 requests from Chrome and Firefox are no longer rejected by the header validation. Fixes #12798
1 parent 75982ea commit 570c5d7

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,12 @@ private static HeaderType validate(int streamId, CharSequence name,
422422

423423
@SuppressWarnings("deprecation") // We need to check for deprecated headers as well.
424424
private static boolean isConnectionHeader(CharSequence name) {
425-
// These are the known standard and non-standard connection related headers:
425+
// These are the known standard connection related headers:
426426
// - upgrade (7 chars)
427427
// - connection (10 chars)
428428
// - keep-alive (10 chars)
429429
// - proxy-connection (16 chars)
430430
// - transfer-encoding (17 chars)
431-
// - upgrade-insecure-requests (25 chars)
432431
//
433432
// We scan for these based on the length, then double-check any matching name.
434433
int len = name.length();
@@ -449,7 +448,7 @@ private static boolean isConnectionHeader(CharSequence name) {
449448
if (len == 16) {
450449
return contentEqualsIgnoreCase(name, HttpHeaderNames.PROXY_CONNECTION);
451450
}
452-
return len == 25 && contentEqualsIgnoreCase(name, HttpHeaderNames.UPGRADE_INSECURE_REQUESTS);
451+
return false;
453452
}
454453

455454
private static boolean contains(Http2Headers headers, CharSequence name) {

codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2HeadersDecoderTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ public void decodingConnectionRelatedHeadersMustFailValidation() throws Exceptio
167167

168168
// Non-standard connection related headers:
169169
verifyValidationFails(decoder, encode(b(":method"), b("GET"), b("proxy-connection"), b("keep-alive")));
170-
verifyValidationFails(decoder, encode(b(":method"), b("GET"), b("upgrade-insecure-requests"), b("1")));
171-
verifyValidationFails(decoder, encode(b(":method"), b("GET"),
172-
b("content-security-policy"), b("upgrade-insecure-requests"), b("upgrade-insecure-requests"), b("1")));
173170

174171
// Only "trailers" is allowed for the TE header:
175172
verifyValidationFails(decoder, encode(b(":method"), b("GET"), b("te"), b("compress")));

0 commit comments

Comments
 (0)