Skip to content

xds/rbac: IP address matching doesn't handle ports #8913

@arjan-bal

Description

@arjan-bal

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

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.

Metadata

Metadata

Assignees

Labels

Area: xDSIncludes everything xDS related, including LB policies used with xDS.P1Type: Bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions