Re: [hybi] Experiment comparing Upgrade and CONNECT handshakes

Willy Tarreau <w@1wt.eu> Sat, 27 November 2010 16:15 UTC

Return-Path: <w@1wt.eu>
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 F34D428C0D8 for <hybi@core3.amsl.com>; Sat, 27 Nov 2010 08:15:37 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.112
X-Spam-Level:
X-Spam-Status: No, score=-1.112 tagged_above=-999 required=5 tests=[AWL=-1.483, BAYES_40=-0.185, HELO_IS_SMALL6=0.556]
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 LbP55TMSKSFi for <hybi@core3.amsl.com>; Sat, 27 Nov 2010 08:15:37 -0800 (PST)
Received: from 1wt.eu (1wt.eu [62.212.114.60]) by core3.amsl.com (Postfix) with ESMTP id 9DA3328C0DC for <hybi@ietf.org>; Sat, 27 Nov 2010 08:15:36 -0800 (PST)
Received: (from willy@localhost) by mail.home.local (8.14.4/8.14.4/Submit) id oARGGcG3029955; Sat, 27 Nov 2010 17:16:38 +0100
Date: Sat, 27 Nov 2010 17:16:38 +0100
From: Willy Tarreau <w@1wt.eu>
To: Eric Rescorla <ekr@rtfm.com>
Message-ID: <20101127161638.GE26428@1wt.eu>
References: <AANLkTim_8g-Cb01si00EkvCK5BtXUx3zHsUee1F6JqsD@mail.gmail.com> <AANLkTimSu1fOGCg0gqX2EFh4v-MkpZuY_-onm3+TO_Z0@mail.gmail.com> <AANLkTimYpdp-75BQSmhAUfyrQv19LvzF1ouznst+ANUG@mail.gmail.com> <AANLkTikbycTS51Ein9ybbZ52zcrViFCNBjCmpRGD3yCk@mail.gmail.com> <AANLkTim=_Ey_7tSJ0H8OKzip-UcwtJ=YMG5wf_f_qnty@mail.gmail.com> <20101127071644.GB26428@1wt.eu> <AANLkTi=Rqu-hm=Jy-GFf706smD8zEHbeD-oP7dNCN6Ro@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <AANLkTi=Rqu-hm=Jy-GFf706smD8zEHbeD-oP7dNCN6Ro@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] Experiment comparing Upgrade and CONNECT handshakes
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: Sat, 27 Nov 2010 16:15:38 -0000

On Sat, Nov 27, 2010 at 07:51:17AM -0800, Eric Rescorla wrote:
> Remember that you're talking to the attacker's server. That server generates
> a 200 with a content length of 0. And since requests without content-length
> are assumed to be empty, this is completely compliant.

Requests yes, but responses no ! No new request will be processed by an
intermediary if a response does not have a content-length, because the
end of the response is only defined by the end of the connection.

> I fear you misunderstand the situation. The text above is descriptive of a
> kind of proxy that can fail. We're observing such proxies in the field.

I'm sure you're not observing that precise situation, because those proxies
already cannot correctly work with pure HTTP then. And if those proxies are
so buggy then it's not the goal of WebSocket to try to work around their
HTTP weaknesses. It's the same as for the destIP vs Host header situation.
It's been known for quite a long time that some transparent proxies's filtering
can be bypassed by trying to make them connect to the real destination IP but
sending an accepted Host header. This is not websocket specific, this is a
flaw that impacts their HTTP processing already.

> Well, that may well be true, but what our results show is that current
> intermediaries
> appear to be rather more susceptible to this when Upgrade is used then
> when CONNECT is used.

Once again, I'm not surprized at all.

> > We could also ensure that an exchanged hello frame right after the
> > handshake
> > looks like an un parsable HTTP request/response or a parsable end of HTTP
> > request/response to intermediaries. One such easy solutions would be to
> > prevent any CR or LF byte from being sent in the whole framing. In this
> > case,
> > whatever the handshake, it's really the framing that's protecting you.
> >
> >
> These sound to me like heuristic defenses to protect you from the handshake
> being insecure.

No, those are defenses against the intermediaries that may unexpectedly
think framed data are new requests.

> What's the argument *for* having an insecure handshake?

There's no argument *for* having an insecure handshake, there are arguments
for having a safe HTTP-compliant handshake. The more we rely on corner cases
(eg: invalid host), the more issues we'll face in field due to specific cases
that will have to be handled.

Basically, my feeling is that we're just hacking instead of designing,
and that always leads to unsafe implementations.

> Both of these attacks are outside the Web threat model and enable much more
> serious attacks than WebSockets. In particular:
> 
> 1. If I can modify /etc/hosts (which typically requires root privileges) I
> can inject any malware of my choice onto the machine.

Except that with "websocket.invalid", you just need to access the file *once*
to divert all the traffic to any websocket site forever (ie until the change
is discovered).

> 2. If I can poison DNS, then I can mount cache attacks directly.

Once again, there's a difference between trying to inject a single host
in the hope to collect all traffic and trying to inject a specific host
that some users is supposed to be using.

> I'd rather have something which works by protocol construction than by
> > pure luck because hopefully nobody resolves websocket.invalid.
> 
> 
> It's not luck that people don't resolve websocket.invalid. However, we would
> certainly be willing to choose another bogus Host header that people had
> more confidence in, if that's somehow a sticking point.

I'd rather rely on the underlying protocol semantics and have something which
cannot fail by design than play with corner cases and tricks consisting in
using host names that people are the least likely to try to resolve. I suspect
that once this is deployed, we'll find infrastructures where people will put
these hostnames themselves on some machines in order to be able to solve some
issues, which will re-open a new can of worms.

Regards,
Willy