#3746·grype

`match.dpkg.using-cpes` (and `match.rpm.using-cpes`) is accepted but has no effect

Author: amitschendelCreated Sep 27, 2026Updated Sep 27, 2026

What happened:

Setting match.dpkg.using-cpes: true (or GRYPE_MATCH_DPKG_USING_CPES=true) does not change matching. grype config --load shows the value as true, but a .deb that Debian does not ship still gets no CPE-based matches, even when its CPE has NVD records.

In the config code, dpkgConfig and rpmConfig embed matcherConfig, so both get the using-cpes key. When the matchers are built, getMatcherConfig passes only MissingEpochStrategy and UseCPEsForEOL (and dpkg.MatcherConfig / rpm.MatcherConfig have no field for the value). Nothing reads opts.Match.Dpkg.UseCPEs or opts.Match.Rpm.UseCPEs except the default-value tests.

The key was exposed in #2976, which added the dpkg/rpm sections for the missing-epoch setting. The dpkg and rpm using-cpes keys are also the only ones without a description in DescribeFields, so grype config prints them with no comment.

What you expected to happen:

One of the following:

  1. match.dpkg.using-cpes: true runs CPE matching for dpkg packages in addition to the distro feed, as using-cpes does for the other matchers; or
  2. the key is removed (or rejected or warned about), so it isn't a silent no-op.

The use case for (1) is third-party .deb packages installed from a vendor's own repository, like Grafana, which the Debian feed has no records for. At the moment use-cpes-for-eol is the only way to get CPE matching for dpkg packages, and it applies only to EOL distros.

How to reproduce it (as minimally and precisely as possible):

A directory with a Debian 12 os-release and one dpkg entry for Grafana's own .deb (grafana:grafana CPE, not packaged by Debian):

bash
mkdir -p repro/etc repro/var/lib/dpkg
cat > repro/etc/os-release <<'OS'
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
ID=debian
VERSION_ID="12"
VERSION_CODENAME=bookworm
OS
cat > repro/var/lib/dpkg/status <<'DPKG'
Package: grafana
Status: install ok installed
Maintainer: [email protected]
Architecture: amd64
Version: 10.0.0
Description: Grafana

DPKG

echo "defaults:";           grype dir:repro -q | tail -n +2 | wc -l
echo "dpkg using-cpes on:"; GRYPE_MATCH_DPKG_USING_CPES=true grype dir:repro -q | tail -n +2 | wc -l

Output:

defaults:
       0
dpkg using-cpes on:
       0

Syft generates cpe:2.3:a:grafana:grafana:10.0.0:*:*:*:*:*:*:* for this package. Scanning the same CPE as a CycloneDX application component returns 31 matches, so the data is there. The same result happens with a config file (match: {dpkg: {using-cpes: true}}) instead of the env var.

Anything else we need to know?:

I tried the smallest fix locally: add UseCPEs to dpkg.MatcherConfig, pass opts.Match.Dpkg.UseCPEs in getMatcherConfig, and change the CPE condition in Match to

go
if m.cfg.UseCPEs || (m.cfg.UseCPEsForEOL && internal.IsDistroEOL(store, p.Distro)) {

With that change the repro returns 31 matches (all dpkg-matcher / cpe-match), defaults stay at 0, and go test ./grype/matcher/dpkg/... ./cmd/grype/cli/options/... ./cmd/grype/cli/commands/... passes. On debian:12-slim the flag did not change the result (219 matches with it off and on, no cpe-match entries). The debug log line inside that block says "distro is EOL", so it would need rewording. I haven't made an rpm repro; the rpm wiring looks the same from the code (rpm/matcher.go#L46, #L98).

If the maintainers would rather keep CPE matching off for distro matchers, option (2) seems like the smaller change. I'm happy to open a PR for either.

Environment:

  • Output of grype version: 0.119.0 (code paths are unchanged on main at c24afc3a)
  • OS: macOS (arm64)