Pods that use the host network can access the node's network interfaces, which can be a security risk.
apiVersion: rules.spotter.dev/v1alpha1
kind: SpotterRule
metadata:
name: spotter-workload-002
labels:
severity: "critical"
category: "workload"
annotations:
rules.spotter.dev/title: "Pod Uses Host Network"
rules.spotter.dev/version: "1.0.0"
rules.spotter.dev/cwe: "CWE-265"
rules.spotter.dev/description: "Pods that use the host network can access the node's network interfaces, 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.hostNetwork) && object.spec.hostNetwork == true) ||
(object.kind == 'Configuration' && has(object.spec.template.spec.hostNetwork) && object.spec.template.spec.hostNetwork == true) ||
(object.kind in ['Deployment', 'StatefulSet', 'DaemonSet'] && has(object.spec.template.spec.hostNetwork) && object.spec.template.spec.hostNetwork == true)
remediation:
manual: "Do not use the host network for pods unless it is absolutely necessary."
references:
- title: "Pod Security Standards"
url: "https://kubernetes.io/docs/concepts/security/pod-security-standards/#host-namespaces"