CVE Remediation Guide & Workflow for Flake-based Nix Systems#
This guide provides a general workflow for identifying, assessing, and remediating CVEs (Common Vulnerabilities and Exposures) in a Nix flake-based infrastructure, leveraging the tools and scripts provided in this repository.
1. Vulnerability Scanning#
- Run a scan:
- Both
just vulscanand the manual command below scan the closure linked by the./resultsymlink, so build the system closure first if it does not already exist:nom build .#nixosConfigurations.<host>.config.system.build.toplevel - Use the
vulnixtool to scan your system’s Nix store for known vulnerabilities:just vulscan # or nix run nixpkgs#vulnix -- -j -w whitelist.toml $(nix-store --query --deriver ./result) > vulnix.json -
This produces a machine-readable
vulnix.jsonfile with all detected CVEs. -
Generate reports:
- Use the provided script to generate human-readable reports:
python3 ./scripts/vulnix-report-gen.py vulnix.json -f markdown -o vulnerabilities-report.md python3 ./scripts/vulnix-report-gen.py vulnix.json -f terminal -o vulnerabilities-report.txt --no-color python3 ./scripts/vulnix-report-gen.py vulnix.json -f json -o vulnerabilities-report.json
2. Review & Prioritize#
- Executive summary:
- Review the summary in the generated reports for counts and severity distribution.
- Detailed findings:
- Focus on packages with
CRITICALandHIGHCVEs first. - Review package names, versions, and associated CVEs.
3. Remediation Workflow#
- Update Packages:
- Update the affected package(s) in your flake inputs or overlays.
- Rebuild the system:
nix flake update ./scripts/system-flake-rebuild.sh # or your preferred rebuild command - Patch or Replace: - If no upstream fix is available, consider patching the package or using an alternative. - Document any temporary mitigations.
- Whitelist (if necessary):
- If a CVE is a false positive or not applicable, add it to
whitelist.tomlwith justification.
4. Verification#
- Re-scan:
- After remediation, re-run the scan and regenerate reports to confirm resolution.
- CI Integration:
- These steps are already wired into the
.github/workflows/cve.ymlworkflow (“CVE Scanning and SBOM Generation”), which builds themokousystem closure, runs vulnix withwhitelist.toml, extracts critical CVEs (CVSS > 7.0), generates an SBOM via sbomnix, uploads the results as artifacts, and comments on pull requests. - Its
pushandpull_requesttriggers are currently commented out, so today onlyworkflow_dispatchis active — the workflow runs manually rather than automatically on every change.
5. Documentation & Audit#
- Track changes:
- Commit updated reports and remediation notes to version control.
- Audit trail:
- Use the markdown and JSON reports as artifacts for compliance and audits.
6. Automation#
- Use the
justtasks and scripts in this repository to automate scanning, reporting, and basic remediation steps. Thesecuritygroup provides: just vulscan— scan./resultwith vulnix and writevulnix.jsonpluscritical_cves.json(CVSS > 9).just critical-cves— print a human-readable report of the critical CVEs.just critical-dependence-tree— generate a dependency tree (why-depends) for each critical CVE to aid remediation.just vulstats— analyze CVSSv3 score trends across the history ofvulnix.json.just sbom <host>— generate an SBOM for the given system configuration via sbomnix.- See
justfileandmodules/flake/programs/shell.nixfor available commands and shells.