MEDIUM: http-ana: Refuse invalid 101-switching-protocols responses
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Jan 2021 15:02:05 +0000 (16:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:27:48 +0000 (16:27 +0100)
commit6e6c7b128454314cca50a7deaaf44326ad2c0953
treed95e1639cf66c8df367c56638423c1ac50c33f1d
parent576c358508ace18fea4ed9a08827045600697f49
MEDIUM: http-ana: Refuse invalid 101-switching-protocols responses

A 101-switching-protocols response must contain a Connection header with the
Upgrade option. And this response must only be received from a server if the
client explicitly requested a protocol upgrade. Thus, the request must also
contain a Connection header with the Upgrade option. If not, a
502-bad-gateway response is returned to the client. This way, a tunnel is
only established if both sides are agree.

It is closer to what the RFC says, but it remains a bit flexible because
there is no check on the Upgrade header itself. However, that's probably
enough to ensure a tunnel is not established when not requested.

This one is not tagged as a bug. But it may be backported, at least to
2.3. It relies on :

  * MINOR: htx/http-ana: Save info about Upgrade option in the Connection header
src/http_ana.c