返回综合榜
开发工具与框架Kubernetes Blog

Kubernetes v1.37:通过绑定挂载选项和 EmptyDir 权限强化容器存储安全

Kubernetes v1.37 引入两项 Alpha 阶段的存储安全特性:卷挂载的绑定挂载选项,以及 emptyDir 卷的可配置权限模式。它们让团队无需借助 init 容器等变通手段,即可在 Kubernetes 中原生实施安全策略。

此前,卷在绑定挂载时默认不带 noexec、nosuid 或 nodev,因此即使容器使用只读根文件系统,被入侵的进程仍可从任意可写卷下载并执行二进制文件。PersistentVolume 的 mountOptions 作用于 CSI 存储层,无法可靠地转化为容器内的绑定挂载标志。emptyDir 还硬编码为 0777 权限,导致共享临时目录无法设置粘滞位(01777)或更严格的权限(如 0750);这些缺陷曾在 issue #48912 和 Kubernetes 1.24 安全审计(#119627)中被指出。

实际使用中,开发者可以在 volumeMount 上设置 bindMountOptions: [noexec, nosuid] 来阻止执行和 setuid 提权,或在 emptyDir 上设置 mode: 01777,使多容器 Pod 中的容器无法删除彼此的文件。bindMountOptions 支持 emptyDir、PersistentVolume、CSI、projected、ConfigMap 和 Secret 卷(不支持镜像卷),mode 则适用于磁盘、Memory 和 HugePages 三种 emptyDir 介质。

两项特性均需在 API server 和 kubelet 上启用 Alpha 特性门控 VolumeBindMountOptions 和 EmptyDirVolumeMode,若省略相关字段则行为与之前完全一致。bindMountOptions 要求容器运行时支持 CRI 的 mount_options 字段;调度器会避开不支持该能力的节点,kubelet 也会拒绝此类 Pod。fsGroup 会覆盖 emptyDir 的 mode,两项特性仅支持 Linux,且若 kubelet 未启用 EmptyDirVolumeMode 门控,mode 字段会被忽略并回退到 0777。

Kubernetes v1.37: Hardening Container Storage with Bind Mount Options and EmptyDir Permissions

Kubernetes v1.37 introduces two alpha-stage storage security features: bind mount options on volume mounts and configurable permission modes for emptyDir volumes. They let teams apply security policies natively, without init-container workarounds.

Previously, volumes were bind-mounted without noexec, nosuid, or nodev, so a compromised process could download and execute binaries from any writable volume even with a read-only root filesystem. PersistentVolume mountOptions apply at the CSI storage layer and do not reliably translate into container bind mount flags. emptyDir also defaulted to a hardcoded 0777 mode, preventing shared scratch directories from getting sticky-bit (01777) or tighter (e.g. 0750) permissions; these gaps were flagged in issue #48912 and the Kubernetes 1.24 security audit (#119627).

In practice, developers can now set bindMountOptions: [noexec, nosuid] on a volumeMount to block execution and setuid escalation, or set mode: 01777 on an emptyDir so containers in a multi-container pod cannot delete each other's files. bindMountOptions works with emptyDir, PersistentVolumes, CSI, projected, ConfigMap and Secret volumes (not image volumes), while mode supports disk, Memory and HugePages emptyDirs.

Both features are behind the alpha feature gates VolumeBindMountOptions and EmptyDirVolumeMode on the API server and kubelet, and defaults are unchanged if the fields are omitted. bindMountOptions requires the container runtime to support the CRI mount_options field; the scheduler avoids nodes lacking it and the kubelet rejects such pods. fsGroup overrides the emptyDir mode, both features are Linux-only, and if the kubelet lacks the EmptyDirVolumeMode gate the mode field is ignored and 0777 is used.

kubernetesstoragesecuritybind mountemptyDirfeature gatealpha
综合11
质量91
猎物热度0
时效0
信息来源1 个来源,主来源:Kubernetes Blog

猎鹰不保存原文正文。标题与摘要用于快速发现信息,事实细节请以来源原文为准。

查看来源