Re: [hybi] Client offers invalid WS protocols, what must the server do? 101???

Alexey Melnikov <alexey.melnikov@isode.com> Tue, 30 August 2011 11:02 UTC

Return-Path: <alexey.melnikov@isode.com>
X-Original-To: hybi@ietfa.amsl.com
Delivered-To: hybi@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A433121F8BDC for <hybi@ietfa.amsl.com>; Tue, 30 Aug 2011 04:02:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -102.402
X-Spam-Level:
X-Spam-Status: No, score=-102.402 tagged_above=-999 required=5 tests=[AWL=-0.103, BAYES_00=-2.599, MIME_8BIT_HEADER=0.3, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hVEjr2qoN-M5 for <hybi@ietfa.amsl.com>; Tue, 30 Aug 2011 04:02:40 -0700 (PDT)
Received: from rufus.isode.com (rufus.isode.com [62.3.217.251]) by ietfa.amsl.com (Postfix) with ESMTP id E258921F8B5D for <hybi@ietf.org>; Tue, 30 Aug 2011 04:02:39 -0700 (PDT)
Received: from [192.168.1.124] ((unknown) [62.3.217.253]) by rufus.isode.com (submission channel) via TCP with ESMTPA id <TlzDUgBpJqDA@rufus.isode.com>; Tue, 30 Aug 2011 12:02:52 +0100
X-SMTP-Protocol-Errors: NORDNS
Message-ID: <4E5CBEA0.2080605@isode.com>
Date: Tue, 30 Aug 2011 11:42:40 +0100
From: Alexey Melnikov <alexey.melnikov@isode.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915
X-Accept-Language: en-us, en
To: Iñaki Baz Castillo <ibc@aliax.net>
References: <CALiegfkC9dLOnLfSQApE9OjoSV1RXT7cTumZ6+yCR1tWo_cvmw@mail.gmail.com>
In-Reply-To: <CALiegfkC9dLOnLfSQApE9OjoSV1RXT7cTumZ6+yCR1tWo_cvmw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-transfer-encoding: quoted-printable
Cc: hybi@ietf.org
Subject: Re: [hybi] Client offers invalid WS protocols, what must the server do? 101???
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/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, 30 Aug 2011 11:02:40 -0000

Iñaki Baz Castillo wrote:

>Hi, the draft (12) says:
>
>       /subprotocol/
>          Either a single value representing the subprotocol the server
>          is ready to use or null.  The value chosen MUST be derived
>          from the client's handshake, specifically by selecting one of
>          the values from the "Sec-WebSocket-Protocol" field that the
>          server is willing to use for this connection (if any).  If the
>          client's handshake did not contain such a header field, or if
>          the server does not agree to any of the client's requested
>          subprotocols, the only acceptable value is null.  The absence
>          of such a field is equivalent to the null value (meaning that
>          if the server does not wish to agree to one of the suggested
>          subprotocols, it MUST NOT send back a |Sec-WebSocket-Protocol|
>          header field in its response).
>
>
>So if the server just supports protocols "aaa" and "bbb" but the
>client offers "ccc" and "ddd", the above text states that the server
>must reply 101 without Sec-WebSocket-Protocol header.
>
>So then, *what* are the client and the server supposed to speak now??
>If the client has ***explicitly*** offered protocols "ccc" and "ddd"
>and the server does not support them, the server should REJECT the WS
>handshake, sure, rather than sending a 101. IMHO "501 Not Implemented"
>could be a good HTTP response for this case.
>  
>
Subprotocols are optional in the WebSocket protocols. So the client 
can't say that a particular extension is required. It can only close the 
connection after the handshake completes without it.

>The WebSocket handshake (HTTP GET + 101) is a negotiation between
>client and server. If the negotiation fails, the WS GET request MUST
>be rejected rather than accepted.
>
>The current text seems to allow ugly JavaScript developers to set a
>random protocol string (just for funny) in the Websocket JS API for
>the function "connect(URL, protocols)". Please make it strict.
>