case study · AI vulnerability monitoring in n8n

A zero-day monitor that alerted on everything that only talks about what we actually run

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.

Client
Hosting provider, several thousand servers (anonymised)
Scope
Workflow rebuild, CVE matching, priority, reporting, performance
Stack
n8n · Claude · NVD · CISA KEV · GitHub · OTX · EPSS
Deployment
Docker, VPN-only access, keys in credentials
Part of the n8n workflow with threat matching and enrichment, next to a Threat Intelligence Brief report at CRITICAL level
The part of the workflow that enriches threats, and the report it produces. Screenshots come from an isolated copy run on a fictional inventory.

01 / starting point

Hundreds of CVEs a day and no answer to “does this affect us?”

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.

  1. 01Hundreds of new CVEs a day

    A 72-hour NVD window holds over 4,700 records. Checking by hand which of them affect our machines is not feasible.

  2. 02Alerts about products we do not have

    Off-the-shelf tools flood the team. A system that alerts every day stops being read.

  3. 03The first version asked about one product

    The workflow built a keyword list, cut it to 20 items and sent only the first one to NVD. Coverage was accidental and unmeasurable.

  4. 04Correlation by words in the description

    “Apache HTTP Server” produced the token “server”, so every CVE mentioning server hit the Apache hosts.

  5. 05A version is not always a vulnerability

    Distributions backport fixes without changing the version number. Comparing the bare number with NVD ranges produces false positives at scale.

  6. 06Priority without exposure

    A flaw on a single internal machine got the same score as remote code execution on hundreds of servers with public IPs.

02 / numbers

From over 300 seconds to half a second per match

Figures from measurements on the production instance during the rebuild and from the notification register (August–October 2026).

>300 → 0.53s
matching ~2,000 CVEs against the inventory
2.6 → 0.67GB
peak memory per run after removing redundant data copies
392 → 45MB
execution history database after retention and VACUUM
25 → 8
items for the model with 25 the answer broke off mid-JSON
4+1
threat sources NVD, CISA KEV, GitHub, OTX plus EPSS for matches
42
nodes including three Code nodes holding all matching logic
3
match confidence levels stated explicitly in the report
515
CVEs in the dedup register each reported once, again only when the situation changes
before the rebuildafter the rebuildfull width = before
Matching time>300 s
0.53 s
Peak memory2.6 GB
673 MB
Execution database392 MB
45 MB
Products queried in NVD1 of 20
full catalogue

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

An inverted model: one CVE window, intersected locally

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.

A window by modification date

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.

KEV and EPSS amplify, they do not include

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.

Vendor-qualified aliases

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.

04 / priority

Weight times exposure, not weight plus points

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.

Priority computed in code0–100

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.

Hosts: confirmed and to be checked

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.

Hosts counted as machines, not rows

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.

Dedup before the limit, not after

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

Most of the work went into what the report should not say

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.

SymptomCauseFix
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 flawThe 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 runAn 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 hostsThe http_server alias had no vendor.vendor:product aliases for generic names.
False positives on repository packagesDistributions 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.
The Match CVEs to inventory node editor: inputs from four sources and the catalogue, code describing three confidence levels, JSON output
Matching. The node reads every source directly. A comment in the code spells out what may be claimed at each confidence level.
The Enrich matches node editor: host-to-software mapping as input, code fetching EPSS, output with an inventory summary
Enrichment. A product → hosts index with short keys, because data crosses n8n process boundaries and every byte is serialised.

06 / AI

The model at the end of the pipeline, once the facts are settled

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.

Confidence

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.

Hosts

Names only from the data

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.

Coverage

Eight assessments, the rest as a table

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.

Completeness

The report says when it is incomplete

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

Five ways the rebuild took the instance down

Each cause was different and each applies to n8n in general, not just this workflow. None was visible while the data was small.

SymptomCauseFix
Reached heap limit without the container being killedThe 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 sQuadratic 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 crashA 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 dataMerge 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 daysEvery run stored full node outputs, including the whole CVE window.Successful runs without data, errors with full data, retention and VACUUM: 392 → 45 MB.
The Parse and Validate AI Assessment node editor: model response as input, code with JSON repair and the alert gate, output with a coverage summary
Validation and alert gate. Repairing common JSON errors, collecting caveats and the shouldAlert decision.
The sec_threat_seen data table in n8n with CVE IDs, situation fingerprint, priority and match class
Notification register. Upsert by CVE ID on a side branch, so a write error does not block the report.

Alert gate

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.

A failure does not close a threat

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

A security tool has to be secure too

Network

Loopback and VPN only

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.

Keys

Domain-restricted credentials

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.

Lesson

The n8n audit found 1 of 3 keys

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.

Data

Raw inventory outside the container

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

From a template that asked about one product to a monitor with full coverage

  1. Diagnosis

    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.

  2. Inverting the query model

    The CVE window fetched once, with NVD pagination and GitHub cursors, intersected locally with the full catalogue. Coverage of every feed counted and reported.

  3. Precision

    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.

  4. Priority and reporting

    Weight times exposure, confirmed versus possible hosts, the dedup register, a model limit with a table for the rest and the alert gate.

  5. Performance, security, maintenance

    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

  • n8n
  • JavaScript
  • Python
  • Claude (Anthropic API)
  • AI Agent
  • NVD API 2.0
  • CPE 2.3
  • CISA KEV
  • GitHub Security Advisories
  • AlienVault OTX
  • FIRST EPSS
  • n8n Data Tables
  • Docker
  • SQLite

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

Facing a similar challenge?

Tell me what you want to achieve. I'll come back with a concrete proposal, a quote and a delivery plan.