HostPath volumes mounting should not be used.
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"