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

Alexander Voronin <alexander.voronin@gmail.com> Fri, 24 September 2010 15:08 UTC

Return-Path: <alexander.voronin@gmail.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 2ED6C3A6A30 for <hybi@core3.amsl.com>; Fri, 24 Sep 2010 08:08:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.28
X-Spam-Level:
X-Spam-Status: No, score=-0.28 tagged_above=-999 required=5 tests=[AWL=-0.132, BAYES_00=-2.599, HTML_MESSAGE=0.001, MIME_CHARSET_FARAWAY=2.45]
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 bAJPuki20wpb for <hybi@core3.amsl.com>; Fri, 24 Sep 2010 08:08:00 -0700 (PDT)
Received: from mail-gy0-f172.google.com (mail-gy0-f172.google.com [209.85.160.172]) by core3.amsl.com (Postfix) with ESMTP id 8E2343A6A94 for <hybi@ietf.org>; Fri, 24 Sep 2010 08:08:00 -0700 (PDT)
Received: by gya1 with SMTP id 1so937175gya.31 for <hybi@ietf.org>; Fri, 24 Sep 2010 08:08:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=43xGYQYo6TxHNLys+qTY1mIaxFSDfWOgfiqRfQ4OChc=; b=s+GdaJ03VOPVXGdc2lNOjXFMD/fqT+aduu/UHP34TpSKsPOI1S5VwhFZNEMn+H0eXv nb8U0Jx3ak95haJSziY7Viiu2bV+04pwSVdBDLgo46fIOcpDt+Fp01hGEzpuLkl698/m pjcAnkCogUgB3fMbjpUbqxNyMSrnEEUdjSxv8=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=CslZDI+ZBwCJnXbwjdeAWgvx+zJ/XSrC0efEEtjiKMo9bQQardb0HD02rbqbK2OBft knqQ4qpfaCt8/HhkeJeHoXnCyU3uuEM53B94nIerU9UBOb3mET2nN8R7Kbn7qmn3aYK/ dM7CRO9eGkWh90b6HvaGdzFKlgvMG/hStcnrs=
MIME-Version: 1.0
Received: by 10.150.229.17 with SMTP id b17mr4797829ybh.379.1285340911628; Fri, 24 Sep 2010 08:08:31 -0700 (PDT)
Received: by 10.231.152.85 with HTTP; Fri, 24 Sep 2010 08:08:31 -0700 (PDT)
In-Reply-To: <20100924145816.GB28314@1wt.eu>
References: <AANLkTikszM0pVE-0dpZ2kv=i=y5yzS2ekeyZxtz9N=fQ@mail.gmail.com> <AANLkTikczXMx9XSY4jGaVwh5LndRTTLg==+LPj=JmiGk@mail.gmail.com> <AANLkTi=_TYM1vZrZYBoSu+8j9WrSXfaZ42EMRmnF3rnz@mail.gmail.com> <AANLkTi=gqCD=ymNawDYnpRommm2CesrBFqC-eDCpuFvG@mail.gmail.com> <AANLkTikKgvO28yKrE3X7FrAnssFFkrogwWbYo6pJEsJC@mail.gmail.com> <20100924145816.GB28314@1wt.eu>
Date: Fri, 24 Sep 2010 18:08:31 +0300
Message-ID: <AANLkTimYMc+YvUd0bBmWtdSTC0S5Gm34cSE0c26e5RMg@mail.gmail.com>
From: Alexander Voronin <alexander.voronin@gmail.com>
To: Willy Tarreau <w@1wt.eu>
Content-Type: multipart/alternative; boundary="000e0cd4d8e073f942049102c069"
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: Fri, 24 Sep 2010 15:08:02 -0000

Let's see whats happen when we using WebSocket:
1. JavaScript creates socket


var webSocket = new WebSocket('ws://localhost/echo');


2. Browser here can't send any kind of data, but just handshaking

GET /echo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
WebSocket-Protocol: sample

---

HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://example.com
WebSocket-Location: ws://example.com/demo
WebSocket-Protocol <http://example.com/demoWebSocket-Protocol>: sample


3. Just now after browser GOT 101 and correct handshake data we can sand
some data

webSocket.send ("some data that ca not be placed in other than HTTP stream");


So You still think there is posible to "protect" something with MD5, BIG
ENDIAN, or some other kind of ugly string manipulations? Handshake must be
simple and clear just to ensure this is correct HTTP server/proxy and it's
compatible with WebSockets. Before that browser will not allow JavaScript to
send ANY data.

2010/9/24 Willy Tarreau <w@1wt.eu>

> On Fri, Sep 24, 2010 at 05:50:57PM +0300, Alexander Voronin wrote:
> > Intermediates and servers that have no WebSockets support will answer to
> > handshake with any code but no 101. Is that still not enough to figure
> out
> > if WebSocket connection established? Why to make things complex if they
> > could be simple?
>
> I think that the point that you missed is that since WS works on top of
> HTTP, any HTTP-compliant intermediary will implicitly support WS. However,
> we're aware that there are some incomplete HTTP implementations, and some
> intermediaries which by design will not let that pass through, reason why
> it's important to detect failures quickly.
>
> > Also I did not get this
> > article<http://www.ietf.org/mail-archive/web/hybi/current/msg04166.html
> >by
> > email, but will answer here. Referenced document provides sample of
> > cross-protocol attack using HTTP POST on SMTP. POST is a one-stage
> request
> > without handshake, WebSocket is a GET extension with handshake, so I
> guess
> > does not matter how complicated handshake will be if browser not obey
> HTTP
> > rules and continue HTTP session after getting "500 Command unrecognized"
> > instead of "HTTP/1.1 101 OK". This is not protocol but browser issue.
>
> No, the issue happens before. Imagine that the browser sends an HTTP-based
> handshake immediately followed by a certain amount of bytes that are to be
> understood by the remote server. If that remote server simply ignores the
> handshake because it does not understand it (as most services do), it will
> start to process the rules that follow the handshake. An SMTP server might
> very well accept spam that are sent as a POST request (my mail server
> receives hundreds of those every day).
>
> Whether the browser stops or not when receiving the "500 Command
> unrecognized"
> is irrelevant to the problem, the harm has already been done.
>
> Willy
>
>


-- 
когда я опустился на самое дно, снизу мне постучали..