Many OS packages missing when scanning CycloneDX SBOM with trivy sbom #9006
Replies: 5 comments 2 replies
-
Cause InvestigationTo investigate the issue, I created a set of test scripts and used git bisect to identify the commit that likely introduced the problem. These scripts automates the build and comparison between fs and sbom scans, helping to isolate the regression that causes missing OS packages in the SBOM scan. run.bash
test.bash
Identified CauseIt appears that the cause is in the following pull request: Specifically, due to cycle detection logic, some orphan OS packages (orphan-pkg) are created during the SBOM decoding phase. These orphan packages are added to the result in the following code: As a result, the internal SBOM structure ends up looking like this:
Note: Both PackageInfo objects have an empty FilePath (""). The However, since both PackageInfo entries have the same FilePath value (an empty string ""), they are merged into the same key when inserted into the nestedMap via nestedMap.SetByString. This causes the first entry (which contains the package dependency graph) to be overwritten by the second entry (which orphan packages). As a result, the packages collected via the dependency graph are lost, and only the orphan packages remain. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hello @masahiro331 I investigated amazon linux image and found that problem is related to encoding SBOM file (instead of decoding).
In other words, these components are not related to the root component (OS component). The problem is with the following logic: Lines 412 to 434 in 3b1426a rpm packages don't have a Relationship field, so we only check parents.But both packages nominally have parents, so we don't relate them to the parent component. |
Beta Was this translation helpful? Give feedback.
-
track #9011 |
Beta Was this translation helpful? Give feedback.
-
@DmitriyLewen
I think this problem needs to be solved from both encode and decode. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When generating a CycloneDX SBOM from an Amazon Linux 2023 system and then scanning it using trivy sbom, a significant number of OS packages (pkg:rpm) disappear.
Note: Due to this issue, any vulnerabilities associated with the overwritten OS packages are not detected during the trivy sbom scan.
Desired Behavior
The number of pkg:rpm entries should remain roughly the same between the original and scanned SBOMs.
Actual Behavior
The scanned SBOM (scan_sbom.json) contains significantly fewer pkg:rpm entries than the original
Reproduction Steps
1. Launch an EC2 instance using Amazon Linux 2023 AMI: ami-027fff96cc515f7bc 2. Install some basic tools sudo yum update && sudo yum install -y git tar
Operating System
amazonlinux 2023
Version
Checklist
trivy clean --all
Beta Was this translation helpful? Give feedback.
All reactions