Skip to main content

SKY-D409 · Deployment and infrastructure

Kubernetes container runs in privileged mode

High

A privileged container runs with almost every protection of the container turned off: it sees all host devices and holds every Linux capability. SKY-D409 reports a Kubernetes workload that sets securityContext.privileged: true on a container.

Languages
Kubernetes YAML
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security; the rule never reports CRITICAL.
Finding type
review
Catalog name
Kubernetes privileged container
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Code running in a privileged container is effectively root on the node. A bug in that container, or a compromised image, lets an attacker escape to the node and from there reach every other pod and the secrets scheduled on it.

What Skylos flags

deploy/node-agent.yaml · YAMLReported on line 19
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          securityContext:            privileged: true

What Skylos leaves alone

deploy/node-agent.yaml · YAML
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          securityContext:            privileged: false            capabilities:              add: ["NET_ADMIN"]

Why Skylos leaves it alone

The container gets the one extra Linux capability it needs (NET_ADMIN, to change network settings) instead of every capability. Added capabilities are outside this rule.

How Skylos decides

  1. Runs with --danger (or -a). Reads every .yaml and .yml file that declares an apiVersion and a kind, skipping .git, node_modules, build and virtual-environment folders. It never renders Helm templates or Kustomize overlays and never contacts a cluster.
  2. Checks the pod spec of Pod, PodTemplate, ReplicationController, Deployment, DaemonSet, ReplicaSet, StatefulSet, Job and CronJob, including items of a v1 List. Values containing template markers such as {{ or ${ are treated as unknown and never reported.
  3. Looks at every container in containers, initContainers and ephemeralContainers. A container needs a unique literal name; otherwise it is not judged.
  4. Reports when securityContext.privileged is the boolean true. false, a missing value and a missing securityContext pass; a string such as "true" is not judged.
  5. Reports HIGH on the privileged: line, once per container.

How to fix it

Remove privileged: true and add only the capabilities the process needs. Enforce this cluster-wide with the Pod Security Admission baseline or restricted level.

deploy/node-agent.yaml · YAML · the fix, against the flagged file
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          securityContext:Removed:             privileged: trueAdded:             privileged: falseAdded:             capabilities:Added:               add: ["NET_ADMIN"]

When it can be wrong

  • Some node agents (CNI plugins, storage drivers, some monitoring agents) really need privileged mode. Accept reviewed ones with a baseline.
  • 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's templates folder and scan the output of helm template instead.

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-D409] on the privileged: line does not hide the finding.

  • [tool.skylos] ignore = ["SKY-D409"] turns the rule off for the project.

  • A baseline (skylos baseline ., then --baseline) accepts the workloads that exist today and reports new ones.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.