container-startupprobe-httpget-host
Redirecting the startup HTTP probe to another host makes the kubelet fetch an arbitrary URL from the node, reaching metadata and node-local endpoints closed to pods, and a hung container passes its startup gate.
object.spec.containers.all(c,
!has(c.startupProbe) ||
!has(c.startupProbe.httpGet) ||
!has(c.startupProbe.httpGet.host) ||
c.startupProbe.httpGet.host == ""
)
spec.containers[*].startupProbe.httpGet.host must be undefined or empty ("").
Remove the host field so the probe targets the pod IP, or set it to an empty string. Field: spec.containers[*].startupProbe.httpGet.host.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: container-startupprobe-httpget-host
annotations:
kubeapt.io/uuid: "746eed3b-2e17-4742-9a68-71458f5b6e3b"
security.kubeapt.io/displayName: "Startup Probe Targets an Arbitrary Host"
security.kubeapt.io/description: "Redirecting the startup HTTP probe to another host makes the kubelet fetch an arbitrary URL from the node, reaching metadata and node-local endpoints closed to pods, and a hung container passes its startup gate."
security.kubeapt.io/resource: "Containers"
security.kubeapt.io/severity: "Low"
security.kubeapt.io/remediation: "Remove the host field so the probe targets the pod IP, or set it to an empty string. Field: spec.containers[*].startupProbe.httpGet.host."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
validations:
- expression: |
object.spec.containers.all(c,
!has(c.startupProbe) ||
!has(c.startupProbe.httpGet) ||
!has(c.startupProbe.httpGet.host) ||
c.startupProbe.httpGet.host == ""
)
message: |
spec.containers[*].startupProbe.httpGet.host must be undefined or empty ("").Save it as container-startupprobe-httpget-host.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./container-startupprobe-httpget-host.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name container-startupprobe-httpget-host -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name container-startupprobe-httpget-host -A