Vulnerability management for NixOS
nixray docs tracker.md
8.7 kB · 145 lines
Markdown
at main

Pre-classification from the NixOS security tracker #

The Nixpkgs security tracker (source) links new CVEs to nixpkgs packages automatically; the NixOS security team then accepts or rejects each link. nixray uses these decisions as hints in the review inbox. A hint never decides anything by itself: a person applies it, and the resulting suppression or confirmation names the tracker as its source.

How the tracker stores decisions #

One suggestion (CVEDerivationClusterProposal) per CVE:

field meaning
status pending, accepted, published (accepted and turned into an issue NIXPKGS-YYYY-NNNN), rejected
rejection_reason set when rejected, see below
comment free text, required for a rejection without reason
packages nixpkgs attribute names the suggestion links (with per-branch versions)
ignored_packages candidates the security team removed from an accepted suggestion

Rejection reasons and who sets them (shared/listeners/automatic_linkage.py):

reason set by meaning
not_in_nixpkgs security team the affected product is not packaged; a name collision
(none, comment only) security team rejected with an explanation
exclusively_hosted_service automatic, from the CVE's tags a hosted service, never local software
hardware_only_cpe automatic, from the CVE's CPEs hardware/firmware
known_vulnerability automatic nixpkgs already lists the CVE in meta.knownVulnerabilities
no_matches automatic the tracker's (vendor-aware) matcher found no nixpkgs package
max_matches_exceeded automatic too many candidates; no information

Obtaining the decisions #

Checked against the live service (October 2026: 51,522 suggestions; 38,581 rejected, 4,504 published, 21 accepted, 8,416 pending):

option verdict
GET /api/v1/matching-training-data: the bulk export of all accept/reject decisions not available: restricted to a manually assigned group
Mirror GET /api/v1/suggestions rejected: page size is fixed at 10 and pages are 285–475 KB, so ≈ 5,150 requests and ≈ 1.8 GB, on infrastructure that restricts its bulk export because of load
GET /api/v1/suggestions?package=<attribute> works for top-level attributes, but misses CVEs the tracker never linked to a package (e.g. the Drupal Diff CVE that vulnix matches to Haskell's Diff), and needs attribute names that vulnix does not know
GET /api/v1/suggestions/by-cve/<CVE-ID> chosen: one public request per CVE in nixray's findings, about 30–50 KB each, and it also covers automatic rejections without packages

Rate limits (api/throttling.py, settings): 30 requests/minute anonymous, 120/minute with a personal API token (Authorization: Token …, created in the tracker's settings). The client keeps a minimum interval between requests (2.1 s anonymous, 0.55 s with a token), honours Retry-After on HTTP 429 and identifies itself with a User-Agent. A 404 means the tracker has no suggestion for the CVE; that result is cached like a decision.

A first sync of a host with ≈ 500 distinct CVEs therefore takes ≈ 18 minutes anonymously or ≈ 5 minutes with a token; later syncs only look up new CVEs and re-check stale results:

  • pending: re-checked after 1 day,
  • everything else (decisions, inconclusive, unknown): after 7 days.

What to expect: measured coverage #

Measured on a real NixOS 26.05 desktop scan (469 distinct CVEs, October 2026):

approach result
per package (?package=) 12 % of findings got a decision, all of them confirmed; no false-positive hints at all
per CVE (sample of 62) 55 % unknown (404), 24 % pending, 11 % confirmed, 10 % inconclusive, 0 % rejected

The tracker only holds CVEs it ingested since going into production in 2026: none of the sampled CVEs from 2021–2025 were known (40 % of this host's CVEs are that old), while 76 % of the 2026 CVEs were. So the tracker mainly confirms current vulnerabilities and, over time, rejects new name collisions; it does not help with old vulnix false positives such as the Drupal Diff CVE matched to Haskell's Diff. Coverage grows with every newly published CVE.

Privacy #

Looking up a CVE tells the tracker's operators that this host (its IP address) is affected by, or at least matched to, that CVE. The set of looked-up CVEs approximates the host's vulnerable-software inventory. The feature is therefore off by default (services.nixray.tracker.enable), and only the scan's own CVE identifiers are sent: no package names, versions or paths.

Mapping a decision to a finding #

A finding is (CVE, package name, version); the tracker speaks in attribute names. A package name matches an attribute if the attribute's last component equals the package name, ignoring case and -/_, after stripping vulnix's python3.13- style prefix (e.g. python313Packages.requests ↔ python3.13-requests, haskellPackages.Diff ↔ Diff).

tracker outcome finding's package hint
accepted/published among packages affected, by the security team (links the issue)
accepted/published among ignored_packages not affected, by the security team
accepted/published neither unlikely: the tracker links this CVE to other packages only (listed)
rejected: not_in_nixpkgs, comment only any not affected, by the security team
rejected: exclusively_hosted_service, hardware_only_cpe any not affected, automatic (from CVE metadata)
rejected: known_vulnerability any affected, automatic (nixpkgs lists it)
rejected: no_matches any unlikely, automatic: the tracker found no nixpkgs package
pending, max_matches_exceeded (inconclusive), unknown any no hint

Versions are not compared: the tracker records versions per nixpkgs branch, which rarely equals the deployed version; they are shown for context.

Integration in nixray #

  • Domain (domain/advice.py): ExternalTriage (one tracker decision about a CVE, normalised), assess(finding, triage) → Hint | None implementing the table above, and the refresh policy. Exact attribute matches win over matches of the attribute's last component: for an openssl CVE the team linked openssl and ignored rubyPackages.openssl. The tracker's vocabulary stays in the adapter.
  • Application: port PerCveSource[ExternalTriage].lookup(cve); use case SyncExternalTriage looks up the CVEs of present findings whose cached result is missing or stale and stores each result in its own transaction (an interrupted sync keeps its progress). An unreachable tracker stops the sync; an answer for one CVE that the parser rejects only skips that CVE, which stays due (nixray tracker-sync still exits 1). TriageService.apply_advice(selection) turns affected hints into confirmations and not affected hints into suppressions for (CVE, package); the reason names the tracker and links the suggestion. Unlikely hints are never applied automatically.
  • Adapter adapters/tracker: HTTP client (stdlib urllib, no new dependency) with throttling, retries and a strict parser.
  • Persistence: table external_triage, one row per CVE: a cache of external data, replaced on refresh. The audit trail lives in the suppressions and confirmations created from it.
  • Operation: nixray tracker-sync [--limit N], run by nixray-tracker-sync.timer 45 minutes after each scan when services.nixray.tracker.enable is set. The optional token is passed as a systemd credential (tracker.tokenFile) and never appears in the environment. The web process still never contacts the network.
  • On demand: Pull advice now in the review inbox creates /run/nixray/tracker-sync.request; the path unit nixray-tracker-sync.path starts the same hardened sync service, which deletes the file when it starts. The web unit's only additional permission is write access to /run/nixray (no network, no token, no D-Bus/polkit). Without the NixOS module NIXRAY_TRACKER_REQUEST_FILE is unset and the button is hidden. The demo (nix run .#demo) sets it and plays the path unit's role with a small loop, so the button queries the live tracker there.
  • UI: a hint chip on findings in the review inbox, the findings list and the CVE page (with a link to the tracker); an inbox filter by hint; an Apply tracker advice action for the selection.