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

Maciej Stachowiak <mjs@apple.com> Wed, 29 September 2010 16:46 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 9232A3A6D2C for <hybi@core3.amsl.com>; Wed, 29 Sep 2010 09:46:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.599
X-Spam-Level:
X-Spam-Status: No, score=-106.599 tagged_above=-999 required=5 tests=[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 8GUUlyozZq+F for <hybi@core3.amsl.com>; Wed, 29 Sep 2010 09:46:56 -0700 (PDT)
Received: from mail-out3.apple.com (mail-out.apple.com [17.254.13.22]) by core3.amsl.com (Postfix) with ESMTP id 6D65B3A6BB0 for <hybi@ietf.org>; Wed, 29 Sep 2010 09:46:56 -0700 (PDT)
Received: from relay16.apple.com (relay16.apple.com [17.128.113.55]) by mail-out3.apple.com (Postfix) with ESMTP id 5C289ABFA1D3 for <hybi@ietf.org>; Wed, 29 Sep 2010 09:47:40 -0700 (PDT)
X-AuditID: 11807137-b7b43ae00000547d-05-4ca36dac5320
Received: from elliott.apple.com (elliott.apple.com [17.151.62.13]) by relay16.apple.com (Apple SCV relay) with SMTP id 9A.7C.21629.CAD63AC4; Wed, 29 Sep 2010 09:47:40 -0700 (PDT)
MIME-version: 1.0
Content-transfer-encoding: 7bit
Content-type: text/plain; charset="us-ascii"
Received: from 67-218-104-244.cust.layer42.net (67-218-104-244.cust.layer42.net [67.218.104.244]) by elliott.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0L9I0000BPBDDY00@elliott.apple.com> for hybi@ietf.org; Wed, 29 Sep 2010 09:47:40 -0700 (PDT)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <AANLkTik9igUwoxVrktoBoZrPoUW=Tjh7HyVbGJgQYes-@mail.gmail.com>
Date: Wed, 29 Sep 2010 09:47:37 -0700
Message-id: <9F595226-FA0A-4C38-A6D0-0F4214BD7D21@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> <CA8029B0-71A3-44ED-88C6-934FE833BBA2@apple.com> <AANLkTim+fXj-h6OS3OdcfVfh3Q1UwxD8NLVawb=AWHX+@mail.gmail.com> <4FAC5C93-9BDF-4752-AFBC-162D718397AB@apple.com> <AANLkTikcH1W3bQwumqHbe-Yqa3XdoJqCa2b-mZuvoQ7g@mail.gmail.com> <9746E847-DC8B-45A7-ADF3-2ADB9DA7F82E@apple.com> <AANLkTik9igUwoxVrktoBoZrPoUW=Tjh7HyVbGJgQYes-@mail.gmail.com>
To: Greg Wilkins <gregw@webtide.com>
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: Wed, 29 Sep 2010 16:46:58 -0000

On Sep 29, 2010, at 3:28 AM, Greg Wilkins wrote:

> On 29 September 2010 18:56, Maciej Stachowiak <mjs@apple.com> wrote:
>> The raw HTTP request can include a body, which is sent immediately, rather
>> than waiting for the remainder of the handshake. The body can include
>> content framed as WS protocol messages. A WebSocket client will wait until
>> the handshake is complete. So yes, the possibility of attempting an HTTP
>> connection to a WebSocket server does create additional attack surface.
> 
> But how is the HTTP header going to be skipped by the WS server in
> order for it to find these encapsulated WS messages?
> 
> Both a HTTP server and a WS server will consume all of any HTTP
> request sent to it, so content will not be mistaken as new messages.
> 
> It is not sufficient just to send WS frames over the wire.  You have
> to explain how they are
> going to be sent so that a server will actually read them and
> interpret them WS messages.

The idea is that you make an HTTP request with a header that looks close enough to the WS handshake to fool the server, followed by what appear to be WS messages in the body.

> 
> 
> 
>> I suspect -76 is not strong enough, but it is slightly stronger in some
>> specific ways. First, by spreading the data across multiple header fields
>> and incorporating whitespace, it makes it slightly trickier to do injection
>> attacks.
> 
> Why is hex encoding simpler to inject than the space/char injected
> decimal encoding?

Because you can't inject whitespace into the resource name in the request line.

> The white space fields originate from the client and do not need to be
> injected into
> the server response.
> 
> Can you explain any scenario where a HTTP client could somehow send Sec- fields
> without spaces, but could not send ones with spaces?

Sticking something that looks like a Sec- header into the request line is possible (that is under the attacker's control with both WebSocket and HTTP APIs) but you can't include whitespace - it will get stripped or percent-escaped.

> 
> Also I've not proposed having only a single key field. We can still
> have two fields,
> so thus require data from multiple header fields.

Your proposal implied only a single nonce value, but I agree that aspect is not an essential part of your proposal.

> 
> 
> I think the bulk of your concerns are about HTTP handshakes in general and
> not specifically about my proposals to fix the handshake issues that
> we have now.
> Let's not forget that the current handshake with unframed random bytes
> is causing
> real problems with intermediaries now - so it needs to be fixed.

For the record, I don't think the unframed random bytes in the request add any security value.

As I understand it, they are intended to trigger fast-fail in unaware intermediaries without extra round trips. I do not personally have any data on whether they work for this purpose. We do seem to have some data that it causes unnecessary failures to connect. Any way to detect intermediaries that can't support WebSocket should ideally be tested in the field in some way (much as the older -75 handshake was). This applies both to new proposals and the -76 handshake, as far as I am concerned.

Personally, I would prefer if failure-detection mechanisms were kept separate from security mechanisms if possible.

Regards,
Maciej