Skip to content

fix: added envoy_disable_xfcc_source_metadata flag to disable xfcc he… - #24044

Open
mrgupta7 wants to merge 3 commits into
mainfrom
mridul/xfcc-skip-metadata
Open

mrgupta7 wants to merge 3 commits into
mainfrom
mridul/xfcc-skip-metadata

Conversation

@mrgupta7

@mrgupta7 mrgupta7 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Add envoy_disable_xfcc_source_metadata to skip the XFCC metadata filter on sidecars

Why

On every request to an HTTP service, the sidecar's public listener runs the header_to_metadata filter. It applies five regexes to the whole x-forwarded-client-cert (XFCC) header (about 2 KB) to fill the consul.* source metadata (trust domain, partition, namespace, datacenter, service). In our profiling this filter was about 55% of sidecar CPU per request.

Turning off XFCC for the whole mesh (sanitizeXForwardedClientCert: true) is not an option for many setups. It breaks peered L7 intentions, ext_authz/Lua/Wasm/access logs that read consul.*, and XFCC forwarding from terminating gateways. This PR adds an opt-in switch that removes only the metadata filter, per sidecar.

What changed

  • agent/xds/config/config.go
    • New proxy config key envoy_disable_xfcc_source_metadata (default: unset, so no change in behaviour).
    • The key is decoded as a string and read through ProxyConfig.XFCCSourceMetadataDisabled() (strconv.ParseBool; anything it does not accept counts as off).
  • agent/xds/listeners.go (makeInboundListener)
    • parseXFCCToDynamicMetaHTTPFilter() is only called when the key is not set to true.
  • Tests
    • config_test.go: parsing cases (bool, string, junk) and a table test that a bad value never drops protocol.
    • resources_test.go: two golden cases, flag on and flag on with peer trust bundles (10 new files under agent/xds/testdata/).

Behaviour

When the key is true for an HTTP service:

  • The header_to_metadata filter is not added to the public listener.
  • XFCC is still built and forwarded (APPEND_FORWARD). RBAC for peered callers matches the header directly and is unaffected.
  • consul.* metadata is empty on that sidecar, so ext_authz, Lua, Wasm and %DYNAMIC_METADATA(consul:...)% access logs see no values. Do not set it on services that use them.

Where it can be set:

Scope How
Whole partition proxy-defaults Config (ProxyDefaults CRD spec.config)
One workload on Kubernetes pod annotation consul.hashicorp.com/proxy-config-map: '{"envoy_disable_xfcc_source_metadata": true}'
One service on VMs proxy { config { ... } } in the service registration

CSL-17779

@mrgupta7
mrgupta7 requested review from a team as code owners October 16, 2026 09:09
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Go Test Coverage: 60.5%

Patch coverage: 83.3% (10/12 changed lines covered)

See the workflow run for the full per-package breakdown and downloadable HTML report.

@codecov-commenter

codecov-commenter commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.77%. Comparing base (9a93eb6) to head (6e8d472).

Files with missing lines Patch % Lines
agent/xds/listeners.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24044      +/-   ##
==========================================
- Coverage   62.12%   56.77%   -5.35%     
==========================================
  Files        1068     1069       +1     
  Lines      129929   129997      +68     
==========================================
- Hits        80716    73808    -6908     
- Misses      41710    49345    +7635     
+ Partials     7503     6844     -659     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The peering regression case needs an actual peered intention to verify preservation of XFCC-based authorization.

1 open finding
What changed in this PR

Adds an opt-in sidecar setting to reduce XFCC metadata extraction overhead without changing default behavior.

Changes:

  • Adds configuration parsing and conditional metadata-filter insertion.
  • Adds parsing tests and resource goldens with and without peer trust bundles.
  • Documents usage, metadata limitations, and override behavior.
File Description
agent/​xds/​testdata/​secrets/​http-public-listener-disable-xfcc-source-metadata.latest.golden Records unchanged secrets.
agent/​xds/​testdata/​secrets/​http-public-listener-disable-xfcc-source-metadata-with-peer-trust-bundles.latest.golden Records secrets for peering case.
agent/​xds/​testdata/​routes/​http-public-listener-disable-xfcc-source-metadata.latest.golden Records route response.
agent/​xds/​testdata/​routes/​http-public-listener-disable-xfcc-source-metadata-with-peer-trust-bundles.latest.golden Records peering route response.
agent/​xds/​testdata/​listeners/​http-public-listener-disable-xfcc-source-metadata.latest.golden Shows metadata filter omitted.
agent/​xds/​testdata/​listeners/​http-public-listener-disable-xfcc-source-metadata-with-peer-trust-bundles.latest.golden Shows opt-out with peer trust bundles.
agent/​xds/​testdata/​endpoints/​http-public-listener-disable-xfcc-source-metadata.latest.golden Records unchanged endpoints.
agent/​xds/​testdata/​endpoints/​http-public-listener-disable-xfcc-source-metadata-with-peer-trust-bundles.latest.golden Records peering-case endpoints.
agent/​xds/​testdata/​clusters/​http-public-listener-disable-xfcc-source-metadata.latest.golden Records unchanged clusters.
agent/​xds/​testdata/​clusters/​http-public-listener-disable-xfcc-source-metadata-with-peer-trust-bundles.latest.golden Records peering-case clusters.
agent/​xds/​resources_test.go Adds two opt-out scenarios.
agent/​xds/​listeners.go Conditionally adds metadata filter.
agent/​xds/​config/​config.go Defines and interprets the option.
agent/​xds/​config/​config_test.go Tests parsing and protocol preservation.
.changelog/​24044.txt Documents option and caveats.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread agent/xds/resources_test.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped opt-in change preserves default behavior and peered authorization, with supporting regression coverage and no unresolved blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped opt-in preserves defaults and XFCC-based authorization, with focused regression coverage and no unresolved blocking issues.

No open issues 🎉

Review effort: Balanced

@mrgupta7
mrgupta7 force-pushed the mridul/xfcc-skip-metadata branch from f2106e3 to 6e8d472 Compare October 27, 2026 09:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants