Impact & Risk Analysis
- Severity: Medium
- CIS Benchmark: CIS 5.2.12
- Impact: Network Policy Bypass & Port Exhaustion. Host ports connect a container directly to a specific port on the host’s network interface. This traffic often bypasses the Kubernetes CNI overlay and NetworkPolicies, effectively exposing the service to the underlying network without standard controls. It also limits scheduling, as two pods asking for the same
hostPortcannot run on the same node (port conflict).
Common Misconfiguration
UsinghostPort to expose a service for testing or external access. This is an anti-pattern in Kubernetes; the correct way to expose applications is via Service objects (NodePort, LoadBalancer) or Ingress.
Vulnerable Example
Secure Example
Audit Procedure
List the policies in use for each namespace or scan running pods forhostPort usage.
Check Running Pods:
- Analyze: Look for any numeric output (e.g.,
80,8080). - Fail: If any user workload uses
hostPort.
Remediation
Add policies to each namespace in the cluster to restrict the admission of containers usinghostPort.
Using Pod Security Admission:
Apply the baseline or restricted profile to your namespaces. Both profiles generally forbid hostPort (unless explicitly exempted).

