fixed false positives for ubuntu kernel packages and backfixes#3129
fixed false positives for ubuntu kernel packages and backfixes#3129rezmoss wants to merge 8 commits intoanchore:mainfrom
Conversation
…VE-2023-2163 Signed-off-by: Rez Moss <hi@rezmoss.com>
…VE-2023-2163 Signed-off-by: Rez Moss <hi@rezmoss.com>
21c89c3 to
40349fd
Compare
| func (m *Matcher) Match(store vulnerability.Provider, p pkg.Package) ([]match.Match, []match.IgnoreFilter, error) { | ||
| // skip cpe matching for linux-kernel packages on major distros like ubuntu to avoid false positives from nvd's version ranges not covering backported fixes | ||
| // kernel vulns are still found accurately using dpkg/rpm matchers with distro data that includes backported fixes | ||
| if p.Type == syftPkg.LinuxKernelPkg && isMainDistro(p.Distro) { |
There was a problem hiding this comment.
this is minor, however, since the first branch of this is by package type (kernel) we should make a separate matcher for this. This also keeps the stock matcher as simple as possible (and matchers are tailor made to handle by package type).
There was a problem hiding this comment.
Added this as a matcher. Now we just need to talk about the matching it's doing and make sure this is behaving the way we expect.
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
|
Working on getting this up to date with a new matcher:
|
Signed-off-by: Rez Moss <hi@rezmoss.com>
Signed-off-by: Rez Moss <hi@rezmoss.com>
|
@spiffcs dropped this here i worked on this earlier & since i'm tied up with other stuff, didnt get to do a final review but tested it pretty thoroughly with the all distro listed, it's all yours to edit, delete, or revert grype result before/after and dockerfile to reprod |
Signed-off-by: Rez Moss <hi@rezmoss.com>
|
Thanks so much @rezmoss - I finally got out from under some work and am trying to grind through PRs that can get over the line. Your name came up a couple times so I wanted to start with the ones you had from Christmas. Thank you for all the effort and thought put into these PRs. I really appreciate the work and will be sure to get these landed 😄 |
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
|
@spiffcs all good on timing, happy to see it moving forward,just ping me if anything comes up |
| // distrosWithReliableKernelData are distros where kernel vulnerabilities are handled by their | ||
| // native package matchers (dpkg/rpm) with distro-specific backport data. | ||
| // For these distros, the kernel matcher skips CPE matching to avoid false positives. | ||
| var distrosWithReliableKernelData = []distro.Type{ |
There was a problem hiding this comment.
Is it possible to infer this from our database or something? I don't love adding yet another hard coded list of distros. Maybe we can query the distro for kernel RPM / dpkg matches and then assume it's a reliable kernel?
There was a problem hiding this comment.
I think in an ideal world, we would distinguish between:
- The distro package owns the kernel artifact and has fixed vulns for the kernel - no fallback, vulns are fixed (or not, but the distro feed is right)
- The distro package owns the kernel artifact and there's no kernel vulns in this distro - search miss, CPE fallback
- The distro package does not own the kernel - who knows where it came from - CPE fallback.
But I'd love to see the SBOMs that made these scans.
There was a problem hiding this comment.
@willmurphyscode still new to the grype codebase so finding the answer wasnt easy, but i did my best, hope its not too off ;)
to reliably infer distros from the db, we’d need to:
- check if the distro has kernel vuln data
- see if the kernel binary came from a package manager
- make sure the version formats match
about the hardcoded approach, i think it because since sbom doesnt show ownership, the kernel binary and deb package are separate with no link
|
Can we get Syft SBOMs for these images? I'd like to understand why Line 151 in 411d3c6 |
|
@rezmoss do you have any A Dockerfile or link to a public image you're scanning would help us answer some of the questions we have about how grype should behave. Lines 151 to 175 in 411d3c6 We want to see why the above would not be filtering out the kernel packages before they even get to the new matcher. We also want to take a look at the SBOM to see what the case would be when this matcher would emit a true positive (vulnerable) for when a kernel package is sent through this matcher. This would be the case where we could not associate the found package to having been installed as a part of the upstream distros package management. If it's installed that way then 👍 we take the Adding blocked tag to this PR for now until we have an image we can test as authoritative that demonstrates both TP/FP behavior for the new matcher 😄 |
@willmurphyscode already shared the grype output & dockerfile before, generating an sbom from those should be simple => #3129 (comment) |
|
@spiffcs you can find the dockerfile in t zip files above, but just in case, here it is too ubuntu alpine linux kernel bin, picked up by the linux-kernel-cataloger
and linux image deb pkg, picked up by dpkg-db-cataloger
also after i replied to @willmurphyscode , i realized syft might already link them somehow, but no idea why that didnt work look this
and parent
and child
hope this helps |
|
Before, I reported similar topic for Vuls. From Vuls team, OVAL does not include kernel CVEs informaiton. |
Thanks, we're already using the Ubuntu CVE tracker data to populate the grype database: https://github.com/anchore/vunnel/blob/10be0cb42e12a7ba0cf8f21e2ecb156d03583b04/src/vunnel/providers/ubuntu/parser.py#L28 |





skip cpe matching for linux-kernel packages on major distros like ubuntu to avoid false positives from nvd's version ranges not covering backported fixes
kernel vulns are still found accurately using dpkg/rpm matchers with distro data that includes backported fixes
e.g CVE-2023-2163 for 5.15.0-164 ,fixed in 5.15.0-70.77~20.04.1