The vulnerability exists because kube-router's proxy and routing modules blindly trust Service.spec.externalIPs and Service.status.loadBalancer.ingress IPs from the Kubernetes API. An attacker with namespace-scoped permissions to create or update Services can specify arbitrary IPs, leading to traffic hijacking or denial of service against critical components like kube-dns.
The analysis of the patch commit a1f0b2eea3ee0f66b9a5b5c49dcb714619ccd456 identifies three key vulnerable functions where this lack of validation occurs:
-
proxy.NetworkServicesController.buildServicesInfo: This function is the primary entry point for the service proxy. It reads Service objects and prepares them for IPVS programming. The patch demonstrates that it previously copied IPs without any checks. The fix involves adding calls to a new IP validator. Exploiting this allows an attacker to bind a malicious service to any IP within the cluster, redirecting traffic.
-
routing.NetworkRoutingController.getExternalIPs: This function in the routing controller retrieves externalIPs to be advertised via BGP. The patch shows it was also missing validation. This could be exploited to advertise malicious routes to the external network.
-
routing.NetworkRoutingController.getLoadBalancerIPs: Similarly, this function retrieves loadBalancerIPs for BGP advertisement without validation, creating another vector for advertising malicious routes.
The root cause was the failure to enforce the --service-external-ip-range and --loadbalancer-ip-range configurations in the controllers that handle these IPs. The patch addresses this by introducing a centralized IP validator in a new pkg/svcip package and applying it at all points where service IPs are processed, effectively closing the security gap in both the in-cluster proxy and the external routing logic.