Re: [hybi] Web sockets and existing HTTP stacks

Maciej Stachowiak <mjs@apple.com> Wed, 03 February 2010 22:17 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 0AAC83A6B66 for <hybi@core3.amsl.com>; Wed, 3 Feb 2010 14:17:17 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.59
X-Spam-Level:
X-Spam-Status: No, score=-106.59 tagged_above=-999 required=5 tests=[AWL=0.008, BAYES_00=-2.599, HTML_MESSAGE=0.001, 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 qKxrn0DCQxT4 for <hybi@core3.amsl.com>; Wed, 3 Feb 2010 14:17:15 -0800 (PST)
Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by core3.amsl.com (Postfix) with ESMTP id BBA913A6A9B for <hybi@ietf.org>; Wed, 3 Feb 2010 14:17:15 -0800 (PST)
Received: from relay16.apple.com (relay16.apple.com [17.128.113.55]) by mail-out4.apple.com (Postfix) with ESMTP id 9719789FDA24 for <hybi@ietf.org>; Wed, 3 Feb 2010 14:17:59 -0800 (PST)
X-AuditID: 11807137-b7bd4ae000000f0d-a5-4b69f61712e8
Received: from et.apple.com (et.apple.com [17.151.62.12]) by relay16.apple.com (Apple SCV relay) with SMTP id EF.1A.03853.716F96B4; Wed, 3 Feb 2010 14:17:59 -0800 (PST)
MIME-version: 1.0
Content-type: multipart/alternative; boundary="Boundary_(ID_FyFUHhWgEXyKt4lNpz4LOA)"
Received: from [10.0.1.5] (c-69-181-42-237.hsd1.ca.comcast.net [69.181.42.237]) by et.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0KXA00A01DXXE3B0@et.apple.com> for hybi@ietf.org; Wed, 03 Feb 2010 14:17:59 -0800 (PST)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <ad99d8ce1002030956w7503957eg8bd6e88da66a884a@mail.gmail.com>
Date: Wed, 03 Feb 2010 14:17:57 -0800
Message-id: <D8279D52-AE47-46F6-84DA-8E348116662A@apple.com>
References: <557ae280911171402v7546e5e7n93a1e57f87dc10e5@mail.gmail.com> <ad99d8ce1002012139l3b8f525bj9caf7861332f3d18@mail.gmail.com> <1427E183-FDBC-4854-9455-B93AB28DAB03@apple.com> <ad99d8ce1002012343n132169f8wbaacc1cf4efe2f87@mail.gmail.com> <31123817-6D3F-489D-9F48-109AC93E6769@apple.com> <ad99d8ce1002030000i566f3517qddf4e62f386c9211@mail.gmail.com> <4B692EDB.1060300@gmx.de> <E9DF7FE9-70F0-4268-8CEF-1007D71F9FBB@apple.com> <ad99d8ce1002030107i5994c847yf639b660dc64cdc9@mail.gmail.com> <7CB6EE56-B840-4368-ABAF-C8AA1CCE6600@apple.com> <ad99d8ce1002030956w7503957eg8bd6e88da66a884a@mail.gmail.com>
To: Roberto Peon <fenix@google.com>
X-Mailer: Apple Mail (2.1077)
X-Brightmail-Tracker: AAAAAQAAAZE=
Cc: hybi@ietf.org
Subject: Re: [hybi] Web sockets and existing HTTP stacks
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 22:17:17 -0000

On Feb 3, 2010, at 9:56 AM, Roberto Peon wrote:

> 
> 
> On Wed, Feb 3, 2010 at 2:02 AM, Maciej Stachowiak <mjs@apple.com> wrote:
> 
> On Feb 3, 2010, at 1:07 AM, Roberto Peon wrote:
> 
> >
> > How exactly does the random bit of text in the first line help?
> 
> In the case of a cross-protocol attack against HTTP, it's likely harder to inject text into the status line than it is to inject a response header, so that's the reason why it is in the first line. In the case of a cross-protocol attack against other protocols, in general it's harder to mess with the very beginning of the server response than the end (though not always).
> 
> The text is not random, it is a hash of some information from the request. The reason for the particular nature of the bit of text is to further increase the challenge of cross-protocol attacks by requiring the handshake response to contain something that (a) cannot be predicted before client JS tries to initiate the connection; and (b) is not a verbatim echo of anything in the handshake request. So even if you can find a server that will echo back exact text of your choice, or pieces of the request of your choice, you cannot make it return what appears to be a valid handshake response.
> 
> You can still do this as an HTTP header.

Indeed! And that was my original proposal. But I have been advised that the status line could afford stronger protection.

>  
> 
> > You still have to frame the HTTP response, which means that any errors in that framing are going to be causing problems.
> 
> I don't understand what kinds of problems you have in mind, could you clarify?
> 
> HTTP header injection problems: If it is possible, you can get interesting things to happen. This true of anything which is attempting to frame HTTP, and thus isn't limited to WebSockets, however, when it happens on a server there is no way to recover safely. The real problem with these is that the server has no idea that it happened without scanning its own output to see that it is framed the way it expects (and I don't know of any server which does this).

My proposal (both the header version and the status line version) should be effective at protecting normal Web servers from WebSocket even if there is a header injection vulnerability; likewise it should still help protect WebSocket servers from HTTP. Even if you can trick the server into injecting a header in its response, you can't predict the nonce, so you can't make it return a correct handshake.

>  
> 
> > In other words, the response will always be as insecure as HTTP. No way around that while still using HTTP. And, as we've already covered, not using HTTP isn't a terribly good option while on port 80 until the upgrade has finished.
> 
> Again, I don't know what you mean by "as insecure as HTTP". Specifically what we're worried about here are cross-protocol attacks (both using WebSocket and against a WebSocket service). The fact that the handshake format is an HTTP request does increase the risk in both directions, but we can do things to mitigate it. If you think my proposed defense is ineffective, could you explain how?
> 
> MitM still works just fine even with the hash value.
> What is the attack vector that you see mitigated? I may just not be seeing it.

Cross-protocol attacks, either using WebSocket from the browser to attempt to talk to plain HTTP another protocol; or using vanilla HTTP (via cross-site XMLHttpRequest) to attempt to talk to WebSocket. I explained both in detail in an earlier message.

Regards,
Maciej