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

Add some security checks when handling a websocket connection. #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,38 @@ implementation must proceed according to the WebSocket [=server-side
requirements=], with the following steps run when deciding whether to
accept the incoming connection:

1. Let |resource name| be the resource name from [=reading the
client's opening handshake=]. If |resource name| is not in
|listener|'s [=list of WebSocket resources=], then stop
running these steps and act as if the requested service is not
1. Using the data from [=reading the client's opening handshake=]:

1. Let |resource name| be the resource name.

1. Let |host| be the value of the Host header, if any, or undefined otherwise.

1. Let |origin| the the value of the Origin header, if any, or undefined
otherwise.

1. If |resource name| is not in |listener|'s [=list of WebSocket resources=],
then stop running these steps and act as if the requested service is not
available.

1. If |host| is not an IP address, and is not a hostname that matches the
hostname of the WebSocket server or another hostname the implementation has
been configured to allow, or in any case if the implementation wants to
reject connections with |host| as the Host header, then stop running these
steps and act as if the requested service is not available.

Note: rejecting connections with unexpected values in the Host header
prevents DNS rebinding attacks. Implementations can opt to provide more
stringent controls where appropriate, for example only accepting connections
when the |host| value corresponds to a loopback interface [[!RFC5735]].

Comment on lines +574 to +578
Copy link
Contributor

@sadym-chromium sadym-chromium Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a note about the Docker edge case here as well: w3c/webdriver#1634 (comment)

1. If |origin| is not undefined, and does not match an origin that the
implementation has been configured to allow, then stop running these
steps and act as if the requested service is not available.

Note: rejecting connections with unexpected values in the Origin header is
necessary to prevent untrusted websites from establishing a WebDriver-BiDi
session.

1. If |resource name| is the byte string "<code>/session</code>",
and the implementation [=supports BiDi-only sessions=]:

Expand Down