- Python 79%
- Jinja-like 9%
- Nix 8%
- CSS 4%
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,
- 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 (which listens on 127.0.0.1:8411).
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://127.0.0.1:8411";
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 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 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_LISTEN_HOST,
NIXRAY_LISTEN_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_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 web interface shows a host selector in the header and a per-host
summary on the overview. Every page shows one host at a time; false-positive marks,
confirmations, tracker advice and LLM judgements are about a package and apply on all hosts.
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.
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.
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) 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.
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.