Repository navigation
trivy vm returns an empty result for Ubuntu 26.04 images and AMIs: the root partition cloudimg-rootfs is skipped by name
#11691
Replies: 2 comments
|
This looks like the same root cause as #5450. That discussion asked to remove the partition name filter ( In #5450, the reason for keeping the filter was to avoid reading backup or journaling disks with unknown names. Adding As an alternative to a name allowlist, we could decide which partitions to skip by partition type instead of name. For example, skip empty entries, EFI System, BIOS boot, Linux swap, and MBR extended partitions, and read all other partitions. Partitions that do not contain ext4 or xfs would still be ignored, because the filesystem check fails for them. I have been running a fork with this type-based check instead of the name filter, and it has worked for my use cases: yusuke-koyoshi@3a86146 . If the maintainers prefer this direction, I am happy to open a PR. |
|
@aliculPix4D Thanks for the detailed report. Tracked in #11692. @yusuke-koyoshi, thanks for sharing the type-based check. Let's agree on the approach in the issue before you open a PR. The warning when no partition is read is not part of that issue. |
Uh oh!
There was an error while loading. Please reload this page.
Description
trivy vmreturns an empty result with exit code 0 for the official Ubuntu 26.04 and 26.10 cloud images. No OS is detected and no package is listed. Ubuntu 24.04 is scanned correctly with the same command. An AMI built from Canonical's Ubuntu 26.04 AMI gives the same empty result with anami:target.The cause is the partition name filter of the VM walker.
shouldSkipskips every partition whose name is not inrequiredDiskName:trivy/pkg/fanal/walker/vm.go
Lines 228 to 230 in 3f6334d
trivy/pkg/fanal/walker/vm.go
Lines 26 to 34 in 3f6334d
Since Ubuntu 26.04, Canonical's image build gives the root partition the GPT name
cloudimg-rootfs(livecd-rootfs 26.04.2: "Set a PARTLABEL (cloudimg-rootfs) on the root filesystem partition", commit). Up to Ubuntu 25.10 the root partition had no GPT name. For a partition without a name, go-disk returns the index of its GPT entry, which is0for the first entry, and0is on the list. The older images were read only because their root partition was unnamed and first in the table.These are the partition tables of the current official cloud images:
cloudimg-rootfscloudimg-rootfs0rootrootNothing reports the skip.
shouldSkiplogs nothing, and the walker logs a partition (Found partition) only after this check, so--debugdoes not show that a partition was skipped.--format jsonand--format cyclonedxprint no warning at all, and the table format prints only the genericSupported files for scanner(s) not found. A pipeline that scans images or generates SBOMs gets an empty result that looks like a clean image.AlmaLinux is affected in the same way. Its GenericCloud images and its AMI build name the root partition
root, and a scan of the AlmaLinux 9 GenericCloud image is empty too. This probably explains the empty scans of AlmaLinux AMIs in #5722 and #8627; neither has an answer from a maintainer. #5450 proposed to remove the name filter for another reason (project files on other volumes).Desired Behavior
trivy vmdetects Ubuntu 26.04 and lists its packages, as it does for Ubuntu 24.04.Adding
cloudimg-rootfstorequiredDiskNamefixes the Ubuntu images, and addingrootfixes the AlmaLinux image.A check that does not depend on names is possible for Ubuntu. Since 26.04 the root partition also has the GPT partition type "Linux root (x86-64)" or "Linux root (ARM-64)". Trivy could read a partition when its type is one of the Linux root types, in addition to the name list; go-disk already defines these types (
RootIntelx64,RootARMx64and the others). This keeps working when a distribution renames its root partition.I tried both changes on
main(92f029f):mainmainwith the two names added to the listmainwith the root type check and without the new namesEvery cell is the result of
trivy vm --scanners vuln --format json --list-all-pkgson the raw image. Each package list of an Ubuntu image has the same package names and versions as Canonical's manifest of that image (the manifest writes some of the names with an:amd64suffix). v0.76.2 without changes gives the same results as themaincolumn.Two things would make the remaining cases visible: a warning when a disk has a partition table and no partition was read, and a debug line with the name of each skipped partition.
Actual Behavior
No OS is detected, no package is listed and the exit code is 0. This is the complete JSON report of
trivy vm --scanners vuln --format json ubuntu-26.04.raw:{ "SchemaVersion": 2, "Trivy": { "Version": "0.76.2" }, "ReportID": "01a1f4f7-ecc1-7e48-a48e-707c08662606", "CreatedAt": "2026-11-19T19:00:51.137937387+01:00", "ArtifactName": "ubuntu-26.04.raw", "ArtifactType": "vm" }--format cyclonedxwrites an SBOM without components. Neither command prints a warning.We found this on AWS first.
trivy vm --format cyclonedxwith anami:target wrote an SBOM without components for an AMI built from Canonical's Ubuntu 26.04 AMI, after about one second and without a warning.There is no command line flag for the list, so our workaround is a build of v0.76.2 with one added line (and the import of
pkg/fanal/walker).AppendPermitDiskNameadds a name torequiredDiskName:With this build the same command lists the packages of that AMI. For the Ubuntu 26.04 image of the reproduction steps it detects ubuntu 26.04 and the 679 packages of Canonical's manifest. For Ubuntu 26.10 the same line needs a build from
main: v0.76.2 does not contain #11460 yet and detects that image asdebian forky/sid.Reproduction Steps
Target
Virtual Machine Image
Scanner
Vulnerability
Output Format
JSON
Mode
Standalone
Debug Output
Operating System
Ubuntu 26.04.1 LTS, x86_64
Version
Checklist
trivy clean --allAll reactions