- Python 81%
- Nix 8%
- Jinja-like 8%
- CSS 3%
nixray #
Vulnerability management for NixOS. nixray runs vulnix against your system closure, keeps every result in PostgreSQL and gives you a web UI to
- see what is vulnerable right now, by severity, separating the running system (runtime) from packages only used to build it (build-time),
- review new findings: confirm them as real or mark them as false positives (with scope, reason, optional review date and an audit trail), optionally pre-classified by the NixOS security tracker and, optionally, a language model that explains whether the CVE really applies to the package,
- see which findings an update of nixpkgs would fix, and since when that fix is available,
- see which vulnerable packages running processes have loaded, and which only an unrestarted service (or the kernel until a reboot) still runs after an update,
- spot CVEs that are exploited in the wild (CISA's Known Exploited Vulnerabilities catalog) or have a public exploit (Exploit-DB, Metasploit, Nuclei), and sort by the likelihood of exploitation (EPSS),
- follow the trend of vulnerabilities over time,
- see how long the system was exposed to each vulnerability.
Design documents: architecture · vulnix analysis · database · UI/UX
Deploy on NixOS #
# flake.nix of your server
{
inputs.nixray.url = "git+https://codeberg.org/pSub/nixray";
outputs = { nixpkgs, nixray, ... }: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
modules = [
nixray.nixosModules.default
{
services.nixray = {
enable = true;
web.trustedUserHeader = "X-Remote-User";
};
# Authenticating reverse proxy in front of the app. The app listens on a Unix socket only
# nginx can reach (web.proxyGroup), so no local user can go around the proxy.
services.nginx = {
enable = true;
recommendedProxySettings = true; # keeps the Host header (needed for the CSRF check)
virtualHosts."nixray.example.org" = {
forceSSL = true;
enableACME = true;
basicAuthFile = "/run/secrets/nixray-htpasswd";
locations."/" = {
proxyPass = "http://unix:/run/nixray-web/web.sock";
extraConfig = "proxy_set_header X-Remote-User $remote_user;";
};
};
};
}
];
};
};
}
Remote deployments: vulnix needs the system's
.drvfiles. If you build on another machine and copy the closure to the server, see the deployment caveat.
This creates a local PostgreSQL database with peer authentication and the hardened systemd units
nixray-migrate, nixray-scan (+ timer, twice a day) and nixray-web. To scan right away,
run systemctl start nixray-scan.
CLI #
nixray migrate # create/upgrade the schema
nixray scan # run vulnix and record the result
nixray scan --from-json FILE [--closure-json FILE]
# ingest captured `vulnix --json` (and `--closure`) output
nixray scan --host NAME ... # record the scan for another host (default: NIXRAY_HOST)
nixray scan --host NAME --remote USER@HOST
# fetch the scan over SSH from `nixray report` on that host
nixray report # run vulnix, print the result for a central nixray (no database)
nixray processes --output FILE # record what running processes have loaded (needs CAP_SYS_PTRACE)
nixray upstream-check [--host NAME] [--from-json FILE [--ref REF]]
# scan the configuration with a newer nixpkgs: what would an update fix?
nixray tracker-sync [--limit N] # look up current CVEs in the NixOS security tracker
nixray judge [--limit N] # let a language model judge the findings to review
nixray kev-sync # download CISA's known exploited vulnerabilities
nixray epss-sync # download FIRST's EPSS scores
nixray exploit-sync # download public exploits (Exploit-DB, Metasploit, Nuclei)
nixray cve-sync [--limit N] # look up the CVE records of current CVEs (CVSS where NVD has none)
nixray euvd-sync [--limit N] # look up the EUVD entries (ENISA) of current CVEs
nixray debian-sync # download the Debian security tracker's verdicts
nixray serve [--host H] [--port P]
Configuration is read from environment variables: NIXRAY_DATABASE_URL (libpq string, default
dbname=nixray), NIXRAY_VULNIX, NIXRAY_VULNIX_CACHE_DIR, NIXRAY_VULNIX_MIRROR, NIXRAY_SCAN_TARGETS
(default --system), NIXRAY_SCAN_TIMEOUT, NIXRAY_TRUSTED_USER_HEADER, NIXRAY_ALLOWED_HOSTS (host names besides localhost the web interface answers to), NIXRAY_LISTEN_HOST,
NIXRAY_LISTEN_PORT, NIXRAY_LISTEN_SOCKET (a Unix socket instead of host and port), NIXRAY_TRACKER_URL, NIXRAY_TRACKER_TOKEN_FILE, NIXRAY_LLM_PROVIDER,
NIXRAY_LLM_API_KEY_FILE, NIXRAY_LLM_MODEL, NIXRAY_LLM_URL, NIXRAY_JUDGE_REQUEST_FILE,
NIXRAY_NOTIFY_FILE, NIXRAY_SSH_KEY_FILE, NIXRAY_UPSTREAM_FLAKE, NIXRAY_UPSTREAM_INPUT,
NIXRAY_UPSTREAM_REF, NIXRAY_UPSTREAM_HOSTS (name=attribute …), NIXRAY_LOADED_PATHS_FILE, NIXRAY_HOST (the host scans are recorded for and the web interface
shows; default: the machine's hostname).
Several hosts #
One nixray installation can keep the history of several machines. The central host fetches scans from the others over SSH; they need neither the database nor the web interface:
# on web2: the agent. The central host's key may run `nixray report` there and nothing else.
services.nixray.agent = {
enable = true;
authorizedKeys = [ "ssh-ed25519 AAAA… nixray@central" ];
};
# on the central host
services.nixray = {
enable = true;
remoteHosts.web2.destination = "nixray@web2.example.org";
remoteKeyFile = "/run/secrets/nixray-ssh-key"; # the matching private key
};
programs.ssh.knownHosts."web2.example.org".publicKey = "ssh-ed25519 AAAA…"; # pinned host key
Each remote host gets a nixray-scan-<name> timer on the scan schedule (and its own
notifications). An unreachable host is a failed scan: its findings stay open until it reports
again. Every agent runs vulnix itself, with its own NVD download (scan.mirror applies there too).
nixray scan --host NAME --from-json FILE records captured output by hand instead. Once there
is more than one host, the overview starts with a summary of all hosts, and the review inbox
covers all of them (false-positive marks, confirmations, tracker advice and LLM judgements are
about a package and apply on every host). Findings, exposure, scans and CVE pages show one host,
chosen in the header.
Notifications #
Off by default. services.nixray.notify.command is a shell command that gets a plain-text
message on stdin when a scan finds new open runtime findings (known false positives and
build-time findings are left out) or when a scan fails, e.g.
services.nixray.notify.command = "${pkgs.curl}/bin/curl -sSf --data-binary @- https://ntfy.sh/my-topic";
# or: "${pkgs.mailutils}/bin/mail -s nixray admin@example.org"
It runs as the nixray user in its own units (nixray-notify, nixray-notify-failure),
outside the scan's sandbox.
Running processes: restart needed? #
Off by default. services.nixray.processes.enable = true; (on the central host and on each
agent) adds a nixray-processes job that records which store paths running processes have
mapped (/proc/<pid>/maps) and which kernel was booted. It runs before each local scan and
every 30 minutes, with only CAP_SYS_PTRACE (needed to read other users' processes) and no
network. The scan lets vulnix match those paths' derivations, so:
- findings get a loaded by nginx.service tag: a running process uses the vulnerable code,
- a finding stays open after an update until the last process that still has the old version is restarted, tagged restart needed (or reboot needed for the kernel); the findings list filters by both, and the overview counts them.
A scan refuses data older than two hours rather than resolve findings of processes it no longer sees. Update the central host before its agents: an older one rejects their reports. See ADR-17 in docs/architecture.md.
Would an update fix it? #
Off by default. Point nixray at the flake with your hosts' configurations and the nixpkgs you would update to:
services.nixray.upstream = {
enable = true;
flake = "git+https://codeberg.org/me/infra"; # or e.g. "path:/etc/nixos"
ref = "github:NixOS/nixpkgs/nixos-25.11"; # what `input` (default: nixpkgs) is overridden by
# hosts = { web2 = "web2-prod"; }; # default: this host and remoteHosts, same names
};
A twice-daily nixray-upstream-check timer evaluates each host's
nixosConfigurations.<host> with that nixpkgs, without building it, and scans it with vulnix.
Open findings whose CVE it no longer reports in the package get a fix available since … tag
(the first check that showed the fix after the finding appeared), the others no fix upstream
yet. The findings list filters by it, and the overview shows how many findings an update
fixes. The flake and the nixpkgs are fetched as the nixray user (no access to /home), so a
private repository needs credentials nix can use. Nothing about the hosts is sent. In CI,
scan the updated system yourself and record it with
nixray upstream-check --host NAME --from-json FILE --ref REF (REF: what nixpkgs was
overridden by, so it counts as a check of the same target). See ADR-16 in
docs/architecture.md.
Pre-classification from the NixOS security tracker #
Off by default. services.nixray.tracker.enable = true; adds a twice-daily
nixray-tracker-sync timer that looks up the CVEs of current findings in the
tracker and shows its decisions as hints in the review inbox. Only CVE
identifiers are sent, but the set of looked-up CVEs approximates the host's
vulnerable software. An optional tracker.tokenFile (a personal API token)
raises the rate limit. Pull advice now in the review inbox triggers the same
sync on demand (via a systemd path unit; the web process stays offline). The
tracker currently only knows CVEs published since 2026. See docs/tracker.md.
Known exploited vulnerabilities #
Off by default. services.nixray.kev.enable = true; adds a daily nixray-kev-sync timer that
downloads CISA's Known Exploited Vulnerabilities
catalog; findings whose CVE is in it get an exploited tag. The whole catalog is downloaded, so
nothing about the host is sent.
Exploit prediction (EPSS) #
Off by default. services.nixray.epss.enable = true; adds a daily nixray-epss-sync timer that
downloads FIRST's EPSS scores: the probability that a CVE is
exploited in the next 30 days. The findings list gets an EPSS column to sort by and a filter
(≥ 1 %, 10 %, 50 %); the CVE page shows the score. The scores of all CVEs are downloaded, so
nothing about the host is sent.
Public exploits #
Off by default. services.nixray.exploits.enable = true; adds a daily nixray-exploit-sync
timer that downloads the public exploits of Exploit-DB,
Metasploit and
Nuclei. Findings whose CVE has one get a
public exploit tag, the CVE page links each of them, and the findings list can be filtered to
them. The whole collections are downloaded, so nothing about the host is sent.
CVE records (CNA data and CISA Vulnrichment) #
Off by default. services.nixray.cveRecords.enable = true; adds a twice-daily nixray-cve-sync
timer that looks up the CVE records of current CVEs. Where NVD has no
CVSS score yet, the CNA's or CISA's score sets the severity (marked with *). The CVE page also
shows the CWE and CISA's SSVC decision (exploitation, automatable, technical impact), and CVEs
rejected by their CNA get a rejected tag, which points towards a false positive. Only CVE
identifiers are sent, but, as for the tracker, the set of looked-up CVEs approximates the host's
vulnerable software. It cannot find CVEs that NVD has not analysed yet: vulnix matches packages
by NVD's data, so those are never reported by a scan. See ADR-13 in
docs/architecture.md.
European Vulnerability Database (EUVD) #
Off by default. services.nixray.euvd.enable = true; adds a twice-daily nixray-euvd-sync timer
that looks up the CVEs of current findings in ENISA's EUVD. The
CVE page links each CVE's EUVD entry (e.g. EUVD-2024-31700), and CVEs ENISA knows to be
exploited get the exploited tag, like those in CISA's KEV catalog. Only CVE identifiers are
sent, but, as for the tracker, the set of looked-up CVEs approximates the host's vulnerable
software. See ADR-14 in docs/architecture.md.
Debian security tracker #
Off by default. services.nixray.debian.enable = true; adds a daily nixray-debian-sync timer
that downloads the Debian security tracker's verdicts.
Findings get a Debian: … hint with Debian's reason: not for us (the CVE is about software
Debian does not ship, a typical vulnix false positive such as a Drupal module named like the
Haskell library Diff), not affected, minor issue, open or fixed in a Debian version
(a Debian revision, often a backported patch, so only context for nixpkgs). Like the tracker's
advice, it is a hint, never a decision. The whole CVE list is downloaded, so nothing about the
host is sent. See ADR-15 in docs/architecture.md.
Dashboard API #
GET /api/summary returns the headline numbers as JSON (open runtime findings): actionable,
by_severity, exploited, needs_review, suppressed, outdated_hosts, and per host in
hosts also new_since_previous, resolved_since_previous, last_success and stale. It sits
behind the same reverse proxy as the UI, so the client must authenticate there. For
Glance:
- type: custom-api
title: nixray
title-url: https://nixray.example.org
url: https://nixray.example.org/api/summary
headers:
Authorization: Basic ${NIXRAY_BASIC_AUTH} # base64 of user:password
cache: 15m
template: |
<div class="flex justify-between text-center">
<div><div class="color-highlight size-h3">{{ .JSON.Int "actionable" }}</div><div class="size-h6">OPEN</div></div>
<div><div class="color-negative size-h3">{{ .JSON.Int "by_severity.critical" }}</div><div class="size-h6">CRITICAL</div></div>
<div><div class="size-h3">{{ .JSON.Int "by_severity.high" }}</div><div class="size-h6">HIGH</div></div>
<div><div class="color-negative size-h3">{{ .JSON.Int "exploited" }}</div><div class="size-h6">EXPLOITED</div></div>
<div><div class="size-h3">{{ .JSON.Int "needs_review" }}</div><div class="size-h6">TO REVIEW</div></div>
</div>
{{ if gt (.JSON.Int "outdated_hosts") 0 }}<p class="color-negative">{{ .JSON.Int "outdated_hosts" }} host(s) without a recent scan</p>{{ end }}
Pre-classification by a language model #
Off by default. services.nixray.judge = { enable = true; apiKeyFile = "/run/secrets/…"; };
adds a twice-daily nixray-judge timer that asks a language model (first provider: Mistral)
whether each finding to review really applies to its package. The review inbox, findings list
and CVE page show the verdict together with the model's reasoning, the inbox can be filtered
by verdict and Judge now runs it on demand; nothing is decided automatically. CVE details, package names and versions are sent to the provider. See
docs/judgement.md.
Demo #
nix run .#demo # seeded from the bundled test fixture
vulnix --system --json > scan.json # or use your own system's findings …
nix run .#demo -- ./scan.json 90 # … replayed over the last 90 days
vulnix --closure /run/current-system --json > closure.json
nix run .#demo -- ./scan.json 90 ./closure.json # … split into runtime and build-time
Starts a throw-away PostgreSQL (Unix socket only, in $XDG_RUNTIME_DIR), seeds it with
simulated history (twice-daily scans, deployments, remediations, one failed scan, known false
positives, and three more hosts with the same CVEs in other roles: a build server, a web
server whose scans sometimes fail and an outdated gateway) via scripts/demo.py, and serves the UI on http://127.0.0.1:8411
(NIXRAY_LISTEN_PORT to change). Ctrl-C stops everything and deletes the database.
The demo starts with real tracker decisions recorded in tests/fixtures/tracker/.
Pull advice now in the review inbox then queries the live NixOS security
tracker for the demo's CVEs (identifiers only, about 2 seconds each); nothing is
contacted unless you click it. Set NIXRAY_TRACKER_URL to use another tracker (https://, or http:// only on loopback).
What EPSS, CISA's KEV, Exploit-DB, Metasploit, Nuclei, the CVE records (with CISA's
Vulnrichment), ENISA's EUVD and the Debian security tracker said about the demo's CVEs is recorded in
tests/fixtures/enrichment.json and stored as their sync jobs would; the outdated gateway still
runs glibc 2.37, affected by the exploited Looney Tunables (CVE-2023-4911). Two examples are
constructed because the real data has none: one CVE without NVD score (its CVE record's score
fills the gap) and one CVE rejected by its CNA (see scripts/demo.py).
It also shows hand-written example LLM judgements; with NIXRAY_LLM_PROVIDER=mistral
and NIXRAY_LLM_API_KEY_FILE set, Judge now judges the remaining findings live.
nix build .#demo builds the launcher without running it.
Development #
nix develop
pytest # unit, web, architecture and Postgres integration tests
ruff check src tests && ruff format --check src tests && mypy && pylint src tests scripts
nix flake check # everything above but pylint, plus a NixOS VM test of the module (needs KVM)
Architecture rules (dependency direction, isolated adapters, framework-free core) are executable
tests in tests/architecture/ using PyTestArch.