Kubernetes PodSecurityPolicy permits host IPC sharing

Block unnecessary sharing of the host IPC namespace through admission policy.

Description

In a legacy Terraform PSP, host_ipc = true permits a Pod to request the node’s IPC namespace. A Pod that shares it can see host IPC resources such as shared memory and message queues.

Potential impact

IPC object permissions can allow a workload to read or change data used by other processes.

Remediation

Set host_ipc = false in the PSP’s spec. Isolate workloads that require host IPC with dedicated policies and nodes, and restrict object permissions. Review other policies that allow hostPID, hostNetwork or privileged mode.

Examples

The excerpts omit other required policy fields. Kubernetes deprecated PSP in 1.21 and removed it in 1.25. On current clusters, enforce the restriction with Pod Security Admission or a policy engine and verify that a new Pod requesting host IPC is rejected.

Before

hcl
resource "kubernetes_pod_security_policy" "policy" {
  metadata {
    name = "terraform-example"
  }

  spec {
    host_ipc = true
  }
}

After

hcl
resource "kubernetes_pod_security_policy" "policy" {
  metadata {
    name = "terraform-example"
  }

  spec {
    host_ipc = false
  }
}

References