Skip to content

Commit 1817c64

Browse files
committed
Add some security checks when handling a websocket connection.
Check the Host and Origin headers for the incoming connection to verify the connection is allowed. The language is intended to allow the specific behaviour to be largely implementation defined, whilst recommending a default behaviour that prevents CSRF-type attacks (reject host headers that aren't an IP address or the server hostname, reject any requests with an origin header). Hopefully adding this text will ensure that implementations consider the security issues accepting a connection, even though it's not possible to give precise requirements that apply to all implementations.
1 parent 1917e89 commit 1817c64

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

index.html

+56-2
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,52 @@ <h3>Processing model</h3>
428428
received data, according to the requirements of [[RFC7230]]. If it
429429
is not possible to construct a complete <a>HTTP request</a>,
430430
the <a>remote end</a> must either close the <a>connection</a>,
431-
return an HTTP response with status code 500, or return
432-
an <a>error</a> with <a>error code</a> <a>unknown error</a>.
431+
return an HTTP response with status code 500, or <a>send an
432+
error</a> with <a>error code</a> <a>unknown error</a>, and then
433+
jump to step 1.
434+
435+
<li><p><p>If <var>request</var> has a <a>Host header</a>,
436+
let <var>host</var> be the value of that header. Otherwise
437+
let <var>host</var> be null.</p></li>
438+
439+
<li><p><p>If <var>request</var> has an <a>Origin header</a>,
440+
let <var>origin</var> be the value of that header. Otherwise
441+
let <var>origin</var> be null.</p></li>
442+
443+
<li><p>If any of the following conditions hold:</li>
444+
<ul>
445+
<li><p><var>host</var> doesn't match the <code>Host</code>
446+
grammar [[RFC7230]]</p></li>
447+
<li><p>The result of <a>host parsing</a> the <code>uri-host</code>
448+
part of <var>host</var> is not an <a>IP address</a>,
449+
a <a>domain</a> identical to the
450+
<a>host</a> of the HTTP server or to another <a>host</a> the
451+
implementation has been configured to allow.</p></li>
452+
<li><p>The <code>port</code> part of <var>host</var> is present
453+
but doesn't match the port of the HTTP server.</p></li>
454+
<li><p>The <code>port</code> part of <var>host</var> is not
455+
present, and the port of the HTTP server doesn't match the
456+
default port for the request's scheme.</p></li>
457+
<li><p> implementation wants to reject
458+
connections with <var>host</var> as the <a>Host header</a>.</li></p>
459+
</ul>
460+
<p>Then <a>send an error</a> with <a>error code</a> <a>unknown
461+
error</a>, and jump to step 1.</p>
462+
463+
<p class=note>Rejecting connections with unexpected values in the
464+
<a>Host header</a> prevents DNS rebinding attacks. Implementations can opt
465+
to provide more stringent controls where appropriate, for example
466+
only accepting connections when the <var>host</var> value
467+
corresponds to a loopback interface [[RFC5735]].</p></li>
468+
469+
<li><p>If <var>origin</var> is not null, and is not identical to an
470+
<a>Origin header</a> value that the implementation has been
471+
configured to allow, then stop running these steps and act as if the
472+
requested service is not available.</p>
473+
474+
<p class=note>Rejecting connections with unexpected values in
475+
the <a>Origin header</a> is necessary to prevent untrusted websites
476+
from establishing a WebDriver session.</p></li>
433477

434478
<li><p>Let <var>request match</var> be the result of the algorithm
435479
to <a>match a request</a> with <var>request</var>’s
@@ -10958,6 +11002,16 @@ <h2>Index</h2>
1095811002
it is supposed that the implementation supports the relevant subsets of
1095911003
[[RFC7230]], [[RFC7231]], [[RFC7232]], [[RFC7234]], and [[RFC7235]].
1096011004

11005+
<dd><p>The following terms are defined in the Web Origin Concept specification: [[RFC6454]]
11006+
<ul>
11007+
<!-- Origin header --> <li><dfn><a href="https://datatracker.ietf.org/doc/html/rfc6454#section-7">Origin header</a></dfn>
11008+
</ul>
11009+
11010+
<dd><p>The following terms are defined in the Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing specification: [[RFC7230]]
11011+
<ul>
11012+
<!-- Host header --> <li><dfn><a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.4">Host header</a></dfn>
11013+
</ul>
11014+
1096111015
<dd><p>The following terms are defined in the Cookie specification: [[RFC6265]]
1096211016
<ul>
1096311017
<!-- Compute cookie-string --> <li><dfn><a href=https://tools.ietf.org/html/rfc6265#section-5.4>Compute <code>cookie-string</code></a></dfn>

0 commit comments

Comments
 (0)