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

Scott Ferguson <ferg@caucho.com> Thu, 02 September 2010 01:36 UTC

Return-Path: <ferg@caucho.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 B1E073A6A49 for <hybi@core3.amsl.com>; Wed, 1 Sep 2010 18:36:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.186
X-Spam-Level:
X-Spam-Status: No, score=-2.186 tagged_above=-999 required=5 tests=[AWL=0.079, BAYES_00=-2.599, IP_NOT_FRIENDLY=0.334]
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 QVL+JkLDA5X8 for <hybi@core3.amsl.com>; Wed, 1 Sep 2010 18:36:35 -0700 (PDT)
Received: from smtp113.biz.mail.sp1.yahoo.com (smtp113.biz.mail.sp1.yahoo.com [69.147.92.226]) by core3.amsl.com (Postfix) with SMTP id E6E7C3A6A3E for <hybi@ietf.org>; Wed, 1 Sep 2010 18:36:33 -0700 (PDT)
Received: (qmail 65743 invoked from network); 2 Sep 2010 01:36:19 -0000
Received: from [192.168.1.11] (ferg@66.92.8.203 with plain) by smtp113.biz.mail.sp1.yahoo.com with SMTP; 01 Sep 2010 18:36:19 -0700 PDT
X-Yahoo-SMTP: L1_TBRiswBB5.MuzAo8Yf89wczFo0A2C
X-YMail-OSG: 5Z5XAKYVM1m6zAoKpFV6MuuYEFjvp0YyWp.ergJtMuaA0M3 cW4TozxK_5J.Lz27pdpgSg2Ym5lEYoLUV7s8tSqDbOHaO45pRDwSAh5RhEJ9 7433FqtQoUQkS3JCVlwewJmWPVcpJiLFysyOSWqkm9H5cLQXUcTk5sKQxSUN XVsXb4xzXm.6B.NctVoxmLHunE9lRkIXDy_0bf7iTHCsFir7um7ekMNn_h3D u6t0AedWYzgtqbmt0sfBQziBhf2ZhwdNERY5VSBjvb0lyjHti9LkroqASFXP nP5a.QYYn09jK5U.dbEiPIBE9b8oOVy3QboIXxt8hVDaxi2_SwkLA1xw-
X-Yahoo-Newman-Property: ymail-3
Message-ID: <4C7EFF8E.7040101@caucho.com>
Date: Wed, 01 Sep 2010 18:36:14 -0700
From: Scott Ferguson <ferg@caucho.com>
User-Agent: Thunderbird 2.0.0.24 (X11/20100411)
MIME-Version: 1.0
To: ifette@google.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> <AANLkTi=N_BTgPtFWRQd1i9EwSGB5vXT-poGexJ-cXOdQ@mail.gmail.com>
In-Reply-To: <AANLkTi=N_BTgPtFWRQd1i9EwSGB5vXT-poGexJ-cXOdQ@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-Transfer-Encoding: 8bit
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
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: Thu, 02 Sep 2010 01:36:41 -0000

Ian Fette (イアンフェッティ) wrote:
> On Wed, Sep 1, 2010 at 2:28 AM, Greg Wilkins <gregw@webtide.com 
> <mailto:gregw@webtide.com>> wrote:
>
>
>     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.
>
>     Dividing a random number by another random number generated from the
>     same random number generator can have unexpected numeric
>     effects....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.
>
>
>
> 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.

The randomness is important because if the hijacker can predict the next 
random number, he can pre-generate the server's response in the initial 
attack and might be able to trick the target server into echoing that 
response (as Adam pointed out earlier.)

To repeat Greg's point, randomness is a tricky business and it's very 
possible to reduce your bits of randomness by using non-cryptographic 
algorithms, like the operations in the current draft, without realizing 
the problems. You might have 64 bits of integer but only 8-12 bits of 
randomness.

That's why a plain hex-encoded nonce can be better than something 
complicated, because you know how many bits of randomness it has.
>
> 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. 

This is one of the problems in the current handshake. The parts that are 
trying to validate the server as a websocket server and the parts that 
are trying to validate the client as a websocket client are jumbled 
together in a way that makes it hard to evaluate and appears to 
compromise both validations.

For server validation, any hijacker injection of those keys is 
irrelevant if the key/nonce is kept secret from the hijacker and if the 
hash calculation is sound. It doesn't matter if he can inject bogus 
keys, because the bogus keys will cause the server to return a bogus 
hash and a bogus hash will be rejected by the client.

What matters is keeping the key/nonce secret from the hijacker, and 
using a solid hash function, so he can't generate the real hash.

For client validation, the draft looks pretty ad hoc. I don't see any 
clear strategy for validating the client as websocket. The presence of 
spaces in the header or the random bytes after the GET are not really 
verifying the client is a websocket client. They're just trying to break 
HTTP, which isn't the same thing.

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

That's one of the dangers of the current spec. Because it's confusing 
and looks like it does a lot, it appears more secure than a 
straightforward, standard security design.

> 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.

I don't think anyone has suggested that.
>
> 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.

Even with a defense in depth strategy, each security layer needs to 
solve its intended problem correctly.

-- Scott
>  
>
>     regards
>
>