Skip to content
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/envoy: Set XffNumTrustedHops to keep header proto intact #3293

Merged
merged 3 commits into from Feb 3, 2021

Conversation

stevesloka
Copy link
Member

@stevesloka stevesloka commented Jan 30, 2021

If a user has an external load balancer that terminates TLS, the X-Forwarded-Proto
header gets overwritten unless the downstream connection is trusted.

This adds a config file option to set the number of trusted hops which will
allow the headers to be instact already set from downstream.

Fixes #3294

Signed-off-by: Steve Sloka slokas@vmware.com

@stevesloka stevesloka requested a review from a team as a code owner January 30, 2021 03:30
@stevesloka stevesloka requested review from jpeach and youngnick and removed request for a team January 30, 2021 03:30
@stevesloka
Copy link
Member Author

This still needs docs & feature tests.

@@ -86,7 +86,7 @@ default-http-versions: []
cluster:
dns-lookup-family: auto
`
assert.Equal(t, strings.TrimSpace(string(data)), strings.TrimSpace(expected))
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(data)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging tests I noticed this was swapped.

@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #3293 (cd6a711) into main (2b62330) will increase coverage by 0.06%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3293      +/-   ##
==========================================
+ Coverage   75.36%   75.43%   +0.06%     
==========================================
  Files          98       98              
  Lines        6154     6162       +8     
==========================================
+ Hits         4638     4648      +10     
+ Misses       1411     1409       -2     
  Partials      105      105              
Impacted Files Coverage Δ
cmd/contour/serve.go 0.00% <0.00%> (ø)
internal/envoy/v3/listener.go 97.50% <100.00%> (+0.03%) ⬆️
internal/featuretests/v3/envoy.go 100.00% <100.00%> (ø)
internal/xdscache/v3/listener.go 95.28% <100.00%> (+0.07%) ⬆️
internal/k8s/log.go 69.56% <0.00%> (+6.52%) ⬆️

Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@youngnick youngnick modified the milestones: 1.12.0, 1.13.0 Feb 1, 2021
Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending an addition I’m guessing you’re going to add here https://github.com/projectcontour/contour/blob/main/site/docs/main/configuration.md

@stevesloka
Copy link
Member Author

@sunjayBhatia yup added docs and a feature test to cover.

If a user has an external load balancer that terminates TLS, the X-Forwarded-Proto
header gets overwritten unless the downstream connection is trusted.

This adds a config file option to set the number of trusted hops which will
allow the headers to be instact already set from downstream.

Fixes projectcontour#3294

Signed-off-by: Steve Sloka <slokas@vmware.com>
Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a tiny discussion starter comment

@@ -106,6 +107,16 @@ The cluster configuration block can be used to configure various parameters for
{: class="table thead-dark table-bordered"}
<br>

### Network Configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any issues we can earmark so we make sure to add configuration to this object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue linked for the max hops, are you referring to the Network Configuration section?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just wondering if we already had other things to add in the network hash we already know about

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah at the moment not sure, things that the chunked length maybe should have gone into there. We can remove the network parent, but was trying to group stuff together in a way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having the network top-level item is great, we should definitely keep that, and look out for things to put in there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@stevesloka stevesloka added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 3, 2021
@stevesloka stevesloka merged commit b49ccc0 into projectcontour:main Feb 3, 2021
@stevesloka stevesloka deleted the numTrustedHops branch February 3, 2021 12:48
@skriss skriss added this to In progress in Contour Project Board via automation Feb 3, 2021
@skriss skriss moved this from In progress to 1.13 Release in Contour Project Board Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x-forwarded-proto header overwritten from trusted downstream
3 participants