# GHSA-XGQ4-8Q3R-4GR4: ReferenceGrant checks ignore to.name, and revoked grants can keep authorizing access

- Database: GitHub
- Severity: CVSS 6.4 (Medium)
- Published: 2026-10-07
- Modified: 2026-10-07

## Affected versions

- github.com/envoyproxy/ai-gateway (Go): from 0.4.0, through 1.1.0

## Description

### Summary
The controller's ReferenceGrant check (referenceGrantValidator in internal/controller/referencegrant.go) ignores the optional `to.name` field. In Gateway API, `name` limits a grant to that one object. Here, a grant for one object authorizes every object of that kind in the namespace.

### Affected
- Released, v0.4.0 through v1.1.0: AIGatewayRoute → AIServiceBackend cross-namespace backendRefs. A route in namespace A that is granted backend `x` in namespace B can reference any AIServiceBackend in B. Its traffic then goes through that backend with that backend's BackendSecurityPolicy credential.
- main, unreleased (#2746): BackendSecurityPolicy → Secret references (AzureCredentials.clientSecretRef, GCPCredentials.credentialsFile, OIDC client secrets).
- I've opened #2783 for #2778, which adds the same check to the static credential types (APIKey, AzureAPIKey, AnthropicAPIKey, AWS credentialsFile). Those Secret values are sent as-is to an upstream the policy owner configures. With `to.name` ignored, a grant for one Secret would let that owner send any Secret in the namespace with an `apiKey` or `credentials` key to a host they control. I've kept this out of the public PR. Please fix `to.name` before or together with it.

### Reproduction
Namespace `shared` has Secrets `granted` and `other`, and a ReferenceGrant from BackendSecurityPolicy in namespace `app` to Secret with `name: granted`. On main, `validateSecretReference(ctx, "app", "shared", "other")` returns nil. It should return the "not permitted" error.

### Suggested fix
Pass the target name from `validateReference` into `isReferenceGrantValid`/`matchesTo`, and match only when `to.Name == nil || string(*to.Name) == targetName`. No existing test or YAML fixture sets `to.name`.

### Related revocation gaps
1. On main: a ReferenceGrant that is being deleted still validates; `isReferenceGrantValid` doesn't check `DeletionTimestamp`. The ReferenceGrant finalizer added in #2750 triggers downstream reconciles before it is removed (`handleFinalizer`, controller.go), so those reconciles can still see the grant. Once the grant is gone nothing reconciles again, so the old access can stay in the generated config. If the finalizer removal fails, the error is only logged and the grant stays valid.
2. Narrowing a grant (editing or removing a `from` entry) only requeues the objects that match the new spec (`getAffectedAIGatewayRoutes` / `getAffectedBackendSecurityPolicies`). Objects that lost access keep it until something else reconciles them.
3. BackendSecurityPolicy changes for InferencePool targets never reach the Gateway: `syncInferencePool` doesn't notify Gateways. So a revoked grant, or a rotated Secret, isn't applied to the filter config for those backends.

## References

- https://github.com/theagentrouter/agent-router/security/advisories/GHSA-xgq4-8q3r-4gr4

Page: https://cve.now/GHSA-XGQ4-8Q3R-4GR4

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
