Re: [hybi] Why redirects are a bad for the security of WebSockets (was Re: Clarify wheter HTTP responses other than 101 are valid)

Greg Wilkins <> Mon, 28 March 2011 21:04 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 589AA28C104 for <>; Mon, 28 Mar 2011 14:04:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2.341
X-Spam-Status: No, score=-2.341 tagged_above=-999 required=5 tests=[AWL=0.036, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, J_CHICKENPOX_66=0.6, RCVD_IN_DNSWL_LOW=-1]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id kPcowvuecJU9 for <>; Mon, 28 Mar 2011 14:04:32 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 4A14228C0F0 for <>; Mon, 28 Mar 2011 14:04:31 -0700 (PDT)
Received: by vws12 with SMTP id 12so3102577vws.31 for <>; Mon, 28 Mar 2011 14:06:08 -0700 (PDT)
MIME-Version: 1.0
Received: by with SMTP id zs8mr501214vdb.184.1301346368648; Mon, 28 Mar 2011 14:06:08 -0700 (PDT)
Received: by with HTTP; Mon, 28 Mar 2011 14:06:08 -0700 (PDT)
In-Reply-To: <>
References: <>
Date: Tue, 29 Mar 2011 08:06:08 +1100
Message-ID: <>
From: Greg Wilkins <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Cc: Patrick McManus <>
Subject: Re: [hybi] Why redirects are a bad for the security of WebSockets (was Re: Clarify wheter HTTP responses other than 101 are valid)
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Mon, 28 Mar 2011 21:04:33 -0000

On 29 March 2011 07:34, Adam Barth <> wrote:
> Consider the following code:
> var url = <obtain URL from somewhere, e.g. postMessage>
> if (!url.startsWith("wss://"))
>  return;
> var socket = new WebSocket(url);
> socket.onopen = function () {
>  [... interact with socket ...]
> };
> Reading this code, it's quite natural to assume that sending and
> receiving information on socket will actually communicate with
>  For example, I might send confidential information to
> or rely upon the integrity of information received from
>  However, if has has an open redirector (as
> is extremely common on the Internet), this assumption is incorrect and
> leads to vulnerabilities.
> Now, we can wring our hands and claim that this sort of issue isn't
> our problem, but it is.  Simply warning folks about these traps in
> Security Considerations is just passing the buck.  Instead, we
> shouldn't add this complexity to WebSockets at this time.  We can
> always change out minds and add support for redirects in the future,
> but we can never remove support once added.


I don't think it is "our problem".     I think it is a "W3C/WHATWG
HTML-5 WG problem".

This is essentially an API issue for the browser websocket object.
There are plenty of ways around this (adding optional follow
redirects, exposing redirect responses etc. etc.),   but I think it is
the W3C and WHATWG HTML-5 working groups that should be where such
matters are decided.

As a web developer I really rather not have to go without redirection
and other common auth methods - and I take responsibility for my
servers not being open redirectors..... but would understand if the
W3C/WHATWG decided not to support these features - at least initially.

However, we should make the protocol such that if/when the API does
support these features, then it will only be an in browser change and
not an update of the protocol.