Workload exposure through an Ingress controller

Ingress can create an unintended public route when it exposes a workload intended for internal use.

Description

Ingress routes HTTP and HTTPS requests to a Service. Check the controller and load balancer to see who can reach an internal Service.

Potential impact

A public host or path can route external requests to an internal service or administration endpoint.

Remediation

Remove public routes to internal services or move them to an internal controller. For public routes, configure authentication, access controls, TLS and any required rate limits. Test reachability from outside the cluster.

Examples

Kubernetes stopped serving extensions/v1beta1 Ingress in 1.22. Use networking.k8s.io/v1 for new manifests.

Before

yaml
apiVersion: v1
kind: Service
metadata:
  name: app
spec:
  type: ClusterIP
  ports:
    - port: 3000
      targetPort: 3000
  selector:
    app: app
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: app-ingress
spec:
  rules:
    - host: app.acme.org
      http:
        paths:
          - backend:
              serviceName: app
              servicePort: 3000

After

yaml
apiVersion: v1
kind: Service
metadata:
  name: app
spec:
  type: ClusterIP
  ports:
    - port: 3000
      targetPort: 3000
  selector:
    app: app

Applying the ClusterIP Service alone leaves any existing app-ingress in place. Remove that Ingress and check for other public routes.

References