More Info:
hostPID=true allows a container to view and signal every process on the node, providing trivial paths to escape isolation. Reject pods with hostPID by default in admission policy.Risk Level
HighAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
In OKE this setting comes from the Kubernetes pod spec (
2. Remove
For each offending controller (Deployment/DaemonSet/Job/etc.):
3. (Optional but recommended) Enforce a policy so
OKE doesn’t offer a direct “disallow hostPID” switch in the console, but you can enforce it using Kubernetes’ built‑in Pod Security Admission (for clusters on recent Kubernetes versions):
Summary of what you must do in OCI Console–driven flow
hostPID: true). There is no single “toggle” in the OCI Console; you remediate by (1) finding the offending workloads and (2) redeploying them without hostPID, and optionally (3) enforcing a policy so it can’t be re‑introduced.Below are the steps, keeping everything driven from the OCI Console as much as possible.1. Identify pods using the host PID namespace
- Sign in to the OCI Console.
- Go to Developer Services → Kubernetes Clusters (OKE).
- Select the Compartment, then click your Cluster.
- In the cluster details page, in the left menu, choose Workloads (if available in your console region/version):
- Look at the Pod YAML (or the parent Deployment/DaemonSet/StatefulSet YAML) for suspicious workloads.
- Check each pod’s spec for:
- If you don’t see it clearly in the GUI, use Cloud Shell from the console:
- Click the Cloud Shell icon (top‑right).
- Configure
kubectlfor your cluster by clicking Access Cluster in the cluster details page and following the on‑screen instructions to download and use the kubeconfig in Cloud Shell. - Then in Cloud Shell run:
- This lists all pods with
hostPID: true.
2. Remove hostPID: true and redeploy
For each offending controller (Deployment/DaemonSet/Job/etc.):-
In the OCI Console → OKE → your cluster → Workloads:
- Locate the workload (Deployment/DaemonSet/Job) generating the pod.
- Use View YAML to see its manifest.
-
Open Cloud Shell again (from the OCI Console) and edit the manifest via
kubectl:- Export the existing manifest:
- Edit the file in Cloud Shell (e.g., using
vi):- Find any line:
and either remove it (default is
false) or explicitly set:
- Find any line:
- Apply the updated manifest:
- Export the existing manifest:
-
For controllers you created via Helm or another CI/CD pipeline, update the source (Helm chart values or Git repo) to:
- Remove/disable
hostPID: truein their templates or values. - Redeploy from that system to avoid it being re‑introduced.
- Remove/disable
-
Verify that no pods in the cluster now use the host PID namespace:
If this returns nothing, the configuration issue is remediated.
3. (Optional but recommended) Enforce a policy so hostPID can’t be used
OKE doesn’t offer a direct “disallow hostPID” switch in the console, but you can enforce it using Kubernetes’ built‑in Pod Security Admission (for clusters on recent Kubernetes versions):-
In Cloud Shell, label namespaces with a strict Pod Security level that disallows host namespaces (e.g.,
restricted):Therestrictedprofile prohibits host namespace sharing (includinghostPID). -
For system namespaces (like
kube-system) you may need less strict policies; focus on your application namespaces. -
Test by trying to deploy a pod with
hostPID: truein that namespace—it should now be rejected by the API server.
Summary of what you must do in OCI Console–driven flow
- Use OKE cluster page + Cloud Shell to:
- Discover pods with
hostPID: true. - Edit and re‑apply their controller manifests to remove
hostPID. - Optionally label namespaces with
pod-security.kubernetes.io/enforce=restrictedso futurehostPIDusage is blocked.
- Discover pods with
kubectl commands and sample manifests aligned to that version.Using CLI
Using CLI
To remediate “Containers sharing the host PID namespace” in OCI OKE, you need to ensure
2. Find Pods/Workloads using
Check current Pods:Check higher‑level objects (Deployments, DaemonSets, StatefulSets, etc.) that might be creating such Pods:(Assumes
3. Remove / disable
For each workload identified:Similar for other kinds:You can drive this fully from OCI CLI by first generating kubeconfig (step 1) and then running these
This can also be done after kubeconfig creation from OCI CLI.
No output means no Pods are using
hostPID: false (or absent) in all Pod specs. Using OCI CLI, the flow is:1. Configure kubectl access via OCI CLI
If you don’t already have kubeconfig for the cluster:2. Find Pods/Workloads using hostPID: true
Check current Pods:yq is installed; if not, you can inspect YAML manually.)3. Remove / disable hostPID in the workload specs
For each workload identified:Option A: Patch with kubectl (fastest)
SethostPID: false on the Pod template:kubectl commands in the same shell.Option B: Edit manifests and re‑apply
If you manage manifests/Helm charts in Git:-
In each Pod template, ensure:
-
Re‑deploy:
4. Optionally enforce at policy level (prevent future drift)
OKE uses upstream Kubernetes; you can use Pod Security Admission (recommended) or Gatekeeper/OPA. Example (Kubernetes v1.25+ with Pod Security Admission):Create a namespace label to enforcerestricted (which disallows hostPID):5. Verify remediation
Re‑run the check:hostPID: true.Using Python
Using Python
In OKE this risk comes from pods that set
2. Python: Identify all resources using
This script scans common workload types (Pods, Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs, CronJobs) in all namespaces and prints where Run this to see all offenders.
3. Python: Remediate by patching
You should ideally fix the original manifests in Git/Helm first. But if you need to remediate live workloads via script, you can patch them like this.Below is an example for Deployments and StatefulSets (you can extend to other controllers similarly):You can add similar blocks for:
4. Prevent new
For long‑term remediation, you should block
hostPID: true in the pod spec. You remediate by finding all such workloads and patching them to hostPID: false (or removing the field), then enforcing a policy to prevent new ones.Below are step‑by‑step instructions and Python examples using the Kubernetes Python client against your OKE cluster.1. Prereqs
-
Install tools:
-
Make sure your
kubectlis already configured for the OKE cluster (e.g. via OCI Console “Access Cluster” instructions).
The Python client will reuse that kubeconfig. -
Verify:
2. Python: Identify all resources using hostPID: true
This script scans common workload types (Pods, Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs, CronJobs) in all namespaces and prints where hostPID is enabled.3. Python: Remediate by patching hostPID to false
You should ideally fix the original manifests in Git/Helm first. But if you need to remediate live workloads via script, you can patch them like this.Below is an example for Deployments and StatefulSets (you can extend to other controllers similarly):apps_v1.patch_namespaced_daemon_setapps_v1.patch_namespaced_replica_setbatch_v1.patch_namespaced_jobbatch_v1.patch_namespaced_cron_job- Or patch individual Pods (not usually needed if controlled by a higher-level resource).
4. Prevent new hostPID usage (policy)
For long‑term remediation, you should block hostPID: true at admission time:- If using Gatekeeper / OPA (or Kyverno), add a policy that denies any pod with
spec.hostPID: true. - Or use Kubernetes Pod Security Admission (PSA) with at least
baseline/restrictedprofiles (which disallow host namespaces).
- Enable Pod Security Admission in the cluster (if supported by your OKE/K8s version).
-
Set the namespace label, e.g.:
hostPID.5. Validate
After the script and/or policy:- Re-run the scanning script — it should find no
hostPID: true. - Try to deploy a test pod with
hostPID: true; it should be rejected by policy (if configured).
Using Terraform
Using Terraform
This setting cannot be configured on the
oci_containerengine_cluster (OKE cluster) resource in Terraform; OKE does not expose admission policy / hostPID controls at the cluster resource level.Rejecting pods with hostPID: true must be done via Kubernetes admission control objects inside the cluster (for example, Pod Security Admission, ValidatingAdmissionPolicy, or a validating webhook such as Gatekeeper/Kyverno), created with kubectl or via a Kubernetes Terraform provider. In the OCI Console you would:- Get credentials for the OKE cluster and configure
kubectl. - Apply an admission policy (e.g., a ValidatingAdmissionPolicy or webhook) that denies any pod where
spec.hostPID == true.

