Remove x-forwarded-client-cert header from request headers in proxy configurations#23544
Open
bharath-k1999 wants to merge 10 commits into
Open
Remove x-forwarded-client-cert header from request headers in proxy configurations#23544bharath-k1999 wants to merge 10 commits into
bharath-k1999 wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents inbound HTTP listeners from forwarding the x-forwarded-client-cert (XFCC) header to the local application by keeping it available for Envoy-side metadata processing and then stripping it before routing to local_app.
Changes:
- Enable
requestHeadersToRemove: ["x-forwarded-client-cert"]on generated inbound HTTP routes when XFCC parsing/forwarding is enabled. - Update xDS listener golden snapshots to reflect the new header removal behavior.
- Add unit + integration test coverage to verify XFCC is not observable by the upstream echo workload.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/integration/connect/envoy/helpers.bash | Improves extraction of JSON from curl -v output used by integration tests. |
| test/integration/connect/envoy/case-l7-intentions-request-normalization/verify.bats | Adds integration assertion that XFCC is stripped before reaching the echo backend. |
| test/integration/connect/envoy/case-l7-intentions-request-normalization-disabled/verify.bats | Adds the same XFCC stripping assertion with request normalization disabled. |
| agent/xds/listeners.go | Adds a new listener filter option and applies requestHeadersToRemove on the generated route. |
| agent/xds/listeners_test.go | Adds a focused unit test ensuring the route contains x-forwarded-client-cert in RequestHeadersToRemove when enabled. |
| agent/xds/testdata/listeners/http2-public-listener.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/http-public-listener.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/http-listener-with-timeouts.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/custom-trace-listener.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/connect-proxy-with-mesh-config-request-normalization-all-envoy-options-enabled.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/connect-proxy-with-mesh-config-request-normalization-all-consul-options.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/listeners/connect-proxy-with-http-max-request-headers.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/wasm-http-remote-file.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/wasm-http-local-file.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/tproxy-and-permissive-mtls-and-envoy-extension.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-remove-outlier-detection.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-patch-specific-upstream-service-splitter.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-patch-specific-upstream-service-failover.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-outbound-doesnt-apply-to-inbound.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-listener-outbound-add.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-listener-inbound-add.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-inbound-doesnt-apply-to-outbound.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-cluster-load-assignment-outbound-add.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-cluster-load-assignment-inbound-add.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-add-round-robin-lb-config.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-add-outlier-detection.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-add-outlier-detection-multiple.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/propertyoverride-add-keepalive.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/otel-access-logging-http.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-outbound-doesnt-apply-to-local-upstreams-with-envoy-constraint-violation.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-outbound-doesnt-apply-to-local-upstreams-with-consul-constraint-violation.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-outbound-doesnt-apply-to-inbound.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-outbound-applies-to-local-upstreams.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-outbound-applies-to-local-upstreams-tproxy.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-inbound-doesnt-apply-to-local-upstreams.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lua-inbound-applies-to-inbound.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/lambda-and-lua-connect-proxy.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/ext-authz-http-upstream-http-service.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/ext-authz-http-upstream-grpc-service.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/ext-authz-http-local-http-service.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| agent/xds/testdata/builtin_extension/listeners/ext-authz-http-local-grpc-service.latest.golden | Updates snapshot to include requestHeadersToRemove for XFCC. |
| .changelog/23544.txt | Adds a release note describing the inbound XFCC stripping behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # The first sed drops curl verbose lines that start with '*'. | ||
| # The second sed converts a trailing '}* <some text...>' fragment to just '}'. | ||
| local json=$(echo "$output" | sed '/^\*/d' | sed 's/}\*.*/}/' | sed -n -e '/^{$/,/^}$/{ p; }') | ||
| echo $json | jq -r '.' || echo "Output did not contain valid JSON: $output" >&3 |
Comment on lines
+2777
to
+2779
| if opts.stripForwardClientCertHeader { | ||
| route.RequestHeadersToRemove = append(route.RequestHeadersToRemove, "x-forwarded-client-cert") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Consul configures inbound public HTTP listeners to parse the
x-forwarded-client-certheader for internal service mesh metadata. Before this change, those listeners could forward the same header to the local service instance on the last hop.This change keeps the header available for Envoy metadata processing, then strips
x-forwarded-client-certfrom the request before forwarding it to the local application. That prevents downstream workloads from receiving client certificate details that Consul only needs for proxy-side processing.The change also updates the affected xDS listener snapshots and adds a focused unit test for the new header stripping behavior.
Testing & Reproduction steps
Reproduced the issue with mesh
sanitizeXForwardedClientCertdisabled and an unpatched Consul server image. Requests sent through the gateway reached the backend workload with anx-forwarded-client-certheader containing SPIFFE and certificate-chain details.Verified the workaround path by enabling mesh
sanitizeXForwardedClientCertand confirming the backend workload no longer received the header.Verified this fix independently of the workaround by running a patched Consul server image with mesh
sanitizeXForwardedClientCert=false, sending traffic through the gateway, and capturing the backend workload request headers. The captured request included expected proxy headers such asx-forwarded-protoandx-request-id, and did not includex-forwarded-client-cert.Ran the following tests:
Links
PR Checklist
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.