What may be claimed
For cpe-product the model must not write “we are vulnerable”. It has to say the product is present and the first step is to establish the version on the listed hosts.
case study · AI vulnerability monitoring in n8n
An n8n workflow pulls new CVEs from four sources, intersects them locally with an inventory of several thousand servers and computes priority from vulnerability weight and exposure. The AI model receives threats that are already matched and assesses them like an analyst. Whether a vulnerability affects us is decided by code, not by the model.
01 / starting point
The company runs several thousand servers, most of them internet-facing: web, mail, databases, DNS. The goal was to learn about a dangerous vulnerability before the distribution erratum ships, and only when it actually affects our infrastructure.
A 72-hour NVD window holds over 4,700 records. Checking by hand which of them affect our machines is not feasible.
Off-the-shelf tools flood the team. A system that alerts every day stops being read.
The workflow built a keyword list, cut it to 20 items and sent only the first one to NVD. Coverage was accidental and unmeasurable.
“Apache HTTP Server” produced the token “server”, so every CVE mentioning server hit the Apache hosts.
Distributions backport fixes without changing the version number. Comparing the bare number with NVD ranges produces false positives at scale.
A flaw on a single internal machine got the same score as remote code execution on hundreds of servers with public IPs.
02 / numbers
Figures from measurements on the production instance during the rebuild and from the notification register (August–October 2026).
Before the rebuild, matching exceeded the 300 s Code node limit and the run crashed, so 300 s is a lower bound. Last row: instead of one keyword, the workflow fetches the whole CVE window and intersects it with the full catalogue.
03 / architecture
Instead of asking the sources about every product, the workflow fetches the whole window of new and modified CVEs once and intersects it with the catalogue in code. API cost no longer depends on inventory size, and coverage is complete and measurable.
NVD is queried by lastMod, not publication date. That also catches older CVEs that only now received CPE data. Pagination at 2,000 records, and a truncated window is reported explicitly.
The KEV catalogue has over 1,600 entries, mostly for products we do not run. So KEV and EPSS raise the weight of a matched CVE but never pull anything into the report on their own. Exception: an entry added to KEV within the scan window.
http_server appears in CPE as both apache:http_server and akka:http_server. Without qualification every Akka CVE hit all Apache hosts. Aliases are curated for the whole catalogue.
Merge only waits for the four sources, and matching reads them directly without copying data.

04 / priority
The earlier version added flat points for “anything exposed”. For a hosting provider that is the reverse of the right order: a flaw on one internal machine scored the same as remote code execution on hundreds of internet-facing servers.
weight = min(CVSS × 8, 80)
+ 25 KEV + 15 EPSS > 0.7
+ 10 no patch + 5 OTX
+ match bonus (10 / 5 / 0)
exposure = public > 0
? min(1; 0.7 + 0.1 · log10(1 + public))
: 0.4–0.6 depending on host count
priority = min(100; weight × exposure)
Logarithmic scale: 10 and 1,000 exposed hosts differ clearly, but not a hundredfold. The model may disagree with the score, but has to justify the difference in one sentence.
The “affected hosts” count merged machines with a confirmed vulnerable version and those only known to run the product. In extreme cases that meant a dozen or so versus several hundred machines. The report gives both numbers separately, and the prompt treats reporting the sum alone as an error.
A single hosting machine runs a dozen PHP versions side by side. Summing over product–version pairs gave more “public PHP hosts” than machines in the whole inventory. Product-level numbers are computed over the set of unique machines.
The register stores a situation fingerprint: CVE, match class, KEV, priority band and reach. Dedup runs before the 8-item limit for the model, otherwise a new threat in ninth place would never surface.
05 / precision
In security a false alarm is a real cost. Each bug below surfaced on a real run, and each fix has a regression test on real API responses captured from production.
| Symptom | Cause | Fix |
|---|---|---|
| CVEs from 2000 reported as critical on thousands of hosts | “Version outside the vulnerable range” was merged with “version unknown”. A negative result looked like a hit. | A third, explicit out-of-range state: dropped, but counted in run statistics. |
| PHP 7.4 “vulnerable” to a PHP 4 flaw | The package epoch (2:7.4) was read as the version, so PHP 7.4 fell into the “up to 4.4.3” range. | Version normalisation before comparison and a test on real NVD records. |
| An alert about Nginx Proxy Manager, which we do not run | An advisory without CPE data matched our nginx through a sentence in its description. | Prose is out of matching. GitHub package names are compared by whole-token equality. |
| Akka CVEs hit Apache hosts | The http_server alias had no vendor. | vendor:product aliases for generic names. |
| False positives on repository packages | Distributions backport fixes without changing the version, while NVD compares upstream versions. | Repository packages are handled by a separate distribution errata monitor. This workflow covers early warning and in-house builds. |
| Fresh CVEs “do not affect us” | For a few days after publication NVD has no CPE data for them. | An nvdWithoutCpe counter in every report. Without CPE or a package, the system says it does not know instead of guessing. |


06 / AI
Claude receives matched threats with host counts and handles what it is good at: exploit weaponisation, impact and lateral movement, actions for the next hour, detection rules and MITRE ATT&CK mapping. It cannot “invent” a hit.
For cpe-product the model must not write “we are vulnerable”. It has to say the product is present and the first step is to establish the version on the listed hosts.
The model uses only hosts from the sample passed by the code and describes the rest as “and N more”. It does not raise a threat without public exposure to CRITICAL without justification.
With 25 threats the answer broke off mid-array. The model assesses the top 8 priorities and the rest go into the report as a compact table. Nothing disappears silently.
An unavailable source, a truncated NVD window, CVEs without CPE data, a repaired JSON: all of it goes to the caveats section. The code adds them even if the model forgets.


07 / performance and reliability
Each cause was different and each applies to n8n in general, not just this workflow. None was visible while the data was small.
| Symptom | Cause | Fix |
|---|---|---|
Reached heap limit without the container being killed | The V8 heap limit, not container memory. | Raising the Node.js heap together with the container limit. Either alone does nothing. |
| Code node timeout after 300 s | Quadratic matching compiled a new regular expression on every iteration. | Indexes built once: CPE token → products, precompiled phrases. Over 300 s → 0.53 s. |
| 2.6 GB in 90 s and a crash | A file read runs once per input item: a 3.2 MB file read 80 times. | executeOnce on reading and parsing the mapping. Peak 673 MB. |
| Hundreds of MB of copied data | Merge in append mode carried the whole CVE window and its output was unused. | “Wait only” mode with an empty output. |
| Execution database at 420 MB in 3 days | Every run stored full node outputs, including the whole CVE window. | Successful runs without data, errors with full data, retention and VACUUM: 392 → 45 MB. |

shouldAlert decision.
A mail goes out only when there is at least one critical, high or actively exploited threat and the model’s response could be parsed. No “nothing found” mails and no alarms caused by technical failures.
When parsing the model’s response fails, nothing is written to the register as “seen”. The same CVEs come back on the next run instead of disappearing for good.
08 / deployment security
n8n is not exposed to the internet. Isolation comes from Docker port mapping, so it does not depend on whether the host firewall is enabled.
NVD, GitHub and OTX keys moved from node headers into credentials with an allowed-domain list. The secret cannot be sent anywhere else, even if attached to another node.
The built-in audit only detected the Authorization header. Keys in custom-named headers went unnoticed. An audit is a sieve, not proof of cleanliness.
Full inventory exports sit in an owner-only directory outside the container mount. n8n only gets what the workflow needs. The webhook requires a token header.
09 / delivery
The starting point was a workflow that formally worked, but queried NVD with a single keyword, correlated by words and fetched a global EPSS top list unrelated to the inventory. Step one was measuring what actually reached the report.
The CVE window fetched once, with NVD pagination and GitHub cursors, intersected locally with the full catalogue. Coverage of every feed counted and reported.
Vendor-qualified CPE matching, version ranges, three confidence levels, then the “out of range” state and removing prose from matching after the first runs on the full inventory.
Weight times exposure, confirmed versus possible hosts, the dedup register, a model limit with a table for the rest and the alert gate.
Indexes, executeOnce, execution retention, keys in credentials, a webhook token. Moving to Claude 5 models required bumping the model node version, because the old one sent an unsupported thinking mode.
technologies
Client data is anonymised. Screenshots come from an isolated copy of the workflow run on a fictional inventory (180 hosts under example.net) and a sample CVE window: the CVE-2026-99xxx IDs, descriptions, hosts and model response are fictional, and addresses, server names, paths and credentials have been replaced. The matching, enrichment and report logic in the screenshots was executed by the actual workflow code, which uses a Polish interface. Numbers in sections 02 and 07 come from production measurements and the bug examples from real runs.
next step
Tell me what you want to achieve. I'll come back with a concrete proposal, a quote and a delivery plan.