Skip to main content

More Info:

Sharing the host IPC namespace allows a container to access shared memory of other processes on the node. Enforce policies that restrict admission of hostIPC containers.

Risk Level

High

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. List existing pods using hostIPC in all namespaces
    • Run on: any machine with kubectl access
    • Command:
    • Review which workloads currently require hostIPC: true, and document the business/technical justification for each.
  2. Inspect pod specs that use hostIPC to understand why it is needed
    • Run on: any machine with kubectl access
    • For each namespace with hostIPC: true pods:
    • Decide case-by-case whether the host IPC access is strictly required or can be removed/alternative design used.
  3. Review existing admission controls (e.g. Pod Security Standards / policies) per namespace
    • Run on: any machine with kubectl access
    • If using built-in Pod Security admission labels:
    • If using Gatekeeper/Kyverno or another policy engine, list policies and identify those that constrain spec.hostIPC:
    • Determine which namespaces hosting user workloads currently lack any policy preventing hostIPC: true.
  4. Decide and design namespace-level policy to minimize hostIPC
    • For each user-workload namespace, decide:
      • Should hostIPC be completely forbidden?
      • Are there exceptional workloads that must be allowed, and how will they be identified (labels, dedicated namespace, etc.)?
    • Based on your admission controller (Pod Security, Gatekeeper, Kyverno, etc.), design or select a policy that:
      • Denies pods with spec.hostIPC: true in general user namespaces.
      • Optionally allows only explicitly approved workloads/namespaces.
  5. Apply or adjust the policy manifests for each user-workload namespace
    • Run on: any machine with kubectl access
    • Apply your chosen policy manifests using kubectl apply -f <file>.yaml (content depends on your chosen policy engine and your decision in step 4).
    • For namespaces that must permit hostIPC for specific workloads, document and implement a controlled exception mechanism (e.g., dedicated namespace with stricter access control).
  6. Re-verify that hostIPC usage is minimized and new admission is restricted
    • Run on: any machine with kubectl access
    • Confirm no unintended pods use hostIPC:
    • Attempt (in a test namespace) to create a pod with hostIPC: true and confirm it is rejected by the policy, adjusting the policy if necessary.

Using kubectl

Run all commands from any machine with kubectl access.

1. Discover current PodSecurity admission level per namespace

These labels indicate if baseline/restricted Pod Security is enforced, which can block hostIPC: true.
Potential problem:
  • Namespaces that run user workloads and either:
    • Have no pod-security.kubernetes.io/* labels, or
    • Are labeled with privileged or have only warn/audit levels, not enforce, may allow hostIPC: true pods.
Focus on namespaces like default, app-specific namespaces, and any non-system namespaces.

2. List existing pods/containers using hostIPC

Any output indicates pods that are sharing the host IPC namespace and should be reviewed.To inspect one of them:
Look for:
Problem indication:
  • Any workload pod (not a deliberately privileged/system tool) with hostIPC: true is a potential security concern.

3. Check workloads that could create hostIPC pods

Deployments:
DaemonSets:
StatefulSets:
Problem indication:
  • Any controller spec containing hostIPC: true will continuously create pods with host IPC enabled unless changed.

4. Find admission policies that address hostIPC (if using Kyverno/OPA/Gatekeeper, etc.)

Kyverno ClusterPolicies:
If present, inspect for hostIPC rules:
Gatekeeper constraints (if installed):
Problem indication:
  • No admission policies referencing hostIPC in namespaces with user workloads means there is no explicit control preventing hostIPC: true pods.

5. Verification after any policy decisions

After you adjust labels/policies manually, verify again:
Any remaining hostIPC: true workloads should be individually reviewed to decide if they are truly necessary and appropriately isolated.
How to interpret the output
  • The first table lists all pods that currently have hostIPC: true.
    • Any entry here is a potential problem that must be explicitly justified as an exception.
  • The “Namespaces that contain pods with hostIPC: true” list shows where you must ensure admission policies (e.g., Pod Security, PSP replacements, or validating admission policies) are configured to control or forbid hostIPC.
  • The detailed spec section helps you review:
    • Which service accounts and applications are using host IPC.
    • Whether usage aligns with an approved exception.
  • The namespace labels section helps you see if Pod Security (or equivalent) is configured strongly enough; namespaces with permissive labels while also having hostIPC: true pods are higher-risk and should be reviewed closely.
This script only reports; you must decide case by case whether each hostIPC: true pod is acceptable and then adjust admission policies and workload manifests accordingly.