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:
- 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 just rebuild # 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:
- Integrate these steps into your CI pipeline to catch regressions early.
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. - See
justfileandmodules/flake/programs/shell.nixfor available commands and shells.