Repository navigation
Fleet mode: agents report to a central server, with a Fleet view in the desktop app - #18
Merged
Merged
Conversation
Scanning dependency files and scanning this computer each built their Inventory inline, right before sending it to OSV and NVD. Fleet mode needs the same inventory on a machine that contacts no vulnerability source, so the two builders are now functions of their own: service::deps_inventory and host::inventory. The scans call them, and their output is unchanged. Inventory, CpeProduct, KnownCve and NotChecked now fill missing fields with their defaults when read, so an inventory written by an older build still loads after a field is added. A package still needs its name, ecosystem and version.
A scan diff reports a finding as riskier when it entered CISA KEV, gained an exploit, jumped in EPSS or rose to a higher risk label. That is right for two scans that saw the same sources. It is wrong when one of them could not read a source: every KEV-listed finding then reads as newly listed the next time the catalog loads. A server re-checking many machines would send that as alerts. diff_with takes a DiffPolicy that leaves out the escalation kinds whose source was missing, a risk label that rose between scans scored differently, and a rise from a record whose advisory could not be read. diff is diff_with under the default policy, so saved scans compare as before. What is new or resolved never depends on the policy. The subject keys a scan could not check were worked out inside ScanStore::record; unchecked_keys now does it, for other callers too.
The lookup cache dropped expired rows, and everything past its 10,000-row cap, only when it was opened. That suits the app and the CLI, which restart often. A process that stays up for weeks never prunes, and its cache file keeps growing. Cache::prune does the same clean-up at any time; opening the cache calls the same code.
The first part of fleet mode: small agents on other machines report what is installed there, and a central server does the vulnerability work for all of them. Nothing uses these modules yet. fleet::token makes and recognises the three credentials (an enrollment code, an agent token, a viewer token). A Secret shows as a fingerprint in Debug output and cannot be serialized, and the server will store only its SHA-256. fleet::protocol holds the messages, a canonical form and hash for an inventory (so an unchanged machine sends a hash, not its package list), the decoder for request bodies (gzip stops at the size limit), and sanitize: the rules an inventory from an agent must pass. A reporting machine may be the one that was broken into, so an inventory cannot bring findings of its own, is refused rather than cut when it is too large, and has everything that is only shown cleaned and bounded. The token fingerprint moves here from cve-server's auth module, which re-exports it, and the hidden terminal prompt moves to cve_core::term so a second binary can use it. ring becomes a direct dependency of cve-core for random bytes; it was already in the build as rustls's crypto provider.
fleet.db is the central server's store. This part holds the hosts that report and the credentials they and the fleet's viewers present. A host joins with a one-time code made on the server. The code names the host, so the machine that redeems it cannot choose who it is. It works once and for 24 hours, and spending it and issuing the agent token happen in one transaction. Enrolling a host that already has a working token needs an explicit replace, which revokes the old token when the new code is used. Only the SHA-256 of a code or token is stored, and a listing never includes even that. A test reads the database files back and checks that no secret is in them. Nothing is cached, so revoking a token stops it at its next request. The file is created owner-only with secure_delete on, like the other databases, and with foreign keys on so that forgetting a host removes its credentials. The schema version is kept in user_version, and a file written by a newer build is refused instead of being guessed at.
The rest of the central server's core: taking in an agent's report, checking each inventory, and answering questions about the fleet. A report is taken target by target. The host comes from the token, never from the report. An inventory must pass sanitize; a refused target does not fail the others, and the reason is kept where a viewer can see it. A target the agent could not read keeps the inventory already held, so an unreadable folder is not taken for an empty one. A changed inventory is checked at once, but at most every 15 minutes per target. Every inventory is checked again at 03:00 UTC, one after another, so hosts running the same software share the hour-long lookup cache. That daily check is what notices a CVE entering CISA KEV on a machine where nothing changed. A scan that fails records nothing and is retried with a growing gap. evaluate compares a scan with the last check and decides the events. It is careful about what it calls news, because nobody is watching a server that checks hundreds of machines: - a source that could not be read in either check cannot make a finding newly exploited or riskier; - the first check of a target is one line, not one per finding; - a host that lists half its packages gets one line, not a hundred fixes; - each kind of event is capped per check, with the rest counted. Only the latest check of a target keeps its findings, in one compressed blob, with an index from every CVE and advisory ID to the hosts that have it. A host is stale after three of its own report intervals, at least an hour, not counting time the server itself was down. One server holds the database at a time, through a lease it renews. The scan runs behind a Scanner trait, so all of this is tested with a stand-in and no network. FindingFilter::keep becomes public for the fleet's findings query.
The test that looks for secrets on disk read the database, its log and its shared-memory file while the store was still open. Windows locks byte ranges of those files for an open connection, and CI runs there too. The store is now closed first, which also writes the log into the database file, so the checkpoint the test ran by hand is no longer needed.
FleetClient is what an agent enrolls and reports with, and what the desktop app and scripts will read the fleet with. The token travels in the Authorization header and nowhere else. The client does not follow redirects, because the token and the inventory would go along. It does not use a proxy for a server on the same machine. Plain http:// is accepted for this machine only, unless the caller says the network encrypts by itself (a tailnet). Host names, target keys and CVE IDs are checked before they become part of a path. A refusal is a typed error, so an agent can tell a revoked token from a busy server. The server's own error text is cleaned before it is shown, and a 5xx body is not passed on at all. An answer is read up to a size limit. Reports are sent gzip-compressed.
`cve-intel fleet serve` runs the central server: a listener for agents and viewers, and behind it the scheduler that checks inventories. The other `cve-intel fleet` commands enroll hosts, make and revoke tokens, and read the fleet (hosts, one host, which hosts have a CVE, events). The listener is separate from `cve-intel serve`, which answers any web page and gives every caller the same access. This one holds every host's software inventory: - Every path needs a fleet token, a path that does not exist included. Only GET /health and the enrollment call (which takes a one-time code) are open. The check is the outermost layer, so a route added later is behind it. - An agent token reports for its own host and reads nothing. A viewer token reads and reports nothing. - There is no CORS, and nothing is administered over HTTP. Enrolling, revoking and forgetting are commands on the server, which open the database directly. - It refuses to listen beyond loopback without TLS, unless told the network encrypts by itself. - A body is read only once the caller is known, within a size limit on the wire and after decompression, and within a time limit. Reports are stored a few at a time; more are told to come back. Each token has a request budget. - Errors are generic JSON; SQL errors and paths go to the log, not the caller. Tokens and codes are logged as fingerprints only, and a test reads the log back to check. One server holds the database. A second one waits to see whether the first still renews its claim, and stops if it does. SIGINT and SIGTERM release the claim, so a restart does not wait.
A new small program for the machines that report. It reads what its configuration names (dependency files under a folder, this machine's OS packages and apps) and sends that to the central server. It contacts no vulnerability source, never listens for a connection, and takes no instructions from the server: what it reads comes from its local configuration file only. cve-intel-agent enroll --server URL [--host-scan] [--deps [NAME=]PATH]… cve-intel-agent preview what a report would carry; sends nothing cve-intel-agent run [--once] cve-intel-agent status It is its own binary so that it stays small: 2.2 MB on macOS built with the new `agent` profile, against 24 MB for cve-intel. It links only the inventory readers, the fleet protocol and an HTTPS client, and must not use IntelService, the cache or a store. A CI step fails if it grows past 8 MB. On Linux it will be larger than on macOS, because reading an rpm database needs SQLite; that size has not been measured yet. The logic is in cve_core::fleet::reporter. A report is two steps: the hash of every target, then only the inventories the server asks for, one per request, so an unchanged machine sends about a kilobyte. A target that cannot be read (a folder that is gone, a package database that cannot be opened) is reported as that, never as an empty inventory. The server then keeps what it holds instead of concluding that everything was fixed. The enrollment code is typed at a hidden prompt or read from CVE_INTEL_FLEET_ENROLL_CODE, never passed as an argument. The token goes into a file only its owner can read, and a token file that other users can read is refused. An end-to-end test runs the real binary against the real fleet listener. toml becomes a direct dependency of cve-core for the configuration file; it was already in the lockfile.
…utes Trying the server and agent by hand showed two things the tests did not. After a fix was deployed and reported, the host went on showing the old findings with nothing to say a newer inventory had arrived. A changed inventory waited 15 minutes after the target's previous check, and the wait was invisible. Now the host is "checking" while any target has an inventory that has not been checked, and the host's detail says so, with when the check will run. The wait is 5 minutes, the shortest interval an agent may report at, so an agent on its normal schedule never meets it. It still stops a machine that rewrites a lockfile every minute from buying a scan a minute. Smaller things from the same run: the first check of a target is logged as that instead of as "0 new", the findings column is headed AFFECTS, and a host that is not Linux shows its OS family where it has no name to give.
With CVE_INTEL_FLEET_WEBHOOK_URL set, the central server posts the events worth interrupting someone for: new and riskier findings at or above CVE_INTEL_FLEET_WEBHOOK_MIN_RISK (HIGH unless set), anything in CISA KEV whatever its label, a host that stops reporting or comes back, and a check that keeps failing. The events table is the outbox. An event stays there until the webhook takes it, so a restart or an unreachable chat service loses nothing. One that fails is retried with a gap that doubles up to an hour, and given up on after a day. Turning alerts on later does not send the backlog. The body is JSON with a `text` field, which is what Slack and Mattermost incoming webhooks show, and the events as data. One vulnerability that is new on several hosts is one line naming them, because a CVE entering CISA KEV can touch a whole fleet at once. Host and package names are escaped so they cannot become markup or a mention. The webhook's address is its credential. It may carry a query string, which some services sign with, and it is never logged or put in an error beyond its host and port. Trying it by hand showed that a target's first check only counted as an alert when it had high-risk findings, whatever the threshold was set to. It is now offered whenever it found anything, and the threshold decides from its riskiest finding.
docs/fleet.md is the guide for whoever sets fleet mode up and runs it: how it works, the five steps to a first report, the commands that read the fleet, when machines are checked and what counts as a change, alerts, TLS and Tailscale, the security model, and a reference for the agent's file, the server's settings and the viewer API. examples/fleet has systemd units for the server and for the agent (a oneshot on a 15-minute timer, as an unprivileged user), an environment file and an agent configuration. A test loads that configuration with the agent's own parser, so the example cannot drift from what is accepted. The README gets a short Fleet mode section, a row in the command table and the new crate in its architecture. SECURITY.md gets a section on what an agent sends where, the credentials, fleet.db and the listener. .env.example lists the new variables, and CONTRIBUTING's pre-PR commands include the agent crate. The Tailscale commands follow Tailscale's documentation as of November 2026; they and the systemd units have not been run on a live tailnet or a Linux machine.
The address of a central server and a viewer token, in settings.db (table fleet_link, one row). A connection is saved only after the server has accepted the token, and what a UI is given holds the token's fingerprint, never the token. The row also remembers the newest fleet event the user has seen, and a poll counts the ones after it that need attention. The fleet client notes each request for the desktop app's activity log (host and path). Elsewhere that does nothing; the optimised agent grows by 16 KB.
Commands for the Fleet view: connect and disconnect, the overview (totals, hosts and the latest changes in one read), one host, a target's findings, which hosts a vulnerability is on, and older changes. The web view never sees the token or talks to the server itself. While a connection is saved the app looks at the server once a minute and tells the window how many changes need attention and whether the totals changed. That look is in the activity log only when it finds something new, or when the server stops or starts answering.
A view of the machines that report to a central server: the fleet's totals, every host and its state, one host's targets with their latest check and findings, which hosts a vulnerability is on, and recent changes. Plan fix on a finding opens the Remediation Lab for the version that host runs. The sidebar counts the changes since the user last looked. The view is its own script and stylesheet. index.html gains the sidebar entry, an icon, an empty section, the two tags and one line in show(); the mapping from a finding to the Lab is now one function the scan view shares.
…tion cve-core's edition.rs holds what sets two applications apart: the name, the data folder, where the lookup cache lives, the folders an early Windows build left behind, and the desktop bundle's identifier. The default build is the STANDARD row, CVE Intel exactly as released. The Cargo feature edition-fleet picks the FLEET row instead: "CVE Intel Fleet" (a working name), with everything under ~/.cve-intel-fleet, so the two can be installed side by side and never touch each other's files. The data folder, the cache's default path and the legacy-folder move read the table. The fleet edition moves nothing: those folders are CVE Intel's. The CLI's name, the MCP server's name and the OAuth resource name come from it too. Both rows are always compiled, so one test run checks both.
With --features edition-fleet the desktop app is another application: tauri.fleet.conf.json overlays the name, executable and identifier (CVE Intel Fleet, cve-intel-fleet, app.cve-intel.fleet), and build.rs applies it, so the feature alone decides what a plain cargo build produces. The Tauri CLI names the executable and makes the installer from the settings it reads itself, so it needs --config as well; given only half of the pair, the build stops and prints the command. The window keeps CVE Intel's name and folders built in, now in one object. In the fleet edition edition.js replaces them: on the sidebar, the About page, where the page names the data folders, and as the key in the MCP setup snippets, so an agent can have both applications configured. Tests hold tauri.conf.json to the released identity, the overlay to the edition table, and the settings compiled into each build to its edition.
Windows does not call a path without a drive absolute, so the tests' "/srv/storefront" was refused there, as it should be. The tests now use a path that is absolute where they run, and the example file, which is a Linux server's, is validated on Unix only.
A read of the listener before release found ways for one sender to cost the server or the other machines more than its share. Without a token: - An enrollment request was limited to 64 KB on the wire but inflated up to the limit of a report, 24 MB. It is now held to 64 KB inflated too. With one agent token: - A report took one of the four ingest slots before its body was read, so four bodies that trickled in kept every other machine out. The body is read first. A host sends one report at a time and has a budget for reports of its own, and both hold until the report is stored, also when the agent hangs up early. - A report listing more than 32 targets is refused as a whole. Each entry past the limit used to be answered and logged one by one. - A changed inventory always went before the daily re-checks, so a host that kept changing could keep everyone else's from running. The time those checks take is now owed to the daily ones, which go first until they have had as much. - Events are capped per host (20,000) before the cap on the whole table, so a host whose findings keep changing fills its own share. Enrollment codes: - A host has one code at a time: a new one withdraws the one before it. - Revoking a host withdraws a code made for it and not used yet, which used to let its holder enroll as that host again. Also: the server stops when its checks or alerts task ends, instead of answering while nothing is checked, and the agent sends an inventory once however often the server lists it as missing.
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CVE Intel checks one machine at a time. The first question in any incident is about all of them: which of our machines have this CVE? This PR adds fleet mode to answer it.
A small agent on each machine reports what is installed there. A central CVE Intel server keeps every machine's inventory, checks it when it changes and again every day, and records what is new, riskier or fixed. The desktop app gets a Fleet view that reads that server.
The agent sends an inventory and looks nothing up, so the machines need no internet access, and a library you deployed last month is still re-checked the morning it enters CISA KEV.
Nothing changes for anyone who does not use it: no listener is started, and the Fleet view is a connect form until a connection is saved.
What you get
cve-intel-agent, a new binary) reads dependency files and the OS package database offline, sends a hash of each inventory, and sends the inventory itself only when the server does not have it. It never listens and takes no instructions. About 2 MB on macOS.cve-intel fleet serve) has its own listener and its own database,fleet.db. It checks a changed inventory at once and every inventory daily at 03:00 UTC. Each check is compared with the one before: new, riskier (entered KEV, gained an exploit, jumped in EPSS, rose a label) or resolved.text; anything else readsevents): new and riskier findings above a threshold, anything in KEV, a machine that stops reporting, a check that keeps failing./api/v1/fleet, for scripts.The guide is docs/fleet.md: setup, when machines are checked, alerts, systemd units, TLS and a Tailscale recipe, and the security model.
How it is built
The logic is in
cve-core, in a newfleet/module; the adapters stay thin.scan::Inventoryas JSON, versioned (protocol: 1, with a frozen fixture). CycloneDX was not used because our reader drops lockfile and OS packages on the way back in.fleet/store.rs:fleet.dbwith hosts, credentials, enrollment codes, targets, checks, an index from CVE or advisory to host, and events. The events table doubles as the webhook outbox. One server per database, held by a lease.fleet/check.rs: a scheduler that takes changed inventories first, then the nightly sweep, and a pureevaluatethat turns two checks into events.fleet/client.rsandfleet/reporter.rs: what the agent and the desktop app use. The agent links only the inventory readers and an HTTPS client, and CI holds it to a size budget so it cannot quietly start linking the server.fleet/link.rs: the desktop app's saved connection.src-tauri/src/fleet.rs(commands and a once-a-minute check) andui/fleet.jswithui/fleet.css.index.htmlgets a nav button, an empty section and the tags.The server is careful about what it calls a change, because nobody is watching it:
Security
A machine that reports may be one that was broken into, so the server treats everything from an agent as untrusted.
/healthand redeeming a code, unknown paths included. The wrong kind of token gets 403.The limits in the fourth and fifth points were tightened after a read of the listener before this PR: the enrollment body used to inflate up to a report's limit without a token, and one agent could hold every ingest slot or keep the scheduler to itself. Each fix has a test.
Two limits that remain, both in the guide: nothing slows down an address that keeps sending requests without a token (they are turned away before the body is read), so the server belongs on a private network or behind a proxy; and alert text escapes
&,<and>as Slack asks, but a target's label is the agent's own words.Two things are stored unencrypted and documented as such:
fleet.dbon the server (a map of what is vulnerable where) and the viewer token in the desktop app'ssettings.db, beside the API keys. SECURITY.md covers both, and what an agent and the desktop app send.Things worth knowing before merging
serve, MCP, the desktop's local server and the tool list are unchanged.settings.dbgains one table.fleet.dbexists only wherefleet servehas run.deps_inventory,host::inventory),diff_withandunchecked_keysinscan_history,Cache::prune, serde defaults onInventory, and the hidden-prompt reader moved toterm.rs. The existing tests pass unchanged.cargo build --profile agent -p cve-agent); downloads are the first follow-up.ringandtomlwere already there through other dependencies.--features edition-fleet, see CONTRIBUTING.md). It is off by default and nothing ships it. What the default build takes from it: the app's names now come from one table (cve-core/src/edition.rs) instead of being written out in several places, with tests that hold them to the released values.Type of change
Also: new CLI commands (
cve-intel fleet …), a new binary (cve-intel-agent) and a new REST listener.Testing
cargo test -p cve-core -p cve-server -p cve-agent: 531 core and 55 server unit tests plus the integration tests, among them a new suite that drives the fleet listener over real sockets (no token, wrong kind of token, enroll then report then read, oversized, inflated and slow bodies, one report at a time, revocation, and a captured log with no token in it). No test touches the network.cargo fmt --all --checkand clippy with-D warningsare clean;cargo check -p cve-intel-desktoppasses. All of it also passes with--features edition-fleet.Not covered, so you know where to look first if something is off:
Follow-ups
Checklist
cve-core; adapters (CLI/REST/Tauri) stay thin.env.exampleare updated