agent/xds: allow trailing semicolon-separated fields in XFCC rbac principal - #23920
Merged
Merged
Conversation
Contributor
Go Test Coverage: 63.1%See the workflow run for the full per-package breakdown and downloadable HTML report. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23920 +/- ##
==========================================
+ Coverage 58.87% 58.88% +0.01%
==========================================
Files 973 973
Lines 120951 120951
==========================================
+ Hits 71205 71223 +18
+ Misses 43138 43117 -21
- Partials 6608 6611 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nitin-sachdev-29
enabled auto-merge (squash)
September 11, 2026 09:58
…ncipal When PR #23647 introduced automatic DNS SAN registration for API Gateway leaf certificates, Envoy began appending ';DNS=<san>' after ';URI=<uri>' in the 'x-forwarded-client-cert' (XFCC) header. The previous regex anchored ';URI=' directly to either a comma or end-of-string: ^[^,]+;URI=<pattern>(?:,.*)?$ This caused RBAC intention evaluation to reject valid cross-cluster/peered API Gateway traffic with 403 Forbidden. This commit relaxes the pattern to allow any trailing semicolon-separated fields (such as ;DNS=... or ;Subject=...) in the first XFCC hop before any subsequent hops or end-of-string: ^[^,]+;URI=<pattern>(?:;[^,]*)?(?:,.*)?$
Address review feedback by simplifying the trailing separator matching to (?:[;,].*)?$. This handles any combination of semicolon-delimited fields (e.g. ;DNS=..., ;Subject=...) in the first XFCC component as well as comma-separated multi-hop chains.
nitin-sachdev-29
force-pushed
the
nitin/fix-peering-gateway-xfcc-rbac
branch
from
September 11, 2026 10:29
b52df3b to
cf700e2
Compare
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
Fixes an authorization failure (
HTTP 403 Forbidden/RBAC: access denied) when an API Gateway proxies cross-cluster or peered traffic to services with service intentions.Root Cause
PR #23647 introduced automatic DNS SAN registration (
DNS:*.api-gateway.consul, etc.) into API Gateway leaf certificates. When an API Gateway establishes an mTLS connection across a cluster peering (via mesh gateway or direct peer resolver), Envoy populates thex-forwarded-client-cert(XFCC) header with the client certificate details:In
agent/xds/rbac.go:xfccPrincipal, the Envoy RBAC regex pattern used to validate the caller's SPIFFE ID in the first XFCC hop was:This regex assumed that
;URI=<idPattern>is either immediately followed by a comma (for subsequent hops) or ends the string. Because PR #23647 added;DNS=...fields immediately following;URI=..., the regex failed to match. Consequently, the destination service proxy's Envoy RBAC filter denied incoming requests withrbac_access_denied_matched_policy[none].Solution
Relax the pattern in
agent/xds/rbac.goto permit subsequent semicolon-separated key-value fields (such as;DNS=...or;Subject=...) in the first XFCC component before comma-separated subsequent hops or end-of-string:Testing & Reproduction steps
1. Unit Tests
TestXFCCPrincipalinagent/xds/rbac_test.goasserting regex matching behavior across:gateway2matchinggateway), mismatched service identities, and identities appearing only in subsequent hops are rejected.agent/xds/testdata/rbac/default-deny-peered-kitchen-sink--httpfilter.golden.2. Acceptance Test Reproduction & Verification
kind-dc1,kind-dc2) and ranTestPeering_Gatewaywith an unfixed build. Reproduced the exact failure:HTTP/1.1 200 OK("hello world"). Ran the full end-to-endTestPeering_Gatewaytest suite from scratch on fresh clusters: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.