Repository navigation
Description
Severity: Low
Summary
In internal/imagecache/bundle_linux.go, setupImageVolumes constructs mount points using ImageVolumeMountPath(bundlePath, vol.Name) without verifying that vol.Name is a clean, local relative path. If a crafted rootfs-overlay.json containing path traversal sequences (such as ../) is processed, setupImageVolumes can create directories, unmount existing mounts, and mount image layers at arbitrary locations on the host within the privileged ateworker context.
Details
In internal/imagecache/bundle_linux.go#L114-L122:
mountpoint := ImageVolumeMountPath(bundlePath, vol.Name)
if err := os.MkdirAll(mountpoint, 0o700); err != nil {
return fmt.Errorf("while creating image volume mount point %q: %w", mountpoint, err)
}
_ = unix.Unmount(mountpoint, unix.MNT_DETACH)
if err := mountImageVolume(mountpoint, vol.Layers); err != nil {
return fmt.Errorf("while mounting image volume %q: %w", vol.Name, err)
}And internal/imagecache/spec.go#L30-L32:
func ImageVolumeMountPath(bundlePath, volumeName string) string {
return filepath.Join(bundlePath, "volumes", volumeName)
}In contrast to createExtraDirs (internal/imagecache/spec.go#L182-L184), which uses os.OpenRoot and enforces filepath.IsLocal, setupImageVolumes performs no checks on vol.Name.
Impact
Exploitability is constrained by upstream controls:
- Both
ateapi(cmd/ateapi/internal/apivalidation/zz_generated.validation.go#L9511) andatelet(cmd/atelet/internal/apivalidation/zz_generated.validation.go#L4448) enforcevalidate.ShortName(content.IsDNS1123Label), rejecting slashes and..traversal sequences in volume names at API ingress. rootfs-overlay.jsonis generated byateleton the host; untrusted sandboxed containers cannot modify it directly.
An attacker would require a pre-existing host-level compromise or a bypass of the API server validation to write a maliciousrootfs-overlay.json.
Suggested fix
Validate vol.Name in setupImageVolumes before joining paths, rejecting non-local paths or path separators:
if !filepath.IsLocal(vol.Name) || filepath.Base(vol.Name) != vol.Name {
return fmt.Errorf("invalid volume name %q: must be a local filename", vol.Name)
}Related
- Related:
SystemInfoVolumeSourceaccepts path traversal (e.g.../) #1436 (SystemInfoVolumeSourcepath traversal validation) - Related: PR Mount an OCI image read-only into an actor #923 (Added image volumes to ActorTemplate)
- Related: PR ateworker-microvm: mount image volumes from EROFS layer images in the guest #2826 (Micro-VM image volumes refactor)
Activity
[-][Low] setupImageVolumes builds host mount paths from vol.Name without a containment check[/-][+]Validate vol.Name path containment in imagecache.setupImageVolumes[/+]quick fix: validating image volume names before constructing mount po…