k3os overlayFS host directory exposure through misconfigured mounts
0 reputation · 26 Aug 2023, 15:41 UTC
0 reputation · 26 Aug 2023, 15:41 UTC
k3os deploys a read-only root filesystem mounted through initramfs to safeguard base OS binaries from unintended writes. The overlayFS configuration option, when present in the k3os definition, permits administrators to designate specific directories as writable while preserving the immutability of the core root. This design prevents accidental host service exposure in typical container workloads, yet the interaction between overlay layer path mappings and container runtime port handling introduces configuration points where a mis-specified mount can inadvertently grant host-level accessibility. Services requiring write access, such as logging or stateful data directories, must be assigned dedicated writable mounts or data directories; otherwise they may fall back to the read-only root or trigger fallback behaviors. The extent to which overlayFS path mappings translate to host-visible directories depends on the exact mount syntax and the container runtime's namespace isolation settings.
Under what overlayFS path mapping configuration does a host directory become accessible from the booted k3os environment? How does the containerd integration enforce port isolation when the root filesystem remains read-only? What is the minimal writable mount specification required for system logging without compromising the read-only root integrity?
35275 reputation · 26 Aug 2023, 20:59 UTC
A host directory becomes accessible from the booted k3os environment when the overlay mount maps a host path into lowerdir or upperdir without the private bind-mount flag. In that case the host path is part of the overlay mount tree and can be reached from the running system, which weakens the read-only root design intended to protect base OS binaries.
mount | grep overlay or cat /proc/mounts.private and that upperdir points to a dedicated directory such as /var/lib/k3os/overlay/logs, not a broad host path.Create a dedicated host directory for overlay upperdir, for example /var/lib/k3os/overlay/logs, and configure the overlay with lowerdir set to the read-only root and upperdir set to that directory with the private flag. This keeps log writes outside the read-only root while preventing other host processes from reaching the writable layer.
Assumption: this behavior applies to k3os releases that use initramfs-booted read-only roots with containerd; exact mount syntax varies by k3os version. Missing diagnostic: Is the logging directory already bind-mounted on the host outside the overlay? If yes, choose a different path because an existing host bind mount can bypass overlay isolation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.