Enforce ReferenceGrant on cross-namespace Gateway API backendRefs#119
Merged
Conversation
85f1a53 to
b60d9cd
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.
Summary
Cross-namespace
backendRefson a Gateway APIHTTPRoutewere honoured unconditionally, letting any route author route traffic to anyServicecluster-wide, without the target namespace's consent. This is non-conformant with the Gateway API spec and a privilege-escalation hole.This change makes a cross-namespace
backendRefrequire aReferenceGrantin the target (Service) namespace that trusts the route's namespace. Without one, the backend is dropped (logged, and reflected asResolvedRefs=False) instead of being routed. Same-namespace references are unaffected and never consult the grant set.What changed
ReferenceGrantwatcher (4th Gateway API watcher), tracking authorised(from_ns, to_ns)pairs in the sharedGatewayScope. A grant appearing/disappearing re-resolves affected routes immediately via the existingchangednotifier.BackendRefAuthorizertrait gates cross-namespace resolution inrule_to_entrypoints; the scope implements it (fail-closed on a poisoned lock).HTTPRoute -> Servicegrants count; a grant targeting another kind (e.g.Secret) does not authorise a backendRef.referencegrantsread verb (docs + e2e deploy manifest).Tests
Secretgrant does not authorise aServiceref.02-gateway.sh): cross-namespace backend refused without a grant (404), served once a grant authorises it (200), refused again after the grant is deleted (404). Verified end-to-end on kind against a local image build: 26 passed, 0 failed.cargo fmt --checkclean,clippyclean.Docs
New "Cross-namespace backends (ReferenceGrant)" section in the Kubernetes provider docs, RBAC updated, and the "not implemented" lists corrected (
ReferenceGrantremoved; the stale claim thatGateway/GatewayClasswere unimplemented fixed).