-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
During a PR review, Gemini raised a comment about a potential bug in the xDS RBAC implementation: #8908 (comment)
The remoteIPMatcher gets the peer address from the peer.Peer set by the transport:
func (sim *remoteIPMatcher) match(data *rpcData) bool {
ip, _ := netip.ParseAddr(data.peerInfo.Addr.String())
return sim.ipNet.Contains(net.IP(ip.AsSlice()))
return sim.ipNet.Contains(ip)
}All the non-test usages get the peerInfo.Addr field from the net.Conn. In most cases, this should contain the port. This means that netip.ParseAddr will fail and we need to use netip.ParseAddrPort instead. All the RBAC tests set the peer address to an IP address without a port, example
grpc-go/internal/xds/rbac/rbac_engine_test.go
Line 730 in c1a9239
| Addr: &addr{ipAddress: "0.0.0.0"}, |
There doesn't seem to be any code that ensures the addresses stores in the rpcData always have the port stripped. This seems like a bug due to which address matching would always fail in the real world.