Skip to content

bug(vm): root partitions named cloudimg-rootfs and root are skipped #11692

Open

Description

@nikpivkin

trivy vm reads only partitions whose names are in requiredDiskName in pkg/fanal/walker/vm.go. go-disk uses the entry index as the name of a GPT partition without a name, and the list contains 0 to 3. So the root partition of Ubuntu 24.04 and older images passes the check only because it has no name and is the first entry. Since Ubuntu 26.04, Canonical names the root partition cloudimg-rootfs in its cloud images and AMIs. AlmaLinux names it root in its GenericCloud images and AMIs. These names are not in the list, so Trivy skips the root partition and returns an empty result with exit code 0. Nothing in the output shows that a partition was skipped, even with --debug.

Reported in #11691. The empty scans of AlmaLinux AMIs in #8627 and #5722 likely have the same cause.

Steps to reproduce

$ curl -LO https://cloud-images.ubuntu.com/releases/resolute/release/ubuntu-26.04-server-cloudimg-amd64.img
$ qemu-img convert -O raw ubuntu-26.04-server-cloudimg-amd64.img ubuntu-26.04.raw
$ sgdisk -p ubuntu-26.04.raw
Number  Start (sector)    End (sector)  Size       Code  Name
   1         2324480         7339998   2.4 GiB     8304  cloudimg-rootfs
  13            2048         2097152   1023.0 MiB  EA00
  14         2099200         2107391   4.0 MiB     EF02
  15         2107392         2324479   106.0 MiB   EF00

Actual behavior

$ trivy vm --scanners vuln --pkg-types os --list-all-pkgs --format json ubuntu-26.04.raw | jq -c '{os: .Metadata.OS, packages: ([.Results[]?.Packages[]?] | length)}'
{"os":null,"packages":0}

The same steps with the Ubuntu 24.04 image detect ubuntu 24.04 and 664 packages, because its root partition has no name.

Expected behavior

Trivy detects the OS and lists the packages of Ubuntu 26.04 and AlmaLinux images. When Trivy skips a partition, the debug log shows the partition name.

Activity

  1. added
    kind/bug
    target/vm
    on Nov 20, 2026
  2. bharathvemula commented on Nov 20, 2026

    @bharathvemula

    I'll take this one — working on a fix that adds cloudimg-rootfs and root to the allowed partition names in pkg/fanal/walker/vm.go, plus a debug log when a partition is skipped.

  3. yusuke-koyoshi commented on Nov 21, 2026

    @yusuke-koyoshi
    Contributor

    I'd like to suggest dropping the name check instead of adding more names.

    The name list fails silently: an unknown name gives an empty result with exit code 0. This has already happened in #5722, #8627 and #11691, and each new name will cause it again.

    shouldSkip already skips partitions by type (Bootable()). I suggest removing requiredDiskName and also skipping Linux swap (GPT, MBR 0x82) and MBR extended partitions (0x05, 0x0F, 0x85). Partitions without ext4 or xfs are still not read, because filesystem detection fails for them. The root partitions in #11691 are then read regardless of their names, because their types are not skipped: Linux root (x86-64) in Ubuntu 26.04, and Linux filesystem data in the AlmaLinux 8, 9 and 10 GenericCloud images. This also reads the other ext4/xfs partitions on the disk, such as the volumes asked for in #5450.

    For reference, here is an implementation: yusuke-koyoshi@3a86146

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

    kind/bugtarget/vm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions