istio: 403 response and Connection: close when "upgrade: TLS/1.2"
Is this the right place to submit this?
- This is not a security vulnerability or a crashing bug
- This is not a question about how to use Istio
Bug Description
Someone upgraded their httpclient5 from 5.3.1 to 5.4 and in doing so, all outbound requests fail when the application is running behind Istio.
Digging into it more, it looks like the client is adding the following upgrade headers:
curl -v -H "connection: Upgrade" -H "upgrade: TLS/1.2" http://app.search-one-read.svc.cluster.local
On face value this doesn’t seem to make sense to me, as the protocol is http:// 🤷 so I’ll raise that issue on the httpclient5 library.
However if I take envoy out of the picture, the remote webserver returns just fine (effectively ignoring the upgrade). That’s the behaviour I’d expect; similar to the way h2 upgrades work (h1 is just returned).
However envoy returns 403 Forbidden - which is odd in itself!
Envoy logs show:
{"time":"2024-09-21T19:41:59.061090Z","level":"debug","scope":"envoy http","msg":"Sending local reply with details upgrade_failed","caller":"external/envoy/source/common/http/filter_manager.cc:1075","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
{"time":"2024-09-21T19:41:59.061122Z","level":"debug","scope":"envoy http","msg":"closing connection due to connection close header","caller":"external/envoy/source/common/http/conn_manager_impl.cc:1759","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
{"time":"2024-09-21T19:41:59.061133Z","level":"debug","scope":"envoy http","msg":"encoding headers via codec (end_stream=true):\n':status', '403'\n'date', 'Sat, 21 Sep 2024 19:41:58 GMT'\n'connection', 'close'\n","caller":"external/envoy/source/common/http/conn_manager_impl.cc:1825","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
{"time":"2024-09-21T19:41:59.061149Z","level":"debug","scope":"envoy http","msg":"Codec completed encoding stream.","caller":"external/envoy/source/common/http/conn_manager_impl.cc:1937","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
{"time":"2024-09-21T19:41:59.061157Z","level":"debug","scope":"envoy http","msg":"doEndStream() resetting stream","caller":"external/envoy/source/common/http/conn_manager_impl.cc:250","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
{"time":"2024-09-21T19:41:59.061163Z","level":"debug","scope":"envoy http","msg":"stream reset: reset reason: local reset, response details: -","caller":"external/envoy/source/common/http/conn_manager_impl.cc:1894","thread":"38","ConnectionId":"351","StreamId":"14014941417083207925"}
This is going to be a nasty problem for us when other people start upgrading their httpclient5.
Version
1.23.1
Additional Information
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 11
- Comments: 25 (16 by maintainers)
Commits related to this issue
- feat(jersey-client): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflict... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(auth): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflicts with ou... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(jersey-client): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflict... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(auth): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflicts with ou... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(jersey-client): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflict... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(auth): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflicts with ou... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(jersey-client): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflict... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
- feat(auth): Disable HTTP upgrade request in Apache Client implementation From 5.3.1 to 5.4.0 Apache HTTP Client 5 introduced a TLS upgrade header for TLS 1/2 by default. This header conflicts with ou... — committed to SDA-SE/sda-dropwizard-commons by JoergSiebahn 2 years ago
I’m aware of the application-level workarounds, but we have too many, and without incorporating static analysis—such as the approach @Stono suggested—it still highly risky for teams upgrading their services, potentially leading to incidents. Ideally we’d also want to be covered for newly created services and third party code running in the cluster.
I believe there are still Istio changes that need to happen here. Reopening
The envoyfilter backfired hard for us and we ended up removing it. It has some funky interactions with tls origination that we couldn’t work out so as it stands, it was the “best” but certainly not complete, workaround.
We’re now in a position where we’re using static code analysis to try and detect the problem http clients in people’s builds and fail there unless they’ve mitigated it with config in their client.
Even when the envoy change lands (if/when) I’d imagine there’s still going to be a reasonable delay before that version is tested and released in an isito release (quarterly release lifecycle), so it’d be awesome to find a better workaround, but so far we’ve failed.
@keithmattix shall we reopen this given it isn’t stale it’s just pending https://github.com/envoyproxy/envoy/pull/37642#discussion_r1913606083
https://www.ietf.org/rfc/rfc2817.txt
Since a server that pre-dated the introduction of the upgrade header would respond normally, and the rfc does not explicitly state what should happen in that case, probably responding normally (i.e. proxying the request in this case) should be the default behaviour.