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

[v1.14] Author backport of #32200 #32265

Merged

Conversation

mhofstetter
Copy link
Member

@mhofstetter mhofstetter commented Apr 30, 2024

Currently, when L7 policies (egress or ingress) are enforced for traffic between Pods, Envoy might change x-forwarded-for related headers because the corresponding Envoy listeners don't trust the downstream headers because XffNumTrustedHops is set to 0.

e.g. x-forwarded-proto header:

Downstream x-forwarded-proto headers will only be trusted if xff_num_trusted_hops is non-zero. If xff_num_trusted_hops is zero, downstream x-forwarded-proto headers and :scheme headers will be set to http or https based on if the downstream connection is TLS or not.

https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-proto

This might be problematic if L7 policies are used for egress traffic for Pods from a non-Cilium ingress controller (e.g. nginx). If the Ingress Controller is terminating TLS traffic and forwards the protocol via x-forwarded-proto=https, Cilium Envoy Proxy changes this header to x-forwarded-proto=http (if no tls termination itself is used in the policy configuration).

This breaks applications that depend on the forwarded protocol.

Therefore, this commit introduces two new config flags proxy-xff-num-trusted-hops-ingress and proxy-xff-num-trusted-hops-egresss that configures the property XffNumTrustedHops on the respective L7 policy Envoy listeners.

For backwards compabitility and security reasons, the values still default to 0.

Note: It's also possible to configure these values via Helm (envoy.xffNumTrustedHopsL7PolicyIngress & envoy.xffNumTrustedHopsL7PolicyEgress).

Author Backport of #32200 (Config properties not yet in Hive Cell on v1.14)

Once this PR is merged, a GitHub action will update the labels of these PRs:

 32200

[ upstream commit 1bc2c75 ]

Currently, when L7 policies (egress or ingress) are enforced for traffic
between Pods, Envoy might change x-forwarded-for related headers because the corresponding
Envoy listeners don't trust the downstream headers because `XffNumTrustedHops`
is set to `0`.

e.g. `x-forwarded-proto` header:

> Downstream x-forwarded-proto headers will only be trusted if xff_num_trusted_hops is non-zero. If xff_num_trusted_hops is zero, downstream x-forwarded-proto headers and :scheme headers will be set to http or https based on if the downstream connection is TLS or not.

https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-proto

This might be problematic if L7 policies are used for egress traffic for Pods from
a non-Cilium ingress controller (e.g. nginx). If the Ingress Controller is terminating TLS
traffic and forwards the protocol via `x-forwarded-proto=https`, Cilium Envoy Proxy changes
this header to `x-forwarded-proto=http` (if no tls termination itself is used in the policy configuration).

This breaks applications that depend on the forwarded protocol.

Therefore, this commit introduces two new config flags `proxy-xff-num-trusted-hops-ingress` and
`proxy-xff-num-trusted-hops-egresss` that configures the property `XffNumTrustedHops` on the respective
L7 policy Envoy listeners.

For backwards compabitility and security reasons, the values still default to `0`.

Note: It's also possible to configure these values via Helm (`envoy.xffNumTrustedHopsL7PolicyIngress` &
`envoy.xffNumTrustedHopsL7PolicyEgress`).

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
@maintainer-s-little-helper maintainer-s-little-helper bot added backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. labels Apr 30, 2024
@mhofstetter mhofstetter marked this pull request as ready for review April 30, 2024 14:29
@mhofstetter mhofstetter requested a review from a team as a code owner April 30, 2024 14:29
@mhofstetter
Copy link
Member Author

/test-backport-1.14

Copy link
Member

@jrajahalme jrajahalme left a comment

Choose a reason for hiding this comment

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

LGTM

@joestringer
Copy link
Member

Heads up @mhofstetter if you have a section with ```upstream-prs ... in your PR description for a backport, then there is no need to manually add a release note. The release tooling will pick up the release note from the parent PR.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 1, 2024
@youngnick youngnick merged commit e679ac5 into cilium:v1.14 May 1, 2024
62 checks passed
@mhofstetter mhofstetter deleted the pr/mhofstetter/proxy-xff-hops-1.14 branch May 1, 2024 15:33
@mhofstetter
Copy link
Member Author

Heads up @mhofstetter if you have a section with ```upstream-prs ... in your PR description for a backport, then there is no need to manually add a release note. The release tooling will pick up the release note from the parent PR.

👍 Good to know - thanks Joe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
No open projects
Status: Released
Development

Successfully merging this pull request may close these issues.

4 participants