Re: [hybi] A WebSocket handshake

Adam Barth <ietf@adambarth.com> Fri, 08 October 2010 21:49 UTC

Return-Path: <ietf@adambarth.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 1B4F53A693C for <hybi@core3.amsl.com>; Fri, 8 Oct 2010 14:49:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.987
X-Spam-Level:
X-Spam-Status: No, score=-1.987 tagged_above=-999 required=5 tests=[AWL=-0.010, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kb8Xq-4-mQPQ for <hybi@core3.amsl.com>; Fri, 8 Oct 2010 14:49:38 -0700 (PDT)
Received: from mail-qy0-f172.google.com (mail-qy0-f172.google.com [209.85.216.172]) by core3.amsl.com (Postfix) with ESMTP id 714653A68C3 for <hybi@ietf.org>; Fri, 8 Oct 2010 14:49:38 -0700 (PDT)
Received: by qyk2 with SMTP id 2so514962qyk.10 for <hybi@ietf.org>; Fri, 08 Oct 2010 14:50:43 -0700 (PDT)
Received: by 10.229.182.130 with SMTP id cc2mr2515937qcb.36.1286574642217; Fri, 08 Oct 2010 14:50:42 -0700 (PDT)
Received: from mail-iw0-f172.google.com (mail-iw0-f172.google.com [209.85.214.172]) by mx.google.com with ESMTPS id l13sm2977521qck.7.2010.10.08.14.50.41 (version=SSLv3 cipher=RC4-MD5); Fri, 08 Oct 2010 14:50:41 -0700 (PDT)
Received: by iwn10 with SMTP id 10so1630941iwn.31 for <hybi@ietf.org>; Fri, 08 Oct 2010 14:50:40 -0700 (PDT)
Received: by 10.231.174.5 with SMTP id r5mr2732700ibz.132.1286574640132; Fri, 08 Oct 2010 14:50:40 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.231.149.20 with HTTP; Fri, 8 Oct 2010 14:50:09 -0700 (PDT)
In-Reply-To: <FACFC0FA-4ED4-4B18-BBCB-6D48D84D0D06@apple.com>
References: <AANLkTimQ5x-v+Mz_OHrNDdtVd94E+HOBWwo3_f1ktEeg@mail.gmail.com> <AB43D171-AC38-47CE-BDC7-401E6D782622@apple.com> <AANLkTimfXPuh=8z-Q75iLFApvi93Wq+kC4LY9ev=bGFu@mail.gmail.com> <FACFC0FA-4ED4-4B18-BBCB-6D48D84D0D06@apple.com>
From: Adam Barth <ietf@adambarth.com>
Date: Fri, 08 Oct 2010 14:50:09 -0700
Message-ID: <AANLkTinTLK5p0tErj0t0t=sGwqN8v19_F-J4k2=8iqe=@mail.gmail.com>
To: Maciej Stachowiak <mjs@apple.com>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] A WebSocket handshake
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 08 Oct 2010 21:49:40 -0000

On Fri, Oct 8, 2010 at 2:41 PM, Maciej Stachowiak <mjs@apple.com> wrote:
> On Oct 8, 2010, at 2:28 PM, Adam Barth wrote:
> > On Fri, Oct 8, 2010 at 2:10 PM, Maciej Stachowiak <mjs@apple.com> wrote:
> > > I like the general approach (based on CONNECT and encrypting the data
> > > stream), it seems more robust than depending on the details of error
> > > handling code.
> >
> > Thanks.  I think we can use the encrypted additional information sent
> > with the initial handshake to address the concerns you express above.
>
> It would be good to spell out the details of what additional information is
> sent and how. Then we could evaluate how much of a burden it would be for
> multiplexing servers to dispatch between HTTP and WebSocket, to dispatch to
> the right virtual host for WebSocket connections, and to dispatch among the
> "servlets" (or equivalent) that implement individual WebSocket resources.
> It seems like they would have to handle this differently than how it's
> currently done for HTTP, it would be useful to understand how different.

Ok.  We have a lot of flexibility in this regard.  If you like the
format of the current handshake, you could include the following in
the additional information (encrypted as described in the document):

        GET /demo HTTP/1.1
        Host: example.com
        Sec-WebSocket-Protocol: sample
        Origin: http://example.com

You can also include cookies or whatever else you like.  There are
only two constraints:

1) You don't want to include too many bytes to avoid spamming servers
with too much traffic before they've agreed to the connection.

2) You probably don't want to send message frames until the server
accepts the connection.  The reason for this is to let simple servers
just spam back the one-and-only origin they want to accept connections
from.  If we hold off on message frames until the handshake finishes,
the browser stops the attacker from sending them messages.  Otherwise,
they have to actively ignore messages from origins they don't like.

Adam