apt: removed packages with leftover configuration (dpkg state rc) are reported as installed #17

Closed
opened 2026-10-07 09:09:08 +00:00 by christianmanivong · 0 comments
Owner

What happens

_get_packages_apt runs dpkg-query -W without looking at the package's state, and marks every line "installed": True. dpkg also lists packages that were removed but whose configuration is still there (state rc). Those arrive in netOrk as installed packages.

On 172.22.8.50 (2026-10-07) the snapshot has 714 entries for 701 installed packages. Among the 13 extra entries are wazuh-agent 4.14.7-1 and three old kernels (linux-image-6.8.0-117-generic …), all with installed: true. dpkg reports them as rc. 10.10.0.100 carries 21 such entries, all of them old kernels.

Why it matters

  • The Packages tab lists software that is no longer on the host.
  • netOrk's CrowdSec discovery (netork/plugins/crowdsec/discovery.py) checks installed to decide whether a CrowdSec engine runs there. A removed engine whose configuration was left behind would still count.
  • For CVE matching it made no difference on these hosts. Running the snapshot with and without the rc entries gave the same findings.

Fix

Add ${db:Status-Abbrev} to the format. Either drop everything that is not ii, or keep rc entries with installed: False if the configuration-only state is worth showing. rpm and apk have no such state.

## What happens `_get_packages_apt` runs `dpkg-query -W` without looking at the package's state, and marks every line `"installed": True`. dpkg also lists packages that were removed but whose configuration is still there (state `rc`). Those arrive in netOrk as installed packages. On 172.22.8.50 (2026-10-07) the snapshot has 714 entries for 701 installed packages. Among the 13 extra entries are `wazuh-agent 4.14.7-1` and three old kernels (`linux-image-6.8.0-117-generic` …), all with `installed: true`. dpkg reports them as `rc`. 10.10.0.100 carries 21 such entries, all of them old kernels. ## Why it matters - The Packages tab lists software that is no longer on the host. - netOrk's CrowdSec discovery (`netork/plugins/crowdsec/discovery.py`) checks `installed` to decide whether a CrowdSec engine runs there. A removed engine whose configuration was left behind would still count. - For CVE matching it made no difference on these hosts. Running the snapshot with and without the `rc` entries gave the same findings. ## Fix Add `${db:Status-Abbrev}` to the format. Either drop everything that is not `ii`, or keep `rc` entries with `installed: False` if the configuration-only state is worth showing. `rpm` and `apk` have no such state.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#17