Rule Metadata

Last updated: 2024-01-15
🔴
Severity
CRITICAL
🛡️
Category
Workload & Runtime Security
Version
v1.0.0
Downloads
1.2K
Author: Spotter Security Team
Created: 2024-01-10
Compliance:
CIS NIST

Shared Host PID Namespace

Pods that use the host PID namespace can see all processes on the node, which can be a security risk.

YAML Configuration

rule.yaml YAML
apiVersion: rules.spotter.dev/v1alpha1
kind: SpotterRule
metadata:
  name: spotter-workload-004
  labels:
    severity: "critical"
    category: "workload"
  annotations:
    rules.spotter.dev/title: "Shared Host PID Namespace"
    rules.spotter.dev/version: "1.0.0"
    rules.spotter.dev/cwe: "CWE-265"
    rules.spotter.dev/description: "Pods that use the host PID namespace can see all processes on the node, which can be a security risk."
spec:
  match:
    resources:
      kubernetes:
        apiGroups:
          - ""
          - "apps"
          - "serving.knative.dev"
        versions:
          - "v1"
        kinds:
          - Pod
          - Deployment
          - StatefulSet
          - DaemonSet
          - Configuration
        namespaces:
          include: ["*"]
          exclude: ["kube-system", "kube-public"]
        labels:
          exclude: 
            rules.spotter.dev/ignore: ["true"]
  cel: |
    (object.kind == 'Pod' && has(object.spec.hostPID) && object.spec.hostPID == true) ||
    (object.kind == 'Configuration' && has(object.spec.template.spec.hostPID) && object.spec.template.spec.hostPID == true) ||
    (object.kind in ['Deployment', 'StatefulSet', 'DaemonSet'] && has(object.spec.template.spec.hostPID) && object.spec.template.spec.hostPID == true)
  remediation:
    manual: "Do not use the host PID namespace for pods unless it is absolutely necessary."
  references:
    - title: "Pod Security Standards"
      url: "https://kubernetes.io/docs/concepts/security/pod-security-standards/#host-namespaces"