Commit d230e3c
fix(controller): honor ReferenceGrantTo.Name in cross-namespace validation
Per Gateway API spec, `ReferenceGrantTo.Name` is optional. When set, the grant
must apply only to that named target; when unset, it acts as a wildcard for
the group/kind. The controller was ignoring the field entirely, so a
name-scoped grant like
to:
- group: aigateway.envoyproxy.io
kind: AIServiceBackend
name: safe-backend
silently allowed AIGatewayRoutes to reference *any* AIServiceBackend of that
group/kind in the target namespace — not what the grant author meant. In
practice this widens cross-namespace permission surface beyond what the
policy declared.
Thread `targetName` through validateReference → isReferenceGrantValid →
matchesTo so the name comparison happens at the leaf. Wildcard behaviour
(name unset) is preserved.
Regression test added covering all three cases: name-unset wildcard,
name-matches (allowed), name-mismatch (denied).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent d10579c commit d230e3c
2 files changed
Lines changed: 56 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | | - | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
163 | | - | |
164 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
165 | 179 | | |
166 | 180 | | |
167 | 181 | | |
168 | | - | |
169 | | - | |
170 | 182 | | |
171 | 183 | | |
172 | 184 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
179 | 189 | | |
180 | 190 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
445 | 475 | | |
446 | 476 | | |
447 | 477 | | |
| |||
456 | 486 | | |
457 | 487 | | |
458 | 488 | | |
459 | | - | |
| 489 | + | |
460 | 490 | | |
461 | 491 | | |
462 | 492 | | |
| |||
474 | 504 | | |
475 | 505 | | |
476 | 506 | | |
477 | | - | |
| 507 | + | |
478 | 508 | | |
479 | 509 | | |
480 | 510 | | |
| |||
0 commit comments