Re: [hybi] WebSocket handshake (HTTP and SSO)

Ian Fette (イアンフェッティ) <ifette@google.com> Wed, 01 September 2010 16:35 UTC

Return-Path: <ifette@google.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 C05583A6817 for <hybi@core3.amsl.com>; Wed, 1 Sep 2010 09:35:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.444
X-Spam-Level:
X-Spam-Status: No, score=-105.444 tagged_above=-999 required=5 tests=[AWL=0.232, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
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 IXFsPfwgYFI6 for <hybi@core3.amsl.com>; Wed, 1 Sep 2010 09:35:56 -0700 (PDT)
Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by core3.amsl.com (Postfix) with ESMTP id 40CFB3A69FD for <hybi@ietf.org>; Wed, 1 Sep 2010 09:35:51 -0700 (PDT)
Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id o81GaKYL002988 for <hybi@ietf.org>; Wed, 1 Sep 2010 09:36:21 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1283358981; bh=ZXQqyOy1bZxy6q83Vt9MEF8cnMw=; h=MIME-Version:Reply-To:In-Reply-To:References:Date:Message-ID: Subject:From:To:Cc:Content-Type; b=E13GSiHNRKhsb91OfAzRVVXPGpz16xdHZGat8kLew1ATPN8g1Hg9g+oamOFqpxNAo XC1hzjXYRGIkFond3nwvw==
Received: from yxn35 (yxn35.prod.google.com [10.190.4.99]) by hpaq6.eem.corp.google.com with ESMTP id o81GaIoH030944 for <hybi@ietf.org>; Wed, 1 Sep 2010 09:36:19 -0700
Received: by yxn35 with SMTP id 35so3403980yxn.41 for <hybi@ietf.org>; Wed, 01 Sep 2010 09:36:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:received:received:reply-to :in-reply-to:references:date:message-id:subject:from:to:cc :content-type; bh=w8rNj1SWf45MLWkPRBbVucm7IDiLchhY05VNvMvMt+8=; b=B5LJT9Ct1jFJe1XRo6sV8efsO2J1ebC2QKRnv9ZSJHxkRmvDHYIebrkByVQb44HeXp y+/RmNWSEHOHGHbORmIQ==
DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=e/dzatVrS5UyY9pDQ8oNG9yvhVWsYuYkrnzcyBYbXi07yduULzrEJxbErNpA3atcCK EBKD8rANpvQbTzNXVD6g==
MIME-Version: 1.0
Received: by 10.151.122.15 with SMTP id z15mr3730758ybm.249.1283358978590; Wed, 01 Sep 2010 09:36:18 -0700 (PDT)
Received: by 10.150.229.7 with HTTP; Wed, 1 Sep 2010 09:36:18 -0700 (PDT)
In-Reply-To: <AANLkTik3joD9ZKk8gtt5Nwa9kX0FpyGd6ZGc-G6yUPOc@mail.gmail.com>
References: <4C7A269F.8020306@gmail.com> <AANLkTinqJ+K-pqm7p7S+aviWVY==S0mJ9RBvNfpnTa02@mail.gmail.com> <AANLkTikCVNoJnKXTOTJadYJWYR356u1wZdVNdBwEh6cg@mail.gmail.com> <AANLkTik3Jo4rG8cTcHerpwPumT_X77bn9y5rDkZ8ZD33@mail.gmail.com> <AANLkTimabr-0gVy1Jpr0=i-Wfv6u-AnD+ReNvb0eajYO@mail.gmail.com> <4C7BDA8F.4080107@caucho.com> <4C7BF060.7070501@isdg.net> <4C7C2A33.6010405@caucho.com> <4C7C746F.1040006@isdg.net> <4C7D2B74.8030702@caucho.com> <4C7D5B20.9030503@isdg.net> <4C7DAECB.7050905@caucho.com> <AANLkTikS7L_04HDAsL6t+FrHZKVXQN2Gx1gmjh4gYLcb@mail.gmail.com> <AANLkTik3joD9ZKk8gtt5Nwa9kX0FpyGd6ZGc-G6yUPOc@mail.gmail.com>
Date: Wed, 01 Sep 2010 09:36:18 -0700
Message-ID: <AANLkTi=N_BTgPtFWRQd1i9EwSGB5vXT-poGexJ-cXOdQ@mail.gmail.com>
From: "Ian Fette (イアンフェッティ)" <ifette@google.com>
To: Greg Wilkins <gregw@webtide.com>
Content-Type: multipart/alternative; boundary="000e0cd5ca3609c839048f354ce8"
X-System-Of-Record: true
Cc: hybi <hybi@ietf.org>, Brodie Thiesfield <brodie@jellycan.com>
Subject: Re: [hybi] WebSocket handshake (HTTP and SSO)
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: ifette@google.com
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: Wed, 01 Sep 2010 16:35:58 -0000

On Wed, Sep 1, 2010 at 2:28 AM, Greg Wilkins <gregw@webtide.com> wrote:

> 2010/9/1 Ian Fette (イアンフェッティ) <ifette@google.com>:
> > On Tue, Aug 31, 2010 at 6:39 PM, Scott Ferguson <ferg@caucho.com> wrote:
> >> Or at least, I think that's what the protocol is trying to do. To me, it
> >> looks like a security -through-confusion protocol hacked together by
> someone
> >> with little security experience, who believes that a complicated,
> confusing
> >> protocol is more secure than a straightforward one. If no one can
> understand
> >> it, no one can attack it, I guess. That's just what it looks like to me.
> >
> > While I can appreciate that you may not care for the complexity of the
> > handshake, I would ask that you please not attack the experience of the
> > people involved in its design. Critiques of the protocol are certainly
> > welcome, but I don't think personal attacks are appropriate.
>
> Ian,
>
> I think I can rephrase Scott's concerns as a non personal attack.
>
> The current handshake contains a number of unusual security features
> that I do not think have had the rigorous analysis that such security
> algorithms deserve.
>
> The algorithm encodes 2 random integers as decimal digits randomly
> interspersed with other characters and spaces.  The algorithm requires
> the characters to be ignored, the spaces to be counted and the number
> to be divided by the number of spaces.
>
> Dividing a random number by another random number generated from the
> same random number generator can have unexpected numeric effects. I
> have previously experienced a problem with a random session ID where
> an attempt to "improve" a 32 bit random number by mixing in some salt
> and applying another random number from the same generator actually
> significantly reduced the search space.  An exploit was developed that
> give 3 session ID, a bit of brute force calculation and you could
> predict the next session with 1 in 48 accuracy. I fear that this
> algorithm, combined with a poor random number generator, may similarly
> be vulnerable, specially as the random characters and spaces will
> reveal more information about the internal state of the generator.
>
> The space counting is to protect against injection, but is not
> required if the nonce is generated after the path is passed to the
> websocket client. I simply don't understand the justification given in
> the specification for the random characters interspersed with the
> numbers.
>
> My counter proposal is that the nonce is sent simply as hex number in
> the header.  Since these numbers are generated after the path is
> passed to the websocket client, they cannot be predicted and thus
> cannot be injected.
>
> Are there any problems with this simpler approach?
>
>
Greg, thanks for the rephrasing. I wasn't as involved with the handshake
design, so apologies in advance if I misstate something. However, I'd like
to share what I believe was the intent of the scheme, in the hopes it may
clear up some of the confusion.

First, I'm not sure how important it is that the numbers are _strongly_
random, so long as they come from a sufficiently large pool of options (e.g.
from 0 to INT_MAX). The point of the handshake is not to establish e.g. key
material that will be used for securing the connection. Rather, the point of
the handshake is to ensure that each end is actually a WebSocket
server/client. Using the same number all the time could mean that the server
could always give back the same response, which would not be desirable as
that would imply that the server might not actually be parsing the entire
handshake, but rather just echoing things back. Using a different number
each time ensures that the server is actually parsing the handshake and not
just returning a predefined value. How strong the RNG is doesn't seem to be
critical for this, unless I've missed something.

As for the spaces, it's to protect against injection as you say. The goal is
to prevent it from being smuggled in the PATH in such a way that that e.g. a
HTTP request could be misinterpreted as a WS handshake request. As spaces
must be encoded in the path (%20) this is designed to prevent against that,
ditto with CRLF.

I think the worry is that a hex number in the header could be potentially
confused, and not offer the same protections.

I think some of the confusion is that this handshake isn't really designed
to provide a secure channel (e.g. choose keys that will be used to encrypt
further data), rather the handshake is to protect against cross-protocol
attacks, and so there are slightly different criteria.

While I might agree that it could perhaps be simpler and still work, there
is also an argument for defense in depth, and frankly it is not difficult to
implement (we and others have already done it), so I'm inclined not to want
to revisit it just for the sake of "I would prefer something simpler" -
would really rather move forward. There are some open issues on the
handshake that I would love to discuss, e.g. #4 - making sure that we fail
on intermediaries that won't forward data properly but at the same time not
hang on intermediaries - but redoing the whole thing based on preference
without any real demonstrated problems (and having people already
implemented it makes me confident it's possible to implement) isn't really
that enticing.


> regards
>