Kubernetes v1.37: Hardening Co... Note

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

Kubernetes v1.37 introduces crucial storage security enhancements to bolster workload protection. These features enable the configuration of emptyDir volume permission modes and bind mount options directly within Kubernetes. This allows developers and security professionals to implement stringent security policies without complex workarounds. The improvements are built upon fundamental Linux security mechanisms like bind mount flags and directory permissions.Bind mount flags, such as noexec, nosuid, and nodev, control actions permitted on mounted filesystems. Directory permissions, including the sticky bit, regulate access and prevent unauthorized file deletions in shared directories. The primary motivation for these features is to enhance Kubernetes workload security by allowing security-relevant bind mount options. Previously, volumes were mounted without these protective flags, creating security vulnerabilities.A significant gap addressed is the inability to set mount options for emptyDir volumes and the default 0777 permission mode for directories. This allowed any process to access, modify, or delete files within emptyDir volumes, regardless of ownership. The new features provide native solutions, for instance, allowing the sticky bit to be set on emptyDir for secure shared workspaces, mirroring /tmp behavior. These enhancements empower application developers to prevent privilege escalation on writable mounts and enforce the principle of least privilege for application data.Use cases include preventing arbitrary binary execution from writable volumes and securing shared scratch space in multi-container pods. Developers can now confidently lock down access to temporary storage by setting specific modes like 0750. Both features are currently Alpha in v1.37 and require enabling feature gates: VolumeBindMountOptions and EmptyDirVolumeMode. These new capabilities are Linux-specific and do not affect Windows nodes.