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

HostPath Volume enabled on Containers

HostPath volumes mounting should not be used.

YAML Configuration

rule.yaml YAML
apiVersion: rules.spotter.dev/v1alpha1
kind: SpotterRule
metadata:
  name: spotter-workload-014
  labels:
    severity: "critical"
    category: "workload"
  annotations:
    rules.spotter.dev/title: "HostPath Volume enabled on Containers"
    rules.spotter.dev/version: "1.0.0"
    rules.spotter.dev/cwe: "CWE-732"
    rules.spotter.dev/description: "HostPath volumes mounting should not be used."
spec:
  match:
    resources:
      kubernetes:
        apiGroups:
          - ""
          - "apps"
        versions:
          - "v1"
        kinds:
          - Pod
          - Deployment
          - StatefulSet
          - DaemonSet
        namespaces:
          include: ["*"]
          exclude: ["kube-system", "kube-public"]
        labels:
          exclude:
            rules.spotter.dev/ignore: ["true"]
  cel: |
    (object.kind == 'Pod' && 
      has(object.spec.volumes) && object.spec.volumes.exists(v, has(v.hostPath))
    ) ||
    (object.kind != 'Pod' && 
      has(object.spec.template.spec.volumes) && object.spec.template.spec.volumes.exists(v, has(v.hostPath))
    )
  remediation:
    manual: "Never use hostPath volume mounts. Instead, use a read-only persistent volume claim (PVC) or a config map or secret."
  references:
    - title: "Volumes - hostPath"
      url: "https://kubernetes.io/docs/concepts/storage/volumes/#hostpath"