Re: [hybi] Insight you need to know: Browsers are at fault when servers crash

Maciej Stachowiak <mjs@apple.com> Mon, 26 July 2010 11:35 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 6D30E3A6A5C for <hybi@core3.amsl.com>; Mon, 26 Jul 2010 04:35:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.49
X-Spam-Level:
X-Spam-Status: No, score=-106.49 tagged_above=-999 required=5 tests=[AWL=0.109, 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 MytuG-g9Jyu8 for <hybi@core3.amsl.com>; Mon, 26 Jul 2010 04:35:24 -0700 (PDT)
Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by core3.amsl.com (Postfix) with ESMTP id 2E2853A679F for <hybi@ietf.org>; Mon, 26 Jul 2010 04:35:24 -0700 (PDT)
Received: from relay15.apple.com (relay15.apple.com [17.128.113.54]) by mail-out4.apple.com (Postfix) with ESMTP id 583FBA5572DA for <hybi@ietf.org>; Mon, 26 Jul 2010 04:35:45 -0700 (PDT)
X-AuditID: 11807136-b7cc9ae000004162-b1-4c4d7311dbe2
Received: from et.apple.com (et.apple.com [17.151.62.12]) by relay15.apple.com (Apple SCV relay) with SMTP id BE.4B.16738.1137D4C4; Mon, 26 Jul 2010 04:35:45 -0700 (PDT)
MIME-version: 1.0
Content-transfer-encoding: 7bit
Content-type: text/plain; charset="us-ascii"
Received: from [17.151.84.236] by et.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0L6500GMZXJKCJ40@et.apple.com> for hybi@ietf.org; Mon, 26 Jul 2010 04:35:45 -0700 (PDT)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <AANLkTin1PBskrUYFeOYzexwZOe++WSOCiSRbp6_RDCsh@mail.gmail.com>
Date: Mon, 26 Jul 2010 04:35:44 -0700
Message-id: <E15FFECE-32B6-49CB-B2D0-5D536A309523@apple.com>
References: <AANLkTilfxps1wWjFrwrH_3Js6Q9E331AMKFRNHfeHcdL@mail.gmail.com> <AANLkTi=vPAnnK0=gE=YN10vt9b-f6sWXXcwK+La5SriO@mail.gmail.com> <623C6D70-B4AF-49EC-BA07-6F90BD0FFFBF@apple.com> <AANLkTi=Q-PVrdaWuOu3H=wUiphe6JB4C+LauSOXKozoY@mail.gmail.com> <AANLkTi=Z-Zw3gJAdwQMAqG5UUVnV_kgsGm3M_qQ2Bwt7@mail.gmail.com> <8B47440C-7CFD-442F-94E3-96A8EBE7D25D@apple.com> <AANLkTimRo_ubic96z3VgwexiOw0KJg10HQedmcuBs6jp@mail.gmail.com> <FA3856A4-FF29-430E-8BE4-3049F1E33A03@apple.com> <AANLkTim14YJgikfeU9k84xMqtcFt0cdqJQZcsNmvt-Eo@mail.gmail.com> <1453160A-6353-4720-88BA-43D17038B4A7@apple.com> <AANLkTimT+mNXBoQO5L11_ibv645u8Se5K+GBhP9vKXmj@mail.gmail.com> <25137069-5C6D-4171-873D-65F9925077A8@apple.com> <AANLkTin1PBskrUYFeOYzexwZOe++WSOCiSRbp6_RDCsh@mail.gmail.com>
To: Adam Barth <ietf@adambarth.com>
X-Mailer: Apple Mail (2.1081)
X-Brightmail-Tracker: AAAAAQAAAZE=
Cc: hybi@ietf.org
Subject: Re: [hybi] Insight you need to know: Browsers are at fault when servers crash
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: Mon, 26 Jul 2010 11:35:25 -0000

On Jul 26, 2010, at 3:52 AM, Adam Barth wrote:

> On Mon, Jul 26, 2010 at 12:37 PM, Maciej Stachowiak <mjs@apple.com> wrote:
>> On Jul 26, 2010, at 3:16 AM, Adam Barth wrote:
>>> On Mon, Jul 26, 2010 at 11:45 AM, Maciej Stachowiak <mjs@apple.com> wrote:
>>>> On Jul 26, 2010, at 12:39 AM, Adam Barth wrote:
>>>>> You can also this this idea at the end
>>>>> of an HTTP-like handshake to get started sending data without waiting
>>>>> for the server to reply.
>>>> 
>>>> Doesn't this second design make WebSocket services potentially vulnerable to
>>>> cross-protocol attacks from HTTP? It's easy for the HTTP attacker to make up
>>>> a key and encrypt the attack payload with it, unless the server has to prove
>>>> it understands WebSocket based on part of the handshake that the in-browser
>>>> HTTP attacker can't control before it is allowed to process messages.
>>> 
>>> I don't quite follow.  You seem to be worried about the WebSocket
>>> server being attacked by a non-WebSocket client.  How does that relate
>>> to whether a WebSocket client waits for the server to acknowledge?
>> 
>> The current design requires the server to fairly thoroughly validate the handshake before it is even possible for it to process messages. A previous design made it easy for the server to ignore the handshake and just start processing messages. If the key for decoding messages is in the HTTP body, or any part of the request that could plausibly be controlled by an attacker, then we are back to that earlier state where it is much easier to accidentally write a vulnerable server. If the key appears in HTTP headers, then some amount of "rigidity" may be required to make it hard to forge it with a non-WebSocket HTTP request.
> 
> Ah, I understand.  We're worried about the consequences of common bugs
> in server implementations.  One approach is to use whatever value the
> server would have sent back to the client to verify that the server
> understood the handshake as part of the key for decrypting the body.
> That way the server is forced to do the same computation, we're just
> verifying it's correctness cryptographically.

The difficulty is that the computation has to validate the HTTP-level handshake, looking at elements that cannot easily be forged, or it suffers from the same problem I described above. If it is derived solely from portions of the request that could be attacker-controlled, then it is predictable to the attacker, so using it as part of the crypto key for the body is no obstacle to injecting chosen plaintext.

This means we'd need something with similar complexity to the current handshake, except we'd have the benefit that the first client --> server message can save a round trip.

On the other hand, using your scheme straight-up without a prior HTTP header is probably safe without any additional rigidity.

Regards,
Maciej