Skip to content

About

experimental tooling for quickly evaluating ubuntu kernel CVE fixes and needs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

105 Commits

Folders and files

Repository files navigation

kernel-cve-tools

kcve is a read-only command-line tool that answers CVE questions about Ubuntu kernels, using local clones of public vulnerability data. It's designed for kernel CVE triage and SRU (Stable Release Update) reporting. Typical questions:

  • How many CVE fixes are still needed for jammy linux 5.15.0-203.213?
  • How many high-priority CVEs were fixed in the latest noble linux-azure-7.0 kernel?
  • Which fixes are pending in the current SRU cycle for a kernel derivative?
  • Which CVEs were fixed between two kernel versions?
  • Which of a kernel's open CVEs will be fixed by its upstream stable updates, and which need a manual backport?

Note

kcve never makes network calls and never modifies the data clones. You keep the clones up to date yourself. Every report shows each clone's latest commit, so you can see how fresh the data is. The only files kcve writes are its own: a small working-kernel state file, and a cache (see Caching).

Features

  • Kernel finder: fuzzy search across every kernel known to the Ubuntu CVE Tracker (UCT). It tolerates typos and lets you pick an exact name interactively.
  • Working kernel: pick a kernel once, and later commands in that terminal use it. Each terminal or tmux pane keeps its own selection. Without one, reports use a default kernel.
  • Status reports: counts by UCT status (needs-triage, needed, pending, released, not-affected, ignored, deferred), broken down by Ubuntu priority and by CVSS severity.
  • Fixed-in reports: CVEs fixed in the latest version, in a specific version, or between two versions. kcve versions lists the versions to choose from.
  • As-of view: re-evaluates statuses for an earlier kernel version, counting fixes that landed later as still needed then.
  • Upstream comparison: checks a kernel's open CVEs against mainline and the upstream stable branches that feed it, using the kernel.org vulns data. It can also report on any single upstream branch.
  • Severity data: combines CVSS scores from UCT, kernel.org (vulns) and the CVE List (cvelistV5). Reports show the highest available score with its source, and always show Ubuntu's own CVSS assessment when there is one. CVEs with no score are reported as UNSCORED, never dropped.
  • Filters: by status, Ubuntu priority and CVSS severity. They can be combined, repeated, or comma-separated.
  • Output formats: terminal tables, Markdown (for sharing with stakeholders) and JSON (for scripting).
  • Explain one or more CVEs: inspect UCT status and evidence, Ubuntu priority, CVSS, and upstream fixing evidence for selected IDs in one kernel.

Requirements

  • Linux, Python 3.12+, and uv
  • Local git clones of the data repositories:
Repository Clone from Used by
ubuntu-cve-tracker https://git.launchpad.net/ubuntu-cve-tracker all commands
vulns https://git.kernel.org/pub/scm/linux/security/vulns.git status, fixed, upstream
cvelistV5 https://github.com/CVEProject/cvelistV5 status, fixed, upstream
ubuntu-security-notices https://github.com/canonical/ubuntu-security-notices history (kernel release dates)

Put the clones side by side in one directory, under the names above:

mkdir -p ~/src/kcve-data && cd ~/src/kcve-data
git clone https://git.launchpad.net/ubuntu-cve-tracker
git clone https://git.kernel.org/pub/scm/linux/security/vulns.git
git clone https://github.com/CVEProject/cvelistV5

cvelistV5 and ubuntu-cve-tracker are large. The first clone can take a while.

Getting started

git clone <this-repository-url> kernel-cve-tools
cd kernel-cve-tools
uv sync
cp .env.example .env

Edit .env and set the directory that contains your clones:

KCVE_REPOS_DIR="/home/you/src/kcve-data"

Then check that everything is wired up:

uv run --env-file .env kcve find jammy linux

The examples below shorten uv run --env-file .env kcve to kcve. To run it that way, export KCVE_REPOS_DIR in your shell and activate the project's virtual environment (source .venv/bin/activate), or install the tool (see Installing as a tool).

Workflows

1. Pick a working kernel

Reports work on one kernel at a time, named as UCT does: <release>_<source-package>, e.g. jammy_linux-azure-6.8 or esm-infra/focal_linux. Use find to look one up:

kcve find linux-azure          # every release of linux-azure and its variants
kcve find jammy azure 6.8      # every term must match
kcve find nobel azure          # typos fall back to close matches ("noble")

Each match shows the latest released version and its needed, pending and needs-triage counts. In a terminal, find asks you to pick one (or to confirm a single match). Your choice becomes this terminal's working kernel, and later commands use it when you don't name a kernel:

kcve find jammy azure 6.8      # confirm jammy_linux-azure-6.8
kcve status                    # reports on jammy_linux-azure-6.8
kcve fixed --list

Manage the working kernel with use:

kcve use                       # show the working kernel and where it comes from
kcve use noble_linux-azure     # set it directly
kcve use --clear               # go back to the default

When a command doesn't name a kernel, kcve picks one in this order:

  1. The working kernel selected in this terminal
  2. KCVE_DEFAULT_KERNEL, if it's set in .env or your environment
  3. The generic linux kernel of the newest Ubuntu series in UCT (currently the development series). A newer series is picked up automatically once UCT starts tracking it.

Reports always state which kernel they used, and why, so a shared report is never ambiguous. Selections are kept per terminal: each terminal window, tab or tmux pane has its own. They last until you log out. Use --no-input with find to list matches without being prompted. Naming a kernel on the command line always overrides the working kernel.

2. Status summary for a kernel

kcve status jammy_linux

This prints counts by status and Ubuntu priority, and by status and the severity of the highest available CVSS score. Add --list to see each CVE.

3. What's pending in the current SRU cycle?

In UCT, pending means a fix is committed but not yet released, so it marks the current cycle:

kcve status noble_linux-azure --status pending --list
kcve status noble_linux-azure --status pending --severity critical,high --list

When there's more than one pending version (e.g. two kernels in flight), look at one at a time with kcve fixed (versions come from kcve versions):

kcve fixed noble_linux-azure --status pending            # newest pending version
kcve fixed noble_linux-azure --in 6.8.0-1074.83 --status pending --list

4. What was fixed in a kernel release?

First, list the kernel's versions to pick from. They're shown newest first, with the number of CVEs released (or pending) in each:

kcve versions jammy_linux            # newest 20; add --all or --limit N
kcve versions --released-only        # working kernel, without pending versions

UCT only records versions that fixed at least one CVE. Then:

# The latest released version recorded in UCT
kcve fixed noble_linux-azure-7.0 --priority high

# A specific version
kcve fixed jammy_linux --in 5.15.0-203.213 --list

# After the first version, up to and including the second
kcve fixed jammy_linux --from 5.15.0-202.212 --to 5.15.0-203.213 --list

kcve fixed reports released CVEs by default. Add --status pending, or --status released,pending, to include fixes that are pending in those versions. If UCT records no fixes in a version you give, kcve prints a note listing the nearest versions it does know about.

5. How many fixes are needed for a specific version?

kcve status jammy_linux --as-of 5.15.0-203.213
kcve status jammy_linux --as-of 5.15.0-194.204 --status needed --priority critical --list

The needed row answers the question. Any CVE fixed (or marked not-affected) in a later version counts as needed at the version you give, and the CVE list shows where it was fixed later (e.g. fixed later in 5.15.0-202.212). This uses the current tracker data to work out the state at that version. It is not a historical snapshot of the tracker.

6. Will upstream stable updates fix it, or does it need a backport?

kcve upstream noble_linux                   # summary of open CVEs vs upstream
kcve upstream noble_linux --bucket backport-needed --priority high --list
kcve upstream resolute_linux --branches 6.18,7.3 --list   # try different feeds

This compares the kernel's needed and needs-triage CVEs (change this with --status) with the upstream stable branches that feed it, and with mainline. Each CVE lands in one bucket:

Bucket Meaning
available-upstream A feeding stable branch has the fix, so expect it through stable updates
backport-needed Fixed upstream, but not in any feeding branch: needs a manual backport
unfixed-upstream Not fixed upstream yet
not-affected-upstream Upstream says mainline and the feeding branches are not affected
no-upstream-record The upstream comparison has no usable published vulns record. This is the comparison bucket for both not-in-vulns (no published record under vulns) and unpublished (a kernel.org reservation state such as reserved, review, or rejected)

Below the bucket counts, two tables break each bucket down by Ubuntu priority and by max CVSS severity. For example, they show how many of the available-upstream fixes are critical or high.

With --list, each CVE shows its status on every feeding branch (e.g. 6.12.50), on mainline, and any other upstream branches that have the fix, which are useful when backporting. Mainline fixes that are only in a release candidate are marked, e.g. 7.4-rc1 (rc only). JSON and Markdown output also include the fixing commits.

Which branches feed which kernel? Ubuntu kernels don't map 1:1 to upstream stable branches. kcve has a built-in mapping (for example, 6.8 is fed by 6.12 and 6.6, and 7.0 by 6.18, 7.2 and 7.3), and every report prints the mapping it used. Override it per run with --branches, or persistently with KCVE_UPSTREAM_FEEDS (see Configuration). If a kernel has no mapping, kcve asks you to provide one rather than guessing.

Reports also show each upstream branch's support status and its latest release in vulns. When a branch is end-of-life upstream (like 5.4), the comparison still runs, with a note that Ubuntu's fixes will now exceed upstream's.

How far behind is the upstream sync? Tell kcve which upstream release each feed was last synced to, and it splits available-upstream into fixes that landed after that release (expect them in the next sync) and fixes upstream already had (worth checking why they're still open):

kcve upstream jammy_linux --synced 5.15.215
kcve upstream resolute_linux --synced 6.18.50,7.2.6        # one per feed
kcve upstream jammy_linux --synced 5.15.215 --sync after-last-sync --list

UCT doesn't record which upstream release a kernel last synced to, so you provide it with --synced, which takes X.Y.Z (or X.Y=X.Y.Z) per feed branch. Or let kcve infer it with --synced auto:

kcve upstream jammy_linux --synced auto
# Last synced: 5.15.224 (inferred from Ubuntu 5.15.0-204.214: 327 CVEs fixed there)

auto looks at the CVEs fixed in the kernel's newest release and finds which upstream stable release fixed them. It picks the highest release that fixed at least two of them, so a single early cherry-pick doesn't count as a sync. It's an estimate, labelled as inferred; pass the real release if you know it. Without --synced, no sync point is assumed.

Once a feed branch is end-of-life upstream (like 5.4 for focal), Canonical stops taking upstream stable updates from it, so --synced auto doesn't infer a sync point for it. The report also says such fixes need a manual backport, instead of expecting them through stable updates or the next sync.

To report on a single upstream branch instead:

kcve upstream --branch 6.18 --upstream-status needed --list
kcve upstream --branch mainline --upstream-status fixed --severity critical --list

# Fixes by the upstream release they landed in (like kcve fixed)
kcve upstream --branch 5.15 --in 5.15.221 --list
kcve upstream --branch 5.15 --from 5.15.215 --list            # since a sync point
kcve upstream --branch mainline --from 7.2 --to 7.3

Every --list row shows the exact release a fix landed in (e.g. 5.15.221), and the header shows the branch's latest release in vulns.

These reports also break each upstream status down by max CVSS severity. They are a pure upstream view, so they don't show Ubuntu priority, and --priority isn't accepted. Use --severity to filter instead, or compare against an Ubuntu kernel to see Ubuntu priorities.

7. History: CVEs logged and patched per month

kcve history jammy_linux                    # last 12 months
kcve history --months 24 --by severity      # working kernel, bars by CVSS severity
kcve history --since 2025-01 --until 2025-12 --priority critical,high
kcve history --all --format json            # every month with data

Each month gets two stacked bars on the same scale, split by Ubuntu priority (or --by severity):

L = logged (CVEs made public that month, per UCT)
P = patched (CVEs fixed in a kernel version first published in a USN that month)
Legend: █ critical  ▓ high  ▒ medium  ░ low  · negligible  ? unknown

2026-10  L  1055  ▓▓▓▓▓▒▒▒▒▒▒▒▒▒░░░░░░░░░░░
         P   950  █▓▓▓▓▓▓▒▒▒▒▒▒▒░░░░░░░░

Note

Filters and the bar breakdown are separate. --priority and --severity choose which CVEs are counted. --by chooses how each bar is split, and it defaults to Ubuntu priority even when you filter by severity. To filter by CVSS severity and also split the bars by it, pass both:

kcve history jammy_linux --severity critical,high --by severity

A table follows, with monthly totals and the kernel versions released that month. Release dates come from the USNs in ubuntu-security-notices, because UCT doesn't record them. Fixes in versions with no USN are counted and noted, not dropped.

In a terminal, the bars are coloured by level (red critical, yellow high, cyan medium, blue low, grey negligible or none, magenta unknown or unscored) and sized to fit the terminal width. When the output is piped or saved, they fall back to the shaded characters above and a width of 50. Override with --color always|never (the NO_COLOR environment variable also turns colour off) and --width N. Markdown and JSON output never include colour codes.

To see one series on its own, use --show logged or --show patched (with --branch: --show published or --show fixed). The bars then use the full width, and the table and JSON include only that series. Releases are listed only when patched CVEs are shown.

For an upstream branch or mainline:

kcve history --branch 6.18
kcve history --branch mainline --all --severity critical

This shows CVEs published each month (date from cvelistV5) that affect the branch, and how many of those it has fixed now, by CVSS severity. Upstream release dates aren't available locally, so fixes are counted by the CVE's publication month, not by when the fix was released. There's no Ubuntu priority in this view.

How far back: UCT public dates go back to 2013 for current kernels, and USN release dates to 2007. kernel.org became a CVE authority in 2024, so CVE volume jumps from then, and upstream (vulns) history mostly starts there.

8. Explain selected CVEs

explain combines the Ubuntu package record and the local upstream evidence for specific CVE IDs, while keeping missing and anomalous records visible:

kcve explain jammy_linux CVE-2024-1234 CVE-2024-5678
cat cvelist.txt | kcve explain jammy_linux
kcve explain noble_linux --cve-file cvelist.txt
kcve explain jammy_linux CVE-2024-1234 --as-of 5.15.0-203.213
kcve explain jammy_linux CVE-2024-1234 --format markdown
kcve explain jammy_linux CVE-2024-1234 --format json

Table output truncates the summary to the terminal width (using at least one reserved column). --color auto enables colour only for terminal table output and is disabled by NO_COLOR; --color always and --color never override that policy. Markdown and JSON never contain ANSI colour. UCT patch details are intentionally omitted from explain output; JSON retains structured UCT state, reason, priority, CVSS, notes, tags, and upstream evidence.

IDs are case-insensitive. IDs supplied in arguments, files, or piped stdin are combined in that order and deduplicated stably, so the first spelling is reported only once. Blank lines and # comments in files and stdin are ignored. Malformed tokens are reported as input issues rather than silently dropped.

The report distinguishes a missing UCT record (not-in-uct) from a UCT file with no exact package/release field (no-kernel-entry), DNE, an invalid status, and no CVSS (unscored). Upstream evidence may distinguish not-in-vulns from unpublished (reserved/review/rejected/returned); both map to the comparison bucket no-upstream-record. Upstream evidence may otherwise be incomplete because it has no version data, or unavailable for older/no-data branches.

--as-of changes only the Ubuntu package status: a released, pending, or not-affected version later than the supplied package version is treated as needed at that earlier version. Upstream evidence remains current to the local vulns clone's HEAD, not historical. A future-release or pending fix uses the existing UCT version semantics; not-affected is treated as fixed at the version recorded in UCT.

Only override upstream feeds with --branches X.Y,... when their mappings are unknown and you know the correct feeding branches:

kcve explain resolute_linux CVE-2026-1234 --branches 6.18,7.3

9. Share or script the results

kcve status noble_linux-azure --status pending --list --format markdown > pending.md
kcve fixed jammy_linux --list --format json | jq '.cves[] | select(.max_cvss.score >= 9)'

Markdown and JSON output include the data freshness information, so shared reports show how current the data was. For explain, text freshness appears in stderr at the bottom of the report, Markdown and JSON include it in the output, and every report remains based only on local, read-only data clones.

Caching

The first run after you update a clone can take several seconds, because kcve reads the clones directly. It caches what it derives, so later runs are fast (well under a second), including in other terminals and after a reboot.

  • The cache lives in ~/.cache/kernel-cve-tools (or $XDG_CACHE_HOME, or KCVE_CACHE_DIR if set). It takes about 10–20 MB, depending on how many kernels you look at.
  • It refreshes itself: each entry records the commit of every clone it was built from, and is rebuilt automatically after you git pull any of them.
  • Different commands share cached data. For example, kcve status, kcve fixed and kcve upstream for the same kernel all use one cached copy of that kernel's CVEs.
kcve cache                     # show the cache location and its entries
kcve cache --clear             # delete the cache
kcve status jammy_linux --no-cache   # bypass the cache for one run

Reading the output

  • Ubuntu priority: Canonical's priority for the CVE (critical to negligible), from UCT. Per-release overrides are applied.
  • MAX CVSS: the highest base score from any source, shown with its source and CVSS version, e.g. 9.8 CRITICAL (kernel.org, 3.1). --severity filters on this score.
  • UBUNTU CVSS: Ubuntu's own CVSS assessment, when there is one (usually CVSS 4.0).
  • UNSCORED: no CVSS score in any local source. Many recent kernel CVEs have no score yet.
  • Exit codes: 0 success, 1 no matches (find), 2 usage or configuration error.

Configuration

Data locations are resolved in this order:

  1. Per-repository flags: --uct-dir, --vulns-dir, --cvelist-dir, --usn-dir
  2. Per-repository environment variables: KCVE_UCT_DIR, KCVE_VULNS_DIR, KCVE_CVELIST_DIR, KCVE_USN_DIR
  3. --repos-dir DIR
  4. KCVE_REPOS_DIR

Options 3 and 4 expect the clones under their default names (see Requirements). .env is git-ignored, and .env.example documents every variable.

Other settings:

Variable Purpose
KCVE_DEFAULT_KERNEL Default kernel when a terminal has no working kernel, e.g. noble_linux
KCVE_UPSTREAM_FEEDS Upstream feed overrides for kcve upstream, e.g. 7.0=6.18,7.3;7.3=7.3
KCVE_STATE_DIR Where working-kernel selections are stored (default: $XDG_RUNTIME_DIR/kernel-cve-tools)
KCVE_CACHE_DIR Where the cache is stored (default: $XDG_CACHE_HOME/kernel-cve-tools, i.e. ~/.cache/kernel-cve-tools)

Installing as a tool

To run kcve outside the repo, install the wheel into its own environment:

uv build
uv tool install dist/kernel_cve_tools-*.whl
export KCVE_REPOS_DIR="$HOME/src/kcve-data"
kcve --help

Development

uv sync
uv run ruff format .
uv run ruff check .
uv run --env-file .env pytest

Unit tests use small synthetic data repos in tests/fixtures/. Tests marked integration read your real clones, and are skipped when KCVE_REPOS_DIR is not set. Project conventions and design decisions for contributors (including AI coding agents) are in AGENTS.md.

Limitations

  • UCT has no list of kernel releases. Versions come from CVE status lines, so a kernel version that fixed no CVEs isn't visible.
  • Each report covers exactly one kernel, and does not combine packages or releases.
  • upstream_* and devel_* entries in UCT are ignored.
  • The upstream feed mappings and upstream end-of-life dates are maintained by hand in the code. kcve upstream prints maintenance notes when they look out of date. Use --branches or KCVE_UPSTREAM_FEEDS in the meantime.
  • Upstream data covers CVEs published by the kernel.org CNA. Older upstream branches without stable data in vulns (e.g. 4.15) can't be compared.

License

MIT

About

experimental tooling for quickly evaluating ubuntu kernel CVE fixes and needs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages