Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid failing HTTP/2 requests with upgrade-insecure-requests #12799

Merged
merged 1 commit into from Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -422,13 +422,12 @@ private static HeaderType validate(int streamId, CharSequence name,

@SuppressWarnings("deprecation") // We need to check for deprecated headers as well.
private static boolean isConnectionHeader(CharSequence name) {
// These are the known standard and non-standard connection related headers:
// These are the known standard connection related headers:
// - upgrade (7 chars)
// - connection (10 chars)
// - keep-alive (10 chars)
// - proxy-connection (16 chars)
// - transfer-encoding (17 chars)
// - upgrade-insecure-requests (25 chars)
//
// We scan for these based on the length, then double-check any matching name.
int len = name.length();
Expand All @@ -449,7 +448,7 @@ private static boolean isConnectionHeader(CharSequence name) {
if (len == 16) {
return contentEqualsIgnoreCase(name, HttpHeaderNames.PROXY_CONNECTION);
}
return len == 25 && contentEqualsIgnoreCase(name, HttpHeaderNames.UPGRADE_INSECURE_REQUESTS);
return false;
}

private static boolean contains(Http2Headers headers, CharSequence name) {
Expand Down
Expand Up @@ -167,9 +167,6 @@ public void decodingConnectionRelatedHeadersMustFailValidation() throws Exceptio

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

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