KCSA Node Security: Kubelet, Container Runtime, kube-proxy and Pods
Kubernetes node security is the hardening of the kubelet, the container runtime and kube-proxy that run on every worker node, and of the Pod settings that decide how much of the node a container can reach. This KCSA lesson covers kubelet authentication and authorization (anonymous access, Webhook mode, how kubelet API paths map to RBAC and why nodes/proxy is dangerous) and its read-only port, the container runtime chain and why its socket and its patches matter, kube-proxy's role, deployment and endpoints, and the Pod-level controls: securityContext users, privilege escalation, capabilities, seccomp and a read-only root filesystem, service account token mounting, host namespaces and user namespaces.
On this page10 sections
- What node security covers in Kubernetes
- Kubelet authentication: anonymous requests and credentials
- Kubelet authorization: Webhook mode and node subresources
- The kubelet read-only port
- The container runtime and its socket
- kube-proxy security
- Pod securityContext: users, privilege escalation and capabilities
- Seccomp, AppArmor and a read-only root filesystem
- Service account tokens in Pods
- Host namespaces and user namespaces
- Configure kubelet authentication so requests without credentials are rejected, and explain how anonymous requests are identified when they are not
- Explain why kubelet Webhook authorization is needed alongside authentication, and map kubelet API paths to RBAC subresources, including the risk of get on nodes/proxy
- Explain why the kubelet read-only port is a disclosure risk and how to close it
- Describe the kubelet to CRI to OCI runtime chain, why mounting the runtime socket gives control of the node, and where runtime vulnerabilities are patched
- Describe what kube-proxy does, how kubeadm deploys it, and how its metrics, health and NodePort addresses are configured
- Apply Pod securityContext controls: non-root users, no privilege escalation, minimal capabilities, seccomp RuntimeDefault and a read-only root filesystem
- Control service account token mounting, host namespaces and user namespaces in Pod specs
What node security covers in Kubernetes
Node security is the hardening of the components that run workloads on every worker node, the kubelet, the container runtime and kube-proxy, and of the Pod settings that decide how much of the node each container can reach. The control plane decides what should run; the node is where it actually runs, so a weak node component or an over-privileged Pod is the most common path from one compromised container to the whole node and then the cluster.
| Component | What it does | What an attacker gains by abusing it | Main controls |
|---|---|---|---|
| kubelet | The node agent: takes Pod specs from the API server, starts containers through the runtime, reports status, serves an HTTPS API (port 10250) | Through its API: Pod listings, logs, and command execution in any container on the node | Anonymous auth off, Webhook authorization, read-only port closed, least-privilege RBAC on node subresources |
| Container runtime | containerd or CRI-O, plus a low-level OCI runtime such as runc, creates and isolates containers | Through its socket: containers started outside Kubernetes, including privileged ones; through a runtime bug: container breakout | Never mount the runtime socket into Pods, patch runtime packages on every node, sandboxed runtimes for untrusted code |
| kube-proxy | Programs each node's Service forwarding rules (iptables, IPVS or nftables) | Redirected Service traffic, and node-level network privileges | Protect its DaemonSet, ServiceAccount and ConfigMap, keep metrics on loopback, limit NodePort addresses |
| Pod | The unit that runs containers with the settings in its spec | Whatever the spec allows: root, host namespaces, extra capabilities, an API token | securityContext (non-root, no privilege escalation, dropped capabilities, seccomp, read-only root filesystem), no unneeded token, no host namespaces, user namespaces |
The control plane (API server, controller manager, scheduler, etcd), the NodeRestriction admission plugin and API-server-to-kubelet TLS are in the control plane security lesson. Container networking, client access and storage are in the next lesson of this domain. Sandboxed runtimes such as gVisor and Kata Containers are taught with isolation in the Overview domain, and which settings each Pod Security Standards profile allows is taught in the Pod Security Standards and Admission lesson.
Kubelet authentication: anonymous requests and credentials
The kubelet authenticates every request to its HTTPS API, and the one setting that decides what happens to a request with no credentials is anonymous authentication: with it on, such a request is accepted as the user system:anonymous in the group system:unauthenticated; with it off, the kubelet answers 401 Unauthorized. The kubelet's command-line defaults are --anonymous-auth=true and --authorization-mode=AlwaysAllow; a KubeletConfiguration file defaults to anonymous off and Webhook authorization. Because the two sets of defaults differ, hardened setups (kubeadm included) set both explicitly either way.
The kubelet has three authentication settings in a KubeletConfiguration file (each also exists as a command-line flag):
| Setting | Flag | What it does |
|---|---|---|
authentication.anonymous.enabled: false | --anonymous-auth=false | Rejects requests that carry no client certificate and no bearer token with 401 |
authentication.x509.clientCAFile | --client-ca-file | Accepts client certificates signed by this CA (this is how the API server itself authenticates to kubelets) |
authentication.webhook.enabled: true | --authentication-token-webhook | Validates bearer tokens, such as service account tokens, by sending a TokenReview to the API server |
The certificate and webhook settings add ways for callers who present credentials to be recognised; neither one refuses a caller who presents none. Only turning anonymous authentication off does that. Authentication also only answers who is calling: a valid stolen token still authenticates successfully, which is why authorization (next section) matters just as much.
When anonymous authentication is left on, an anonymous request is not automatically harmless. It moves on to authorization like any other identity. Under Webhook authorization, RBAC decides for system:anonymous and system:unauthenticated exactly as it does for any other user or group: whatever a binding grants those identities on node subresources, anonymous callers get.
The kubelet read-only port
The kubelet read-only port, historically 10255, is a second listener that serves Pod and node information over plain HTTP with no authentication and no authorization, so hardening guidance is to close it with readOnlyPort: 0 (or --read-only-port=0). It is off by default when a KubeletConfiguration file is used, but older setups, flags and some managed images have opened it.
The risk is information disclosure rather than control. The port exposes Pod specs, container details and node and Pod statistics, which help an attacker map workloads, and it leaks any sensitive value written directly into a Pod spec, such as a plain environment variable. As its name says, it only reads: the danger is what it reveals, not what it can change.
Because the read-only port bypasses the authentication and authorization settings of the HTTPS API entirely, turning anonymous authentication off does not protect it. Making sure no caller without credentials can read Pod details from a kubelet needs both authentication.anonymous.enabled: false on the HTTPS port and readOnlyPort: 0.
The kubelet's certificate settings (rotateCertificates for its client certificate, serverTLSBootstrap for a CA-signed serving certificate) manage its own TLS identities; they are good practice but are about identity, not about which listeners are open or who may call them.
The container runtime and its socket
The container runtime is the software that pulls images and runs containers for the kubelet: the kubelet talks to a high-level runtime such as containerd or CRI-O through the Container Runtime Interface (CRI), and that runtime calls a low-level OCI runtime such as runc or crun, which creates the Linux namespaces and cgroups that isolate each container. Dockershim was removed in Kubernetes 1.24, so current nodes run a CRI runtime directly.
| Interface | Connects the kubelet or runtime to |
|---|---|
| CRI (Container Runtime Interface) | The container runtime: images, Pod sandboxes, containers |
| CNI (Container Network Interface) | Network plugins that give Pods addresses and connectivity |
| CSI (Container Storage Interface) | Storage drivers that provision and mount volumes |
| OCI specifications | Not a plugin interface: the image format and the runtime spec that runc and crun implement |
The runtime socket is root on the node. containerd listens on /run/containerd/containerd.sock and CRI-O on /var/run/crio/crio.sock. Anything that can write to the socket can ask the runtime to start any container, including a privileged one with the host's root filesystem mounted. Containers started that way never pass through the API server, so RBAC, admission control and Pod Security Admission never see them. Any Pod given the socket through a hostPath volume therefore has control of the node, and with it every workload and credential on that node. Use rootless or daemonless image builders instead of mounting the socket.
Runtime vulnerabilities are node-level vulnerabilities. The low-level runtime sets up isolation, so a flaw in it can let a process escape to the host; runc has had such bugs, including CVE-2019-5736 and CVE-2024-21626. The fix is to update the runtime packages (runc, and containerd or CRI-O where they bundle or pin it) on every node, usually by rolling out a patched node image. The vulnerable binary lives on the node, so only replacing it there removes the flaw. Where untrusted code must run, a sandboxed runtime selected with a RuntimeClass adds a further isolation layer (taught with isolation in the Overview domain).
kube-proxy security
kube-proxy is the node component that watches Services and EndpointSlices and programs each node's packet-forwarding rules (iptables, IPVS or nftables) so that traffic for a Service's virtual IP reaches a backend Pod; anyone who controls it or its configuration can redirect Service traffic. Keep its job distinct from its neighbours: the CNI plugin handles Pod addressing and NetworkPolicy enforcement, and cluster DNS handles name resolution.
Because every node must forward Service traffic, kubeadm deploys kube-proxy as a DaemonSet in kube-system that runs on every node with the host network and as a privileged container, so it can change the node's network rules. Its configuration lives in the kube-proxy ConfigMap and it authenticates to the API server with the kube-proxy ServiceAccount. Protecting kube-proxy therefore means restricting who can edit that DaemonSet, ConfigMap and ServiceAccount, as much as hardening the process.
kube-proxy also opens a few endpoints of its own, which a KubeProxyConfiguration controls:
| Setting | Default | Security note |
|---|---|---|
metricsBindAddress | 127.0.0.1:10249 | Plain HTTP with no authentication; binding it to 0.0.0.0 exposes it on every interface of the node without adding TLS or authentication. Keep it on loopback, or restrict which hosts can reach it if a remote scraper needs it. |
healthzBindAddress | 0.0.0.0:10256 | A health check endpoint used by load balancers; it reveals little but can be narrowed to the interface that needs it. |
nodePortAddresses | All node addresses in iptables and IPVS mode; the node's primary IPs in nftables mode | Lists the CIDRs on which NodePort Services are opened, so it restricts the node addresses every NodePort listens on. |
The bind address settings concern kube-proxy's own endpoints, and clusterCIDR only tells kube-proxy the Pod address range.
Pod securityContext: users, privilege escalation and capabilities
A Pod's securityContext is the part of its spec that sets the Linux security settings of its containers, such as which user they run as, whether they can gain privileges and which capabilities they hold; it can be set for the whole Pod and per container, and container-level values win.
Running as non-root. runAsUser sets the UID the container process runs as; runAsNonRoot: true is a check, not a user. With it set, the kubelet compares the effective UID (from runAsUser, or else the image's USER instruction) with 0 and refuses to start a container that would run as root, reporting an error such as CreateContainerConfigError. It never substitutes another user, and the API server accepts the Pod because the image's user is only known on the node. If the image has no USER instruction, it runs as root, so pair runAsNonRoot with a non-zero runAsUser (or an image with a numeric non-root USER). runAsGroup sets the primary group and fsGroup the group ownership of volumes.
Privilege escalation. allowPrivilegeEscalation: false sets the Linux no_new_privs flag, so a process cannot gain more privileges than its parent, for example by executing a setuid-root binary or one with file capabilities. Kubernetes documents allowPrivilegeEscalation: false as inconsistent with privileged: true or the CAP_SYS_ADMIN capability: escalation is always possible for such a container. The API server rejects the setting alongside privileged: true, and a container that adds SYS_ADMIN can gain privileges whatever the setting says. To actually keep no_new_privs, remove the privileged flag or SYS_ADMIN.
Capabilities. Linux splits root's power into capabilities, and container runtimes grant a default set (including NET_BIND_SERVICE and NET_RAW) that most applications never use. The least-privilege pattern is to drop everything and add back only what is needed:
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]
For a process running as root in the container, the capabilities left after drop and add are the ones it holds. NET_BIND_SERVICE allows binding ports below 1024; NET_ADMIN (network configuration) and SYS_ADMIN (a huge catch-all) are far broader and rarely justified. Two caveats: for a non-root user, an added capability only reaches the bounding set, so the binary also needs a matching file capability; and some runtime configurations, such as containerd 2.x by default, already let unprivileged processes bind low ports. privileged: true grants every capability and access to host devices, and should be reserved for node-level system components.
Seccomp, AppArmor and a read-only root filesystem
Seccomp filters which system calls a container may make, and Kubernetes runs containers Unconfined (no filtering) unless a profile is requested in the securityContext or the kubelet's seccompDefault option is enabled. Many people assume the runtime's default profile always applies; in Kubernetes it does not.
seccompProfile.type | What it uses |
|---|---|
RuntimeDefault | The default profile maintained by containerd or CRI-O; blocks a set of rarely needed, risky system calls and needs nothing on the node |
Localhost | A custom profile file on the node, named in localhostProfile and placed under the kubelet's seccomp directory (by default /var/lib/kubelet/seccomp) |
Unconfined | No filtering; also what applies when nothing is set and seccompDefault is off |
Setting seccompProfile.type: RuntimeDefault at the Pod level covers every container. Enabling seccompDefault: true in the KubeletConfiguration makes RuntimeDefault the node-wide default for Pods that set nothing. Seccomp is distinct from allowPrivilegeEscalation: no_new_privs stops privilege gain on exec but filters no system calls. AppArmor, on nodes that support it, is set with securityContext.appArmorProfile and the same three kinds of type, and restricts file and resource access rather than system calls.
A read-only root filesystem. readOnlyRootFilesystem: true mounts the container image's filesystem read-only, so an attacker with a shell cannot replace binaries or drop tools into the image's contents. Because the mount itself is read-only, it refuses writes from every user, root included: permissions and capabilities decide who may write to a writable file, but they cannot make a read-only mount writable. Volumes are separate mounts, so the application can still write where it is meant to. When an application needs a scratch directory, mount an emptyDir volume at that path (for example /tmp); it is deleted with the Pod.
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: registry.example.com/app:1.4.2
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}Service account tokens in Pods
By default every Pod gets a token for its ServiceAccount mounted at /var/run/secrets/kubernetes.io/serviceaccount/, and a Pod that never calls the Kubernetes API should not have one: set automountServiceAccountToken: false so an attacker who compromises it finds no API credential. Pointing the Pod at a ServiceAccount with no RBAC rights is weaker: the token still authenticates, and any rights granted to that ServiceAccount later, or to groups it belongs to, come with it.
The setting exists on both the ServiceAccount and the Pod, and the Pod's value takes precedence. Turning automount off on the ServiceAccount is a sensible default, but any Pod author can turn it back on in the Pod spec; there is no conflict error, and the token volume stays read-only. To guarantee no token, enforce the Pod-level setting with an admission policy.
Mounted tokens are short-lived and bound to the Pod. On current clusters the kubelet requests a token through the TokenRequest API and mounts it as a projected volume. The token has an audience and an expiry, the kubelet refreshes it before it expires, and it is bound to the Pod object: once that Pod is deleted (after graceful termination completes), the API server rejects the token. Each Pod has its own token, so a token's lifetime is tied to its Pod, not to the ServiceAccount: deleting a Pod ends its token alone. Actions at the ServiceAccount or cluster level, such as recreating the ServiceAccount or rotating the signing key, also invalidate tokens but affect every Pod that depends on them, and changing RBAC changes what a token may do, not whether it authenticates. Long-lived tokens stored in Secrets are a legacy pattern to avoid. How service accounts authenticate in general, and Secrets as objects, are taught in the Kubernetes Security Fundamentals domain.
Host namespaces and user namespaces
Host namespace settings let a Pod share one of the node's Linux namespaces instead of getting its own, which removes a layer of isolation, so ordinary workloads should leave all three off.
| Setting | Shares | What a compromised container gains |
|---|---|---|
hostPID: true | The node's process ID namespace | Sees every process on the node, can read details such as command lines and environments where permissions allow, and with enough privilege can signal or trace them |
hostNetwork: true | The node's network namespace | Uses the node's interfaces and IP, can bind node ports, and reaches services bound to the node's loopback, such as the kube-proxy metrics endpoint and the kubelet's local endpoints; Pod-targeted network controls generally do not apply to it |
hostIPC: true | The node's IPC namespace | Reads and writes shared memory segments and System V message queues used by other processes on the node |
Binding a service to 127.0.0.1 protects it only from other network namespaces; a hostNetwork Pod is in the node's namespace, so loopback is the node's loopback. Reading or writing host files is a different setting again, a hostPath volume. Some system components (kube-proxy, CNI agents) legitimately need host namespaces; application Pods should not.
User namespaces are the control for workloads that must run as root inside the container. Setting hostUsers: false in the Pod spec gives the Pod its own user namespace: the kubelet maps the container's UIDs and GIDs, including root, to a distinct unprivileged range on the host. A process that escapes the container lands as an unprivileged host user, and capabilities such as CAP_SYS_ADMIN apply only inside the Pod's namespace. The image itself is unchanged. It requires node support: a recent Linux kernel and a runtime that implements it, such as containerd 2.0 or later or a recent CRI-O. Without a user namespace, root in a container is UID 0 on the host as well, which is why the other Pod controls work by removing privileges rather than remapping the user.
Tip. KCSA questions on this topic are mostly short definitions and scenarios about which component or setting does what. Kubelet items separate anonymous authentication from Webhook authorization, ask which KubeletConfiguration setting or flag closes a gap, and test how kubelet paths map to nodes subresources, including why get on nodes/proxy is not read-only. Read-only port items ask what it exposes. Runtime items cover the CRI and its sibling interfaces, the risk of a mounted runtime socket, and how runtime vulnerabilities are remediated. kube-proxy items cover what it maintains, how it is deployed, and its metrics, health check and NodePort address settings. Pod items work through securityContext fields (users and groups, privilege escalation, capabilities, seccomp profile types, readOnlyRootFilesystem), service account token automount and token lifetime, host namespaces and user namespaces. Scenarios usually add a constraint, such as least privilege or minimal disruption, that decides between workable options.
- Turn kubelet anonymous authentication off; when it is on, credential-less requests become system:anonymous in system:unauthenticated and only RBAC bindings decide what they get.
- Run kubelets with Webhook authorization: AlwaysAllow lets any valid token, even a stolen low-privilege one, run commands in every container on the node.
- Kubelet paths map to nodes subresources; get on nodes/proxy can execute commands, so monitoring needs only nodes/metrics and nodes/stats.
- The read-only port serves Pod details over HTTP with no checks and is not covered by anonymous-auth; set readOnlyPort: 0.
- The kubelet calls containerd or CRI-O over CRI, which calls runc; the runtime socket is root on the node, and runtime CVEs are fixed by patching every node.
- kube-proxy runs as a privileged host-network DaemonSet that programs Service forwarding; keep metrics on 127.0.0.1 and use nodePortAddresses to keep NodePorts off public interfaces.
- runAsNonRoot is a check enforced by the kubelet at start; pair it with a non-zero runAsUser. allowPrivilegeEscalation: false is inconsistent with privileged (rejected by the API server) and with SYS_ADMIN, so remove those to keep no_new_privs.
- Drop ALL capabilities and add back only what is needed; set seccomp RuntimeDefault, because unset means Unconfined.
- readOnlyRootFilesystem stops even root from writing to the image; give writable paths an emptyDir.
- Disable token automount for Pods that never call the API (the Pod setting overrides the ServiceAccount), avoid host namespaces, and use hostUsers: false for root-in-container images.
Check yourself: 3 questions on this topic
Exam-style KCSA questions on Node security: kubelet, container runtime, kube-proxy and Pods, answered right here with an explanation after each. Want more? KCSA Kubernetes Cluster Component Security practice questions.
Frequently asked questions
How do you stop the kubelet from accepting anonymous requests?
Set authentication.anonymous.enabled: false in the KubeletConfiguration file, or start the kubelet with --anonymous-auth=false. The kubelet then answers 401 Unauthorized to any request on its HTTPS API that carries neither a client certificate nor a bearer token. Enabling webhook token authentication or a client CA file does not do this, because those only add ways to authenticate callers who do present credentials. The separate read-only port must also be closed with readOnlyPort: 0, since it ignores authentication entirely.
What is the difference between kubelet AlwaysAllow and Webhook authorization?
With AlwaysAllow (the default for the --authorization-mode flag), every authenticated request is allowed, so any valid credential, including a stolen service account token, can list Pods, read logs and run commands in containers on that node. With Webhook, the kubelet sends a SubjectAccessReview for each request to the kube-apiserver, so the cluster's RBAC rules decide. Production kubelets should use Webhook together with anonymous authentication turned off.
Why is get on nodes/proxy dangerous?
The kubelet maps any API path without a specific subresource, including exec, attach, run and port-forward, to nodes/proxy. Some of those endpoints accept WebSocket connections, which begin with an HTTP GET and are authorized with the get verb, so get on nodes/proxy can be enough to run commands in every container on a node. Grant monitoring tools get on nodes/metrics and nodes/stats instead.
What is the kubelet read-only port and should it be disabled?
The read-only port, historically 10255, is a kubelet listener that serves Pod specs, container details and node statistics over plain HTTP with no authentication or authorization. It cannot run commands or change objects, but it discloses information that helps an attacker map workloads, including values written directly into Pod specs. Disable it with readOnlyPort: 0 in the KubeletConfiguration or --read-only-port=0.
Why is mounting containerd.sock into a Pod dangerous?
Whoever can use the container runtime socket, such as /run/containerd/containerd.sock or /var/run/crio/crio.sock, can start any container on the node, including a privileged one that mounts the host's root filesystem. Containers started this way bypass the API server, so RBAC, admission control and Pod Security Admission never see them. A Pod with the socket mounted therefore effectively controls the node.
Which seccomp profile does a Kubernetes container use by default?
If neither the Pod nor the container sets a seccompProfile and the kubelet's seccompDefault option is off, the container runs Unconfined, with no system call filtering. Set seccompProfile.type: RuntimeDefault in the securityContext to use the container runtime's default profile, or enable seccompDefault on the kubelet to make RuntimeDefault the default for every Pod on that node.
Does automountServiceAccountToken on the Pod or the ServiceAccount win?
The Pod's setting takes precedence. If a ServiceAccount sets automountServiceAccountToken: false but a Pod using it sets true, the token is mounted. Setting false on the ServiceAccount is a good default, but to guarantee that Pods get no token you must also enforce the Pod-level setting, for example with an admission policy.
What does hostUsers: false do in a Pod spec?
It runs the Pod in its own Linux user namespace, so the kubelet maps the container's user IDs, including root, to an unprivileged range on the host. A process that escapes the container is then an unprivileged user on the node, and capabilities it holds apply only inside the Pod. It lets images that must run as root run more safely without changes, but the node needs a recent Linux kernel and a runtime that supports user namespaces, such as containerd 2.0 or later.
Source
This lesson covers the "Kubernetes Cluster Component Security" domain of the official KCSA exam guide. Vendors revise their guides — check the source for the current version.
- KCSA certification page and curriculum — The Linux Foundation
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.