Closed Bug 1687021 Opened 4 years ago Closed 4 years ago

Case-sensitive "connection" upgrade request header check breaks WebSocket connection

Categories

(Remote Protocol :: Agent, defect, P3)

Firefox 86
defect

Tracking

(firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: barancev, Assigned: david.burns)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36

Steps to reproduce:

Using WebDriver client to establish websockets connection to devtools.

Actual results:

The client sends a request like this:

GET /devtools/browser/7bf2f22f-20c2-a24a-8e2e-65c915b33f68 HTTP/1.1
upgrade: websocket
connection: upgrade
sec-websocket-key: PVcEwBy4ZRRAg54cU+qcOg==
sec-websocket-version: 13
origin: http://localhost:59770
host: localhost:59770
accept: /
user-agent: AHC/2.1

but geckodriver responds with "400 Bad Request" and the log says

JavaScript error: chrome://remote/content/server/WebSocketHandshake.jsm, line 99: Error: The handshake request has incorrect Connection header

Expected results:

Looking at the WebSocketHandshake.jsm code I've found that it checks "connection" header to contain "Upgrade" token:

89 const connection = headers.get("connection");
90 if (
91 !connection ||
92 !connection
93 .split(",")
94 .map(t => t.trim())
95 .includes("Upgrade")
96 ) {
97 throw new Error("The handshake request has incorrect Connection header");
98 }

But according to RFC 6455 Section 4.2.1 it should perform a a check for

"A |Connection| header field that includes the token "Upgrade", treated as an ASCII case-insensitive value."

Some client bindings will send over the headers with either a capital
first letter and some might not. We need to handle all cases

Assignee: nobody → david.burns
Severity: -- → S3
Status: UNCONFIRMED → ASSIGNED
Component: geckodriver → Agent
Ever confirmed: true
Priority: -- → P3
Product: Testing → Remote Protocol
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ffd297fc8b7a Allow connection header names to be case insensitive. r=remote-protocol-reviewers,whimboo
See Also: → 1680733
Summary: An attempt to set connection to devtools rejected because of "incorrect Connection header" → Case-sensitive "connection" upgrade request header check breaks WebSocket connection
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: