Re: [hybi] Redesigning the Web Socket handshake

Maciej Stachowiak <mjs@apple.com> Wed, 03 February 2010 15:51 UTC

Return-Path: <mjs@apple.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 7534B3A6C5A for <hybi@core3.amsl.com>; Wed, 3 Feb 2010 07:51:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.441
X-Spam-Level:
X-Spam-Status: No, score=-106.441 tagged_above=-999 required=5 tests=[AWL=0.158, BAYES_00=-2.599, 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 L-nm-w9I4iqi for <hybi@core3.amsl.com>; Wed, 3 Feb 2010 07:51:39 -0800 (PST)
Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by core3.amsl.com (Postfix) with ESMTP id 921C928C119 for <hybi@ietf.org>; Wed, 3 Feb 2010 07:51:39 -0800 (PST)
Received: from relay11.apple.com (relay11.apple.com [17.128.113.48]) by mail-out4.apple.com (Postfix) with ESMTP id 4F8D389EF89E for <hybi@ietf.org>; Wed, 3 Feb 2010 07:52:22 -0800 (PST)
X-AuditID: 11807130-b7b0aae00000102c-39-4b699bb67978
Received: from elliott.apple.com (elliott.apple.com [17.151.62.13]) by relay11.apple.com (Apple SCV relay) with SMTP id 77.DD.04140.6BB996B4; Wed, 3 Feb 2010 07:52:22 -0800 (PST)
MIME-version: 1.0
Content-transfer-encoding: 7bit
Content-type: text/plain; charset="us-ascii"
Received: from [17.151.86.222] by elliott.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0KX900LAGW39EJB0@elliott.apple.com> for hybi@ietf.org; Wed, 03 Feb 2010 07:52:22 -0800 (PST)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <5c902b9e1002030738j20d6a20dud9154b956c338a28@mail.gmail.com>
Date: Wed, 03 Feb 2010 07:52:21 -0800
Message-id: <E1EB568E-F023-4C69-B66A-AF55F1703438@apple.com>
References: <Pine.LNX.4.64.1002012305000.21600@ps20323.dreamhostps.com> <4B676E8C.70804@webtide.com> <Pine.LNX.4.64.1002020311030.3846@ps20323.dreamhostps.com> <4B679E2C.2080502@webtide.com> <FD440FEA-9F53-4F4C-8AA5-98B23318F0F7@apple.com> <5c902b9e1002021431w25768b2eu4e21244f080bed25@mail.gmail.com> <9A862D96-FD32-4532-BDBE-AAC5C82DB954@apple.com> <BD4D49B1-6EB0-425E-BA3C-AE34DE826739@apple.com> <5c902b9e1002030738j20d6a20dud9154b956c338a28@mail.gmail.com>
To: Justin Erenkrantz <justin@erenkrantz.com>
X-Mailer: Apple Mail (2.1077)
X-Brightmail-Tracker: AAAAAQAAAZE=
Cc: hybi@ietf.org
Subject: Re: [hybi] Redesigning the Web Socket 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: Wed, 03 Feb 2010 15:51:41 -0000

On Feb 3, 2010, at 7:38 AM, Justin Erenkrantz wrote:

> On Wed, Feb 3, 2010 at 12:20 AM, Maciej Stachowiak <mjs@apple.com> wrote:
>> I asked a security expert to review this and he had two suggestions:
>> 1) Include the nonce hash in the status line. The strongest protection
>> against cross-protocol attacks comes in the first few bytes, according to
>> him, so it should be as early as possible.
> 
> The drawback with doing it in the reason is that it is going to be
> substantially harder to trust that HTTP/1.1 clients and such get
> proper access to the reason.  (And, again, relying upon any bits in
> the reason is a violation of HTTP - the reason is *only* intended for
> human eyes.  I've seen hands slapped by Roy many times when folks try
> to expect that the reason is machine-parsable.)  Due to that, I think
> it's an acceptable tradeoff to just put it in the header as originally
> suggested.  It will likely still be in the first packet that the
> client receives.

The goal is more like "first few bytes" than "probably first packet". Remember, we're trying to defend against cross-protocol attacks, so what well-behaved clients and servers will do is not super relevant. I am more concerned with the security of the protocol than pleasing the aesthetic sense of HTTP gurus.

> 
>> 2) The hash should also include the request origin and some fixed
>> WebSocket-specific string (e.g. "WebSocket::"). (He actually suggested 'HMAC
>> the string "Web
>> Socket::" and origin of WebSocket request using the nonce as a key' but I'm
>> not sure if he was serious.)
> 
> Using the origin IP introduces a lot of problems when there are
> reverse proxies involved.

The origin is not an IP address. I'm talking about what goes in the WebSocket-Origin header. See the spec for an explanation and examples.

>  (Since it seems that prior discussions have
> belittled NATs and transparent forward proxies as not being
> "relevant", I'll set those aside - but I feel the implementation
> challenges are just as relevant there too.)  Try as some might to
> fight against it, we should simply realize that most large-scale WS
> deployments are going to see some type of reverse proxy sitting in
> front of it.  Therefore, the server generating the nonce probably
> won't know the origin easily

The nonce is actually generated by the client, not the server. I assume you mean the hash (produced from the nonce among other things). But see above. This doesn't relate to IP addresses.

> - and will have to rely upon custom
> information set by its reverse proxy in front of it to generate the
> proper nonce.  On the server-side, knowing the "real" origin IP is a
> very error-prone process and probably would give us more grief due to
> naive server implementations getting it wrong than we really intend.
> There is no HTTP standard for setting the origin IP on the hops, but
> most big sites end up setting some custom header out of necessity, but
> I expect many basic deployments do not do so.

 - Maciej