Repository navigation
ci: scan a full node build for known CVEs every week - #63
Conversation
|
Force-pushed: dropped the |
|
Added the whitelist and the workflow to CODEOWNERS, same owners as the release tooling: an edit to |
|
Scan node now also imports the WireGuard preset (wireguard-tools, qrencode, lndconnect) and enables encrypted clightning replication (gocryptfs), so those parts of the shipped closure are scanned too. Re-ran on a Linux box: builds, same 22 findings. |
6c2bc1e to
f6ad969
Compare
|
Hello, I went through this PR with AI agent to collect some ideas and problems. I'm still not sure whether these reports might get too noisy. Maybe we should just run the scans without reporting to an issue, or send all reports to one fixed issue (which we could pin, for example). btw - none of the points below is a hard requirement, and there may be a better approach. Thanks! The scan itself looks solid. My doubts are about how the findings are reported. None of this is a hard requirement, and there may be a better approach. Concerns
Ideas
Did you look at vulnxscan/SARIF, or is there a reason vulnix + an issue fits better? |
|
Thanks, those are fair points. I pushed 3a3fbb5 on top of a rebase to master with your design. What changed:
On the noise premise: vulnix does see nixpkgs patches. It drops a CVE when a patch filename in the derivation carries that CVE id (the CVE patch auto-detection section in its README), and vulnxscan uses the same filename heuristic. So the stable part of the list is CVEs that nixpkgs hasn't patched or bumped past yet, plus NVD entries with wrong version ranges. That list only changes with the pin, which is why the job now only speaks when it changes. On vulnxscan: I looked at it. It aggregates vulnix, grype and OSV. Its docs say the OSV queries don't specify the ecosystem and return false positives for Nix, and grype needs its own database download, so I'd expect more noise, not less, and a much bigger tool closure. The SARIF route is real and dismissing an alert with a reason is nicer than a whitelist file, but only people with write access see the alerts and it needs Testing: Models: Fable 5.1 planned the change and Opus 5.5 wrote the first draft. Codex (GPT-6 Astra, xhigh) reviewed the uncommitted diff and found five real problems that I fixed (CRLF bodies, a clean first run that never initialized the issue, no comment size limit, a lost comment when the body was saved first, and the inherited shape check). GLM 5.3 (max) reviewed the tree at 3a3fbb5 and found nothing in the files this PR touches. Its three findings elsewhere are #107, a point #48 already fixes, and the Trezor bridge, which I filed as #153. Astra graded those three too and agreed on the first two. DeepSeek V4.1 Flash 1017 (max) timed out at the provider and gave no result. |
|
@ostermayer Thanks, you're right about vulnix: it skips CVEs named in patch filenames, so my noise premise was wrong.
|
|
@prusnak any opinion on this one? I'd give it a try and see how well it works in the long run. |
bitcoinix ships NixOS modules, not a flat package set, so the meaningful CVE scan target is the runtime closure of a built node. test/ci/scan-node.nix builds a representative node (the secure-node preset with every shipped service and backups enabled), and test/ci/cve-scan.sh runs vulnix on its system toplevel. Build-time dependencies that still reach that closure (compilers, build systems, VCS used to fetch sources) are not run on a deployed node; they are whitelisted pname-wide in .github/cve-whitelist.toml. Known vulnix pname collisions are whitelisted per CVE only. The scan fails closed: a failed build, a vulnix error exit, or a report that is not a JSON array of well-formed entries fails the job instead of reading as a clean scan. .github/workflows/cve-scan.yml runs the scan weekly and on demand. New findings open or update a `[cve-scan]` tracking issue; a clean scan closes it. SECURITY.md documents this. Ported from the fork ostermayer/nix-bitcoin. NVD serves the yearly 2.0 feeds at a few tens of KB/s to anonymous clients, and vulnix aborts after 10 s without data and discards the partial update. The workflow caches ~/.cache/vulnix between runs, so a run normally fetches only the `modified` feed, and the script retries the scan up to five times to ride out short stalls. Assisted-by: Codex (GPT-6)
The first version searched for a tracking issue by title, opened one on findings and closed it on a clean scan. A title search matches words and takes the first hit, so it could overwrite and close a human's issue, and the same findings produced a comment every week. Every run now writes the summary to the step summary and uploads it as an artifact. When the CVE_SCAN_ISSUE repository variable holds the number of a pinned issue, test/ci/cve-report.sh keeps that issue current: it stores the sorted set of active CVEs in an HTML comment in the body, writes nothing when the set is unchanged, and on a change posts one comment listing new and resolved CVEs before it rewrites the report part of the body. Everything above the <!-- cve-scan-report --> line is left to people. The script never creates, closes or labels issues. The variable reaches the script through the environment and must be digits. cve-scan.sh writes the set as cve-set.txt and now requires the vulnix fields instead of substituting empty arrays, so a malformed report fails the job rather than resolving every tracked CVE. SECURITY.md describes where the report goes and how a finding is triaged. Assisted-by: Codex (GPT-6)
Add offline fixtures for the scanner and issue reporter as a flake check. Evaluate the representative scan node in check_flake so module changes cannot silently break the scheduled target. Assisted-by: Codex (GPT-6)
Run on Mondays and Thursdays so ordinary runs stay within the strict seven-day limit for incremental NVD updates. Document that cold caches and longer gaps still need the yearly feeds. Assisted-by: Codex (GPT-6)
Ignore stored sets above the report marker when comparing findings or detecting initialization. Recover from a deleted marker without overwriting human text or repeating notifications on later runs. Assisted-by: Codex (GPT-6)
Diff package/CVE identities so upgrades do not report an unfixed CVE as resolved and new. Count each identity once across vulnerable versions, while preserving version details in the stored report and artifacts. Assisted-by: Codex (GPT-6)
Remove the new whitelist and workflow entries and the corresponding documentation claim. The scan scripts and node definition also determine findings, so ownership of only two files does not cover the reporting behavior. Assisted-by: Codex (GPT-6)
Describe newly published CVEs and corrected affected-version ranges as reasons findings change even when package pins stay the same. Assisted-by: Codex (GPT-6)
yeah, let's try this - rebased the PR and added 6 more commits suggested by Astra (some of them implementing your suggestions) |
seberm
left a comment
There was a problem hiding this comment.
@prusnak thanks, the six commits look good. I'll probably also create a pinned issue for CVE_SCAN_ISSUE so we can test that part of the feature too.
Opus 5.5 review:
One thing for later, not blocking: since the compare ignores versions, a pin bump that changes only package versions writes nothing to the issue. The body then shows the old versions and the old scan date until the package/CVE pairs change (test_version_only_change_does_not_notify checks for exactly that). Notifications are right, but someone reading the pinned issue can't tell how current it is.
Suggested fix: when the versioned set changes but the pairs don't, rewrite the report part of the body without a comment. Body edits don't notify anyone. Alternatively, say in the report that the date is the last change, not the last scan.
|
Tracking issue created here: I've configured the Testing the cve-scan workflow here: |
|
@ostermayer the scan works. I opened #159 for triaging the first findings. Would you take a first pass? |
…ange (#162) cve-report.sh wrote nothing to the pinned tracking issue when the set of package/CVE pairs was unchanged. After a pin bump that only moved versions, or after a plain rerun, the body kept the old versions and the old scan date, so nobody could tell how current it was. The script now renders the new body first and compares it with the stored one. Different pairs: one comment, then the body edit, as before. Same pairs and a different body: the body is edited without a comment. Same body: nothing is written. Trailing newlines don't count as a change, because gh prints one that the stored body doesn't have. The summary carries the scan time, so every completed scan now refreshes the body. Body edits don't notify anyone; comments still go out only when the pairs change. A failed scan leaves the body as it was. An oversized set now fails the job even when the pairs didn't change. SECURITY.md says the body shows the last run. Tests cover the refresh, idempotence and that the part above the marker survives. Follow-up to #63.
Refs #16 (section 5)
Problem
bitcoinix has no routine check for known CVEs in the software it deploys. The project ships NixOS modules rather than a flat package set, so a package-level scan misses what a node really runs, and a scan of a test-derivation closure reports build tools that never run on a node.
Change
test/ci/scan-node.nixbuilds a representative node: the secure-node and WireGuard presets plus bitcoind, clightning (with clnrest and encrypted replication), lnd, charge-lnd, electrs, fulcrum, btcpayserver (lnd backend), mempool, rtl (both node interfaces), backups and nodeinfo. Hardware wallets are host tooling, so they're left out.test/ci/cve-scan.shbuilds that node and runsvulnix --closureon its system toplevel, which is the RUNTIME closure (nix path-info -r). Without--closurevulnix scansnix-store -qRof the deriver, the build closure, which is what the fork's version did, and its whitelist of compilers was masking that. The script fails closed: a failed build, a vulnix error exit, or a report that isn't a JSON array of well-formed entries fails the job and never reads as a clean scan. The per-package CVSS shown in the summary is the max over the non-whitelisted CVEs only..github/cve-whitelist.tomlcontains only vulnix pname collisions (git, dash, snappy, uuid), each scoped to explicit CVE ids, and no blanket pname entries. The fork's[nix]entry for CVE-2024-27297 is dropped, because it was meant for the Rustnixcrate, which isn't in a runtime closure, and it would've masked a real Nix package-manager finding..github/workflows/cve-scan.ymlruns the scan every Monday and on demand. Every run writes the summary to the step summary and uploads the report as an artifact. If the repository variableCVE_SCAN_ISSUEholds the number of a pinned tracking issue,test/ci/cve-report.shkeeps the part of that issue's body below a<!-- cve-scan-report -->line current and leaves everything above it to people. It stores the sorted set of active CVEs in an HTML comment in the body, writes nothing when the set is unchanged, and on a change posts one comment listing the new and the resolved CVEs. It never opens, closes or labels issues. The variable reaches the script through the environment and has to be digits. The workflow only reads thebitcoinixCachix cache, has no signing key, pins actions by commit SHA, and isn't part ofci_gate. It caches~/.cache/vulnixbetween runs, because NVD serves the yearly feeds at a few tens of KB/s to anonymous clients and vulnix gives up after 10 s without data and discards the partial update, so a cold run from a slow connection fails outright. With the cache a run fetches only themodifiedfeed, and the script retries the scan up to five times to ride out short stalls.SECURITY.mddescribes the scan, where the report goes, who triages it and what a whitelist entry needs..github/CODEOWNERScovers the whitelist and the workflow, because a whitelist edit can hide a real finding and should get the same review as the release tooling.Ported from the fork
ostermayer/nix-bitcoinwith the--closurefix.Testing
./test/ci/cve-scan.shon a Linux box with Nix, this branchfound=true, summary written./test/shellcheck.shtest/ci/cve-report.shagainst a stubbedgh, 12 scenarios (fresh issue, unchanged set, CRLF body, changed set with a human edit kept, clean after findings, markerless issue with a clean scan, non-numeric variable, failedgh issue view, oversized comment and body)bash -n, YAML parse of the workflowThe first real run reported 22 store paths with non-whitelisted CVEs at the pin of that time: glibc, perl, zlib, openssl 3.5.8, sqlite, openssh 10.5p1, dbus, dhcpcd, jq, nghttp2, coreutils, cups, avahi, libusb, busybox, ada (the URL parser linked into Node.js, used by rtl and mempool), plus
gcc(CVE-2023-4039) andpatch. The last two are in the runtime closure becauselibgccshares thegccderivation and some package keeps a reference topatch. Neither runs on a node, but I left them reported rather than whitelisting a whole pname. That list is the expected shape of the first tracking issue, and most entries are nixpkgs-wide and get fixed by moving the pin.A cold run on a KVM host on 2026-10-22 failed five times in a row on the NVD download, which is what the cache step is for. The scan node itself evaluates and builds on current master.
Models used on this PR: Fable 5.1 and Opus 5.5 for the changes. Kimi K3, GLM 5.3 and DeepSeek V4.1 Flash 1017, all at max thinking, and GPT-6 Astra at xhigh reasoning reviewed earlier revisions in the audit runs over the open branches and found no problem in the changed files. Fable 5.1 made the 2026-10-22 revision (rebase, the scan node without the removed services, the cache and the retries), and Astra reviewed it: it corrected my claim that retries resume a download, and found nothing else. DeepSeek and GLM, both at max thinking, reviewed the tree of this revision and found nothing in the workflow, the script, the scan node or the whitelist. Their two findings elsewhere are master code that #25, #48 and #133 already cover.
The second commit (3a3fbb5) replaces the issue search, create and close logic after seberm's review. Fable 5.1 planned it, Opus 5.5 wrote the first draft, Codex (GPT-6 Astra, xhigh) reviewed the uncommitted diff and found five real problems that were fixed before the push, GLM 5.3 (max) reviewed the tree at 3a3fbb5 and found nothing in the files this PR touches, and DeepSeek V4.1 Flash 1017 (max) timed out at the provider and gave no result.