-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: filter misdirected TLS requests #2483
Conversation
37e4f48
to
db6bea0
Compare
When using the wrong host, envoy responds with a 421:
When using the correct host, routing works right:
|
@stevesloka @youngnick LMK what you think about this approach. As far I know, this is the only way to fix #1493 . |
The right place is to fix upstream in Envoy, but this is a good workaround for now. This has existing for some time, nice work @jpeach! |
If it's the only way for now, I'm okay with it. I think we need to be clear that this doesn't mean we'll be adding support for arbitrary Lua filters (yet). I would like to see this removed in favour of a better upstream solution if it's implemented. |
I don't see much upstream activity on this. If we want something upstream we probably need to make a proposal and drive it. |
I can't do C++, so I can't do the coding, but I agree. |
I just chatted with another Contour user who ran into this. They are going to make a build and test it out to verify (in their environment) that this solves, but I think we should merge this if the tests go well and then release a v1.14.1 to include this and the ingress.class status info fixes. |
64ca014
to
b9ef916
Compare
Codecov Report
@@ Coverage Diff @@
## master #2483 +/- ##
==========================================
+ Coverage 77.10% 77.20% +0.10%
==========================================
Files 70 70
Lines 5736 5770 +34
==========================================
+ Hits 4423 4455 +32
- Misses 1218 1219 +1
- Partials 95 96 +1
|
09a3f79
to
191af02
Compare
In my use case this seems to fix the issue , even though i am confused by the regex in https://github.com/projectcontour/contour/pull/2483/files#diff-98b92a08d0022a6c73eceeb2e1d99a43R3128 which i would expect to be a negation ... but i obviously am not understanding this properly since it works :) my setup
with 1.4.0
Using a build of this branch
|
2efdcc0
to
b58edfb
Compare
@youngnick @stevesloka Could you please review? The diff is pretty big unfortunately, due to testing impact. The main functional change is around the new FilterMisdirectedRequests API. |
b58edfb
to
70e2937
Compare
TLS routes are specialized to a unique virtual hostname. However, if wildcard certificates are being used, browsers will aggressively coalesce and reuse server connections even when the full origin hostname doesn't match. This results on 404 responses because each TLS virtual host only has routes for one host. We can avoid this behaviour bleeding out to users by generating a 421 Misdirected Request response if the request authority doesn't match the FQDN of the virtual host. In this case, the browser is supposed to understand that the request wasn't processed and re-send it on a new connection. This fixes projectcontour#1493. Signed-off-by: James Peach <jpeach@vmware.com>
70e2937
to
a78acf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice. One small question about how this and the fallback cert interact.
@jpeach In my setup, I am changing the envoy https port from 443 to 8443. Its trying to match the host portal.example.com but its getting host as portal.example.com:8443. Here is curl output curl https://portal.devtest.example.com:8443/devtest -v
|
TLS routes are specialized to a unique virtual hostname. However, if
wildcard certificates are being used, browsers will aggressively coalesce
and reuse server connections even when the full origin hostname doesn't
match. This results on 404 responses because each TLS virtual host only
has routes for one host.
We can avoid this behaviour bleeding out to users by generating a 421
Misdirected Request response if the request authority doesn't match
the FQDN of the virtual host. In this case, the browser is supposed
to understand that the request wasn't processed and re-send it on a
new connection.
Signed-off-by: James Peach jpeach@vmware.com