Skip to content

Validate vol.Name path containment in imagecache.setupImageVolumes #2919

Open

Description

@destijl

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:

  1. Both ateapi (cmd/ateapi/internal/apivalidation/zz_generated.validation.go#L9511) and atelet (cmd/atelet/internal/apivalidation/zz_generated.validation.go#L4448) enforce validate.ShortName (content.IsDNS1123Label), rejecting slashes and .. traversal sequences in volume names at API ingress.
  2. rootfs-overlay.json is generated by atelet on 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 malicious rootfs-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

Activity

  1. added
    kind/bug
    area/security
    on Oct 19, 2026
  2. changed the title [-][Low] setupImageVolumes builds host mount paths from vol.Name without a containment check[/-] [+]Validate vol.Name path containment in imagecache.setupImageVolumes[/+] on Oct 29, 2026
  3. added a commit that references this issue on Nov 29, 2026
    ca14d32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/securitykind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions