Skip to content

Moving SIEM correlation rules onto the event stream ​

Three tests that show whether your correlation engine loses alerts under load, and how to run the rules next to the SIEM you keep.


If you run correlation rules on a busy SIEM, you may know the symptom that brings people to a page like this one: a rule that fires every time in the lab stays silent during the incident it was written for. Often the rule and the data are the ones from the lab, and only the volume changed.

This guide is for SIEM engineers deciding whether to keep tuning those rules or to run them somewhere else. I assume you know Sysmon and Sigma, so I'll skip the introductions.

Where correlation breaks ​

A SIEM parses logs into its normalized schema, then correlates the normalized events. Parsing costs about the same per event whatever the volume. A rule with a window, though, keeps state for every partial match still waiting for its next step, so its memory grows with the matches in flight, and every new event is checked against them. It is also only as right as its input: a rule over the last ten minutes needs those ten minutes of events to reach it in time, and the engine to still hold the partial matches they complete. When a collector falls behind or memory runs short, a correlation engine can lose a match without telling anyone, and you can test whether yours does.

Three tests for the engine you have ​

Here are the three ways I know a rule goes quiet without an error, each with a test for your current engine and what Varpulis does today.

Does it drop late events, and say so? ​

Take a day of normalized events and inject an attack sequence that spans two sources, say a network connection from one collector and a process start from another. Replay the day twice into a test instance, once as recorded and once with the second source held back ten minutes. If the delayed replay raises fewer alerts and no counter or log line accounts for the difference, late input is dropped in silence.

Varpulis measures windows and .within() between the timestamps the events carry, and a window fed by several event types waits for the slowest of them. Sequences are stricter, because their steps are taken in arrival order and a partial match expires as soon as the pattern sees an event stamped after its deadline, so a late process start finds nothing left to complete. Declaring .watermark(out_of_order: 10m) on the stream that holds the sequence keeps its partial matches open ten more minutes. Two cases are not covered today. A second step that arrives before its first is not matched by -> (an and matches both orders, without checking which came first), and there is no counter for an event that came too late.

Does it evict partial matches, and say so? ​

Replay a noisy source (failed logons, say) at several times its usual rate, with one injected sequence whose first step sits early in the window. If the alert stops firing as the rate grows and the engine reports no eviction, it sheds partial matches in silence.

Varpulis does not evict by default. A pattern keeps at most 10 000 partial matches open (per partition with .partition_by()), and past that cap it opens no new ones and counts each refusal as runs_dropped. Vejas, the runtime that runs Varpulis rules on a live bus, publishes the counters of each detect unit on /metrics as vejas_detect_losses_total{unit, kind}, and reports a lost run on its log and on the bus, at most once a minute. (filters_without_value counts the events a .where() could not judge, a field missing or of another type.) VEJAS_DETECT_MAX_RUNS sets the cap. Size it as first steps per second times how long a first step waits: 50 SMB connections a second under a two-minute within keep 6 000 matches open, at 3 to 4 KB each in a Vejas unit.

Does a heavy rule slow the light ones? ​

Load a deliberately expensive rule next to a cheap one (a 24-hour count of logons per user over a large directory does the job), inject the cheap rule's sequence, and measure the delay between its last event and the alert, with and without the heavy rule. If the delay grows, your rules wait in the same queue.

In Vejas, each detect unit is one .vpl file with its own thread and its own durable consumer, so a heavy unit falls behind on its own consumer while the others keep reading theirs. Units still share the CPU and memory of the process, and the rules inside one file share its thread, so an expensive rule goes in a file of its own.

The SIEM keeps its job ​

The SIEM keeps collection, parsing, storage, search and the analyst UI. Only correlation moves, to Vejas detect units that read the normalized events, and the alerts go back into the SIEM. Varpulis is the engine inside them (its own server and cluster are retired, see ADR-008).

┌───────────────────┐   normalized events   ┌──────────────────────┐
│ SIEM              │ ────────────────────> │ Vejas                │
│ collection        │     bus subjects      │ detect units (.vpl)  │
│ parsing           │                       │ Varpulis engine      │
│ storage, search   │ <──────────────────── │ losses on /metrics   │
│ analyst UI        │        alerts         │                      │
└───────────────────┘                       └──────────────────────┘

The seam is wherever your SIEM can hand out events after normalization and before correlation, so the fields its parsers extract come along. A connector puts the events on the Vejas bus (NATS JetStream): an HTTP POST to http-in, a Kafka topic, AMQP, MQTT, message queues, or NATS directly. The Kafka source is a bridge over kcat that keeps its offsets in Vejas, so a restart resumes where it stopped (CI tests that mechanism without a live broker, and kcat must be installed on the host). Alerts leave the same way, to the SIEM's API through an HTTP sink, or onto a topic or queue the SIEM reads.

Field names, event types and event time ​

The rules below use plain normalized names (host, dst_host, dst_ip, dst_port, image, parent_image, command_line, user, source_image, target_image, granted_access, src_host, logon_type). Map each one to what your SIEM's normalized schema calls it. Each .from() names a subject and the event type of its payloads, and a payload with a string event_type field takes that type instead, so use one subject per category or let the forwarder set event_type.

The engine reads event time from @timestamp (RFC 3339), else ts or timestamp (epoch milliseconds), and stamps a payload that has none of them when it arrives. That is acceptable for multi-minute windows on a healthy bus, and wrong as soon as a collector lags. There is no way today to name another field, so the forwarder has to put the SIEM's event time under one of those three names.

Two rules, ported ​

A rule rarely translates line for line between engines, so what I port is its intent. Both rules run as they are in the playground, which runs the engine in your browser with WebAssembly. Their .from() and .to() lines name the subjects a Vejas detect unit reads and writes (Vejas ignores the connector's url), and the playground accepts them and takes its events from its own editor.

Lateral movement over SMB, then remote execution ​

A connection to port 445 on a host, then within two minutes a process started on that host by the service control manager (services.exe) or by the PsExec service. PsExec leaves that trace, and so do the tools that work like it, whatever their binary is called.

vpl
connector Bus = nats (
    url: "ignored: the bus is NATS_URL"
)

event NetworkConnection:
    host: str
    dst_host: str
    dst_ip: str
    dst_port: int

event ProcessCreation:
    host: str
    image: str
    parent_image: str
    command_line: str
    user: str

stream Smb = NetworkConnection
    .from(Bus, topic: "vx.siem.network")
    .where(dst_port == 445)

stream ServiceChild = ProcessCreation
    .from(Bus, topic: "vx.siem.process")
    .where(ends_with(lower(parent_image), '\services.exe')
        or ends_with(lower(parent_image), '\psexesvc.exe'))

stream LateralMovement = Smb as smb
    -> ServiceChild where host == smb.dst_host as exec
    .within(2m)
    .emit(
        rule: "lateral_movement_smb",
        mitre: "T1021.002",
        source_host: smb.host,
        target_host: exec.host,
        target_ip: smb.dst_ip,
        image: exec.image,
        command_line: exec.command_line,
        user: exec.user
    )
    .to(Bus, topic: "vx.alerts.lateral")

The sample events hold one attack (ws-07 to srv-db-02) and one look-alike that must not fire: an SMB connection to a file server while a service starts on the print server. The run gives one detection, for srv-db-02.

Run it in the playground

The join host == smb.dst_host keeps the look-alike quiet. Each SMB connection opens its own partial match, so a client that opens several raises one alert per connection, and a unit that crashes may raise an alert again when it restarts (alerts are at least once). Deduplicate on source and target where the alerts land.

The same rule with the target's events arriving late is the first test seen from the inside: the process start, stamped 40 s, arrives after an SMB connection stamped 200 s, and nothing fires. Add .watermark(out_of_order: 5m) under .within(2m), run it again, and it fires.

Credential dump, then remote use ​

A process opens LSASS with an access mask that includes reading its memory, and within the hour the same machine logs on to another one over the network. The first step is the usual single-event rule with an exclusion list, and the sequence adds the question an analyst asks next, whether that machine then logged on somewhere else.

vpl
connector Bus = nats (
    url: "ignored: the bus is NATS_URL"
)

event ProcessAccess:
    host: str
    source_image: str
    target_image: str
    granted_access: str

event Logon:
    host: str
    src_host: str
    user: str
    logon_type: int

stream LsassRead = ProcessAccess
    .from(Bus, topic: "vx.siem.process_access")
    .where(ends_with(lower(target_image), '\lsass.exe')
        and (granted_access == "0x1010" or granted_access == "0x1410"
             or granted_access == "0x1438" or granted_access == "0x143a"
             or granted_access == "0x1fffff")
        and not (ends_with(lower(source_image), '\wininit.exe'))
        and not (ends_with(lower(source_image), '\csrss.exe')))

stream NetworkLogon = Logon
    .from(Bus, topic: "vx.siem.logon")
    .where(logon_type == 3)

stream CredentialUse = LsassRead as dump
    -> NetworkLogon where src_host == dump.host and host != dump.host as logon
    .within(1h)
    .emit(
        rule: "credential_dump_then_remote_use",
        mitre: "T1003.001,T1078",
        host: dump.host,
        dumped_by: dump.source_image,
        access: dump.granted_access,
        used_on: logon.host,
        user: logon.user
    )
    .to(Bus, topic: "vx.alerts.credentials")

The sample events hold a dump on ws-07, followed 25 minutes later by a network logon from ws-07 to srv-db-02, and one look-alike: csrss.exe reading LSASS on ws-11, then a logon from ws-11. The run gives one detection, for ws-07.

Run it in the playground

Migration: parallel run, backfill, cutover ​

The migration that holds up is the boring one. Start with a parallel run: Vejas gets the same normalized events as the current engine, and both send their alerts into the SIEM as different sources for two to four weeks, to find where the same input gives a different output.

Then replay 30 days of exported events, in their recorded order, into a second Vejas runtime started with VEJAS_IDLE_CLOSE_SECS=0 (its units then judge in event time alone, whatever the replay speed), and compare the alert counts per rule with what the current engine raised. I would expect most deltas to come from time, a window measured on arrival in one engine and on the logs' timestamps in the other. The others are events the current engine lost under load, or a port that was not equivalent after all. Investigate each one.

Then cut over one rule at a time. The Vejas version becomes the one analysts act on, the old one runs in shadow for a week, and you roll back if the new one misses an incident the old one caught. When the last rule has moved, the SIEM's correlation engine carries no load, and turning it off is a budget decision.


If you want to see it run first, the detect demo puts two detect units on a bus: the behavioural sequence still fires when the attacker renames PsExec and the signature rule goes quiet, and its alert survives a kill -9 between the two halves of the sequence. To start from your own rules, send three of them with one sample event from your bus to [email protected]: they come back ported to Varpulis, with what they catch on that event shape, free. For your own traffic, the four-week proof of concept takes three to five of your scenarios to running rules on your event stream, next to your SIEM, at a fixed price.

Varpulis - Next-generation streaming analytics engine