Check provider logo

Pod does not use HostPorts

core_minimize_admission_hostport_containers

Severityhigh
Servicecore
by Prowler

Kubernetes Pods are inspected for any container declaring ports[].hostPort. The finding highlights workloads that bind container ports directly to the node's network stack via HostPorts.

Risk

Using HostPorts exposes Pods on node IPs outside centralized Service/Ingress controls. Attackers can directly probe and access workloads (confidentiality/integrity). Port conflicts or saturation on nodes can disrupt traffic (availability). Network segmentation and some policies may be less effective.

Run this check with Prowler CLI

prowler kubernetes --checks core_minimize_admission_hostport_containers

Recommendation

Avoid hostPort; publish services via ClusterIP with Ingress/LoadBalancer. Enforce admission policies to deny hostPort by default, permitting only a narrowly justified allowlist. Apply least privilege network rules, segment nodes, and monitor for unexpected host port bindings as defense in depth.

Remediation

Terraform
Other
  1. Open your Kubernetes Dashboard and go to Workloads
  2. Select the affected Deployment/DaemonSet/StatefulSet (or Pod) and click Edit
  3. In the YAML, remove every hostPort field under spec.template.spec.containers[].ports[] (or spec.containers[] for a standalone Pod)
  4. Save the changes; allow the workload to restart
  5. Verify the new Pods have no hostPort defined

Source Code

Resource Type

Pod

References