Skip to content

ci: scan with a vulnix that reads patches from structured attrs - #165

Merged
seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:cve-scan-vulnix-pin
Oct 29, 2026
Merged

seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:cve-scan-vulnix-pin

Conversation

@ostermayer

Copy link
Copy Markdown
Collaborator

Follow-up to the first scan in #157. Ten of the 62 reported pairs were the libssh2 CVEs, and nixpkgs carries a CVE-named patch for each of them at our pin. vulnix 1.12.4 didn't see them: it reads patches only from the plain derivation environment, and libssh2 is built with __structuredAttrs, which keeps patches in the __json variable. Every package nixpkgs moves to structured attrs gets the same false positives.

Upstream fixed it in nix-community/vulnix@3596c69 on 2026-10-19. The last release, 1.12.5, is from 2026-07-31, so no release has it.

What changed:

  • test/ci/vulnix.nix: the nixpkgs vulnix package with overrideAttrs swapping the source for upstream commit 525eb2c (2026-10-26, includes the fix and an NVD download retry). Same build recipe and tests as nixpkgs, pinned by hash. The comment says when to drop the file.
  • test/ci/cve-scan.sh runs nix shell --impure -f test/ci/vulnix.nix instead of nixpkgs#vulnix. The second commit updates the two comments about NVD timeouts to what the pinned vulnix does: five attempts per feed with a 60 s read timeout, and the outer loop covers a feed that fails all of them.
  • The check_flake job evaluates vulnix.nix next to the scan target, so a broken pin fails CI before the Monday run.

Tested

  • I ran the cve-scan.yml workflow on the first commit in my fork: https://github.com/ostermayer/bitcoinix/actions/runs/40563471734. vulnix built, the scan completed, and libssh2 is gone from the report. 21 store paths and 58 set lines instead of 22 and 68, nothing else changed.
  • On the KVM host, vulnix 1.12.4 run by hand on the same libssh2 outputs still reports all ten, and nix derivation show on those derivations lists all ten CVE-named patches. That's the bug reproduced and the fix confirmed.
  • python3 test/ci/cve-tests.py test/ci: 26 stub tests pass. bash -n and YAML parse pass.

Codex (GPT-6 Astra, xhigh) reviewed the first commit and found the two stale timeout comments, fixed in the second, and nothing else. The Nix modules aren't touched, so the GLM 5.3 (max) audit of the tree at bacf78d is for completeness: four findings in modules/, none in the files this PR touches. Astra confirmed three (#87, #133, and electrs enabling bitcoind REST, which the configuration tests already pin down as intended) and marked the backup one a false positive. DeepSeek V4.1 Flash 1017 wasn't run on this CI-only change.

@github-actions github-actions Bot added the area: ci .github/, test/, dev/ label Oct 27, 2026
@seberm seberm added the type: maintenance No user-visible change: refactor, CI, deps, tooling, docs-only label Oct 27, 2026

@viberaven viberaven left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actionable findings at dda6f7a.

Reviewed the scanner override, structured-attribute patch detection, scan invocation, and CI changes. The scanner derivation evaluates, its source fetch passes the pinned hash check, all 26 CVE-tool tests pass with jq available, and cve-scan.sh passes bash syntax checking.

I did not build the complete scanner or rerun the full node/NVD scan locally.

Review performed with Codex (GPT-6 Astra).

vulnix 1.12.4 from nixpkgs reads `patches` only from the plain derivation
environment. Packages built with __structuredAttrs keep it in __json, so
the first scan reported all ten libssh2 CVEs although nixpkgs carries a
CVE-named patch for each one, and the same will happen to every package
nixpkgs moves to structured attrs.

Upstream fixed this in nix-community/vulnix@3596c69, which is in no
release yet. test/ci/vulnix.nix takes the nixpkgs package and swaps in
the upstream source at a pinned commit, and cve-scan.sh runs that. The
check_flake job evaluates it next to the scan target.
The pinned vulnix retries each feed download up to five times with a 60 s
read timeout before it gives up. The two comments still described the
10 s single attempt of vulnix 1.12.4.
@seberm
seberm force-pushed the cve-scan-vulnix-pin branch from dda6f7a to be9ab46 Compare October 29, 2026 13:31

@prusnak prusnak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sebsgent sebsgent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested at be9ab46, looks good to merge.

  • Reproduced the bug: two of the four libssh2 derivations in the scan closure use __structuredAttrs. Loaded through vulnix's derivation.load, 1.12.4 finds 0 of their 10 CVE patches and the pinned build finds 10/10. The two plain derivations are 10/10 with both versions.
  • nix build --impure -f test/ci/vulnix.nix builds, the hash matches, and upstream's 119 tests pass. 525eb2c is upstream master HEAD and includes 3596c69.
  • cve-tests.py (29 tests) and shellcheck pass. CI is green, and check_flake runs the new eval step.
  • The retry comments match upstream's code: 5 attempts, a (10, 60) s timeout and doubling backoff.
  • I didn't run a full NVD scan; for the end-to-end result I relied on the fork run.

Review performed with Claude Code (Opus 5.5).

@seberm
seberm merged commit 1961248 into bitcoinix:master Oct 29, 2026
11 checks passed
@ostermayer
ostermayer deleted the cve-scan-vulnix-pin branch November 8, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ type: maintenance No user-visible change: refactor, CI, deps, tooling, docs-only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants