SKY-D411 · Deployment and infrastructure
Kubernetes container mounts a sensitive host path
A hostPath volume puts a file or folder of the node into the container. SKY-D411 reports one that mounts the node's root, its system and credential folders (/etc, /proc, /sys, /var/lib/kubelet), or the container runtime's socket such as /var/run/docker.sock.
- Languages
- Kubernetes YAML
- Quality gate
- counted toward the gate limits (full and diff scans). Reported under security (
danger). It counts towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Kubernetes sensitive host path mounted
Why it matters
Whoever can talk to the Docker or containerd socket can start a privileged container on the node, so the mount is root on the node in one step. /etc and /var/lib/kubelet hold the node's credentials and other pods' secrets.
What Skylos flags
apiVersion: apps/v1kind: DaemonSetmetadata: name: node-agent namespace: monitoringspec: selector: matchLabels: app: node-agent template: metadata: labels: app: node-agent spec: containers: - name: agent image: registry.example.com/node-agent:2.4.1 volumeMounts: - name: docker-sock mountPath: /var/run/docker.sock volumes: - name: docker-sock hostPath: path: /var/run/docker.sock type: SocketWhat Skylos leaves alone
apiVersion: apps/v1kind: DaemonSetmetadata: name: node-agent namespace: monitoringspec: selector: matchLabels: app: node-agent template: metadata: labels: app: node-agent spec: containers: - name: agent image: registry.example.com/node-agent:2.4.1 volumeMounts: - name: logs mountPath: /var/log readOnly: true volumes: - name: logs hostPath: path: /var/logWhy Skylos leaves it alone
A log collector that mounts the node's /var/log is a common and narrower hostPath. /var/log is not on the list of sensitive paths.
How Skylos decides
- Runs with
--danger(or-a). Reads every.yamland.ymlfile that declares anapiVersionand akind, skipping.git,node_modules, build and virtual-environment folders. It never renders Helm templates or Kustomize overlays and never contacts a cluster. - Checks the pod spec of
Pod,PodTemplate,ReplicationController,Deployment,DaemonSet,ReplicaSet,StatefulSet,JobandCronJob, including items of av1List. Values containing template markers such as{{or${are treated as unknown and never reported. - For each
volumeMountsentry of each container, finds the pod volume with the same name. OnlyhostPathvolumes count. - Works out the host path that is really mounted, including a
subPath. A path with a template marker,.., asubPathExpror a volume name used twice is not judged. - Reports
/, any path inside or above/etc,/proc,/sysand/var/lib/kubelet(so/var/libcounts too), and the Docker, containerd, CRI-O, cri-dockerd, dockershim, k3s and Podman sockets under/runor/var/run, or a folder that holds one. - Reports HIGH on the volume mount entry.
readOnly: truedoes not remove the finding: a read-only socket still accepts API calls.
How to fix it
Do not give workloads the runtime socket. Build images in CI or with a rootless builder, read container data through the Kubernetes API, and mount only the narrow paths an agent needs, read-only.
apiVersion: apps/v1kind: DaemonSetmetadata: name: node-agent namespace: monitoringspec: selector: matchLabels: app: node-agent template: metadata: labels: app: node-agent spec: containers: - name: agent image: registry.example.com/node-agent:2.4.1 volumeMounts:Removed: - name: docker-sockRemoved: mountPath: /var/run/docker.sockAdded: - name: logsAdded: mountPath: /var/logAdded: readOnly: true volumes:Removed: - name: docker-sockAdded: - name: logs hostPath:Removed: path: /var/run/docker.sockRemoved: type: SocketAdded: path: /var/logWhen it can be wrong
- Node agents such as log shippers that read
/var/lib/dockercontainers or monitoring agents that read/procare reported. Accept reviewed ones with a baseline. volumeDevices(raw block devices) are not judged.- Helm chart templates are not rendered. A value written as
{{ .Values.x }}is not judged, and a template file that is not valid YAML on its own (most are not) stops the scan as incomplete, exit 2, with a Kubernetes parse error. Exclude the chart'stemplatesfolder and scan the output ofhelm templateinstead.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
The Kubernetes rules read no inline marker:
# skylos: ignore[SKY-D411]on the reported mount does not hide the finding.[tool.skylos] ignore = ["SKY-D411"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the workloads that exist today and reports new ones.