SKY-D409 · Deployment and infrastructure
Kubernetes container runs in privileged mode
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 towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Kubernetes privileged container
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
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: trueWhat 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 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
- 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. - Looks at every container in
containers,initContainersandephemeralContainers. A container needs a unique literalname; otherwise it is not judged. - Reports when
securityContext.privilegedis the booleantrue.false, a missing value and a missingsecurityContextpass; a string such as"true"is not judged. - 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.
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'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-D409]on theprivileged: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.