Re: [hybi] Handshake was: The WebSocket protocol issues.

Maciej Stachowiak <mjs@apple.com> Tue, 28 September 2010 05:27 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 95A633A6A90 for <hybi@core3.amsl.com>; Mon, 27 Sep 2010 22:27:53 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.483
X-Spam-Level:
X-Spam-Status: No, score=-105.483 tagged_above=-999 required=5 tests=[AWL=-1.284, BAYES_00=-2.599, J_CHICKENPOX_22=0.6, J_CHICKENPOX_24=0.6, J_CHICKENPOX_25=0.6, J_CHICKENPOX_47=0.6, 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 A0apwWPVrBUa for <hybi@core3.amsl.com>; Mon, 27 Sep 2010 22:27:52 -0700 (PDT)
Received: from mail-out3.apple.com (mail-out.apple.com [17.254.13.22]) by core3.amsl.com (Postfix) with ESMTP id 22A593A6C37 for <hybi@ietf.org>; Mon, 27 Sep 2010 22:27:52 -0700 (PDT)
Received: from relay11.apple.com (relay11.apple.com [17.128.113.48]) by mail-out3.apple.com (Postfix) with ESMTP id B71B7AB9C8FE for <hybi@ietf.org>; Mon, 27 Sep 2010 22:28:32 -0700 (PDT)
X-AuditID: 11807130-b7cf8ae0000058d2-96-4ca17d001044
Received: from et.apple.com (et.apple.com [17.151.62.12]) by relay11.apple.com (Apple SCV relay) with SMTP id AA.A7.22738.00D71AC4; Mon, 27 Sep 2010 22:28:32 -0700 (PDT)
MIME-version: 1.0
Content-transfer-encoding: 7bit
Content-type: text/plain; charset="us-ascii"
Received: from [17.151.102.217] by et.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0L9F000X7Z7K1A40@et.apple.com> for hybi@ietf.org; Mon, 27 Sep 2010 22:28:32 -0700 (PDT)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <20100928052501.GD12373@1wt.eu>
Date: Mon, 27 Sep 2010 22:28:31 -0700
Message-id: <CA8029B0-71A3-44ED-88C6-934FE833BBA2@apple.com>
References: <AANLkTikszM0pVE-0dpZ2kv=i=y5yzS2ekeyZxtz9N=fQ@mail.gmail.com> <62B5CCE3-79AF-4F60-B3A0-5937C9D291D7@apple.com> <AANLkTikKc+4q_Q1+9uDo=ZpFF6S49i6vj2agZOGWVqKm@mail.gmail.com> <E2D38FF3-F1B9-4305-A7FC-A9690D2AEB4A@apple.com> <AANLkTikRYB_suPmSdH3uzGmdynozECRszDx+BpUvtZ4h@mail.gmail.com> <5CBF797D-A58E-4129-96B3-164F6E7409B9@apple.com> <4CA0D0D2.4040006@caucho.com> <AANLkTinACqm-GxUPhvFMf6_sGfeJofwy1r=28o=vgM43@mail.gmail.com> <4CA12810.8020006@caucho.com> <AANLkTimrMfXrnVMjU3f57L_sO7usyYQ56rBM4aMb2Pfr@mail.gmail.com> <20100928052501.GD12373@1wt.eu>
To: Willy Tarreau <w@1wt.eu>
X-Mailer: Apple Mail (2.1081)
X-Brightmail-Tracker: AAAAAA==
Cc: hybi <hybi@ietf.org>
Subject: Re: [hybi] Handshake was: The WebSocket protocol issues.
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: Tue, 28 Sep 2010 05:27:53 -0000

On Sep 27, 2010, at 10:25 PM, Willy Tarreau wrote:

> On Tue, Sep 28, 2010 at 10:30:14AM +1000, Greg Wilkins wrote:
>> On 28 September 2010 09:26, Scott Ferguson <ferg@caucho.com> wrote:
>>> Greg Wilkins wrote:
>>>> 
>>>> Scott,
>>>> 
>>>> yes - I glossed over the details of what the actual hash should be in
>>>> the ping packet.  I believe H(c-nonce, "WebSocket") is a good hash
>>>> that indicates the server is a WS.
>>> 
>>> That's not quite the issue. It's the second hash in the PONG that's missing,
>>> because we also need to verify the client as a WS client and not a hijacked
>>> HTTP client (or hijacked future non-websocket client):
>> 
>> OK, I've got it.
>> 
>> For your proposal of a server nonce, then a HELLO op-code is more
>> appropriate than ping/pong as the pong should normally contain the
>> same content as the ping.
>> 
>> So my proposal was:
>> 
>> HTTP(upgrade,nonce)   -->
>> <-- HTTP(101)
>> <-- WS(ping,hash(nonce,"WebSocket"))
>> [ <-- * WS(op, data)  ]
>> --> WS(pong,hash(nonce,"WebSocket"))   ; client calls onOpen
>> [ * WS(op, data) -->  ]
>> 
>> 
>> Your amendment is
>> 
>> HTTP(upgrade,c-nonce)   -->
>> <-- HTTP(101)
>> <-- WS(hello,hash(c-nonce,"WebSocket"),s-nonce)
>> [ <-- * WS(op, data)  ]
>> --> WS(hello,hash(s-nonce,"WebSocket"))   ; client call onOpen
>> [ * WS(op, data) -->  ]
>> 
>> 
>> I'm not 100% convinced that the server nonce is really necessary, as
>> the client has already been validated by sending Sec-Headers and the
>> upgrade in the first place, and the contents of the ping message must
>> be copied into a pong message (and is not predictable if the nonce is
>> hidden from the client).
> 
> I really think that if we can get a clean WS-based handshake, we can
> get rid of the Sec-* headers, as the WS handshake will validate a much
> more serious part of the protocol than the HTTP headers with their
> tricks.

If we go with an HTTP-based handshake at all, we have to keep something in the original HTTP request that browser-hosted HTTP clients are assumed unable to send. Otherwise we'll significantly increase the risk of HTTP-vs-WebSocket cross-protocol attacks.

Regards,
Maciej