PL EN
WB-4B24A2E9TLP:CLEARWazuh 5

Suricata alerts from OPNsense in Wazuh 5: syslog, relay and enabling the integration

Suricata alerts from OPNsense in Wazuh 5: eve over syslog, an rsyslog relay writing clean JSON, agent error 1103 and enabling the suricata integration.

A Suricata alert from OPNsense reaches a finding in Wazuh 5 through four hops: eve over syslog, an rsyslog relay, an agent with localfile in json format, and the enabled suricata integration. Each of them can fail without a message in the interface, so for each one I give the configuration and a way to check it.

Four hops and their silent failures

Wazuh 5.0 is a release candidate, so menu names and settings may still change. I rely on the 5.0-rc documentation and, where it is silent, on a test with Wazuh 5.0.0-rc2, OPNsense 26.7 and Suricata 8.0.6, and I mark such places as test observations. Addresses, host names and paths in the examples are synthetic.

The Suricata sensor runs in IDS mode on an interface that receives a copy of the traffic from a port mirror. OPNsense sends eve records over syslog to an intermediate host. There rsyslog writes only the JSON object to a file, the Wazuh agent reads that file, and Wazuh 5 decodes the events with the suricata integration.

HopWhat it doesHow it fails silently
OPNsensesends eve alerts to a syslog targetno target, or a filter on a different application
Relaystrips the syslog header, writes JSONthe header stays in the file, the json format cannot read it
Agentreads the file with a localfile blockthe file did not exist at startup, error 1103
Wazuh 5decodes with the suricata integrationintegration disabled, event without a decoder

The Wazuh documentation describes the Suricata integration with Suricata installed on a host with an agent that reads /var/log/suricata/eve.json. I do not install an agent on OPNsense, so the relay recreates the same state: a file with one eve object per line on a host with an agent.

In Wazuh 4.14 such a file would hit rule 86600, which matches JSON events with the timestamp and event_type fields. Its collisions with other sources are covered in the article on FIM for WordPress. In Wazuh 5 the integration decoder takes over classification.

What OPNsense sends over syslog

The “Enable eve syslog output” option is on the IDS settings page, in the test under Services > Intrusion Detection > Administration. The OPNsense documentation describes it like this: it sends alerts in EVE format to syslog at the info level and does not change alert logging in OPNsense itself. Block (drop) logs go only to the internal logger, so they will not reach Wazuh this way.

Enabling the option alone sends nothing outside. The documentation says to create a target in System > Settings > Logging / Targets with an application filter suricata and level info. The Suricata documentation shows, in a commented-out example of the syslog output, the values identity: "suricata", facility: local5 and level Info, consistent with this filter.

In the test, only records with event_type equal to alert passed through syslog. The flow, dns, http, tls and stats records did not reach the relay. DNS and HTTP fields are visible only where Suricata attached them to the alert.

The same can be set through the API. The OPNsense API documentation lists the endpoints ids/settings/set, ids/service/reconfigure, syslog/settings/add_destination and syslog/service/reconfigure, but does not give the request bodies. The bodies below come from the test:

POST /api/ids/settings/set
{"ids":{"general":{"syslog_eve":"1"}}}

POST /api/ids/service/reconfigure

POST /api/syslog/settings/add_destination
{"destination":{"enabled":"1","transport":"udp4","program":"suricata","level":"info,notice,warn,err,crit,alert,emerg","facility":"local5","hostname":"192.0.2.10","port":"514","rfc5424":"0","description":"Suricata eve alerts"}}

POST /api/syslog/service/reconfigure

Target fields in the get_destination response in the test:

FieldValuesNote
transportudp4, tcp4, udp6, tcp6, tls4, tls6udp4 in the test
programsuricataapplication filter
levelfrom debug to emergcomma-separated list
facilitylocal5value from the example in the Suricata documentation
hostnamerelay addresshere 192.0.2.10
port514default value
rfc54240default value

UDP does not confirm delivery, so under heavy traffic or during a relay restart alerts can be lost. The same form accepts TCP and TLS transport.

Relay: rsyslog keeps only the JSON

The intermediate host needs four elements: the imudp module, a template that cuts the JSON object out of the message text, a separate ruleset, and a UDP input bound to that ruleset. The property() statement in a list type template accepts the parameters regex.expression, regex.type (ERE or BRE) and regex.subMatch. On Ubuntu 24.04 the packaged /etc/rsyslog.conf sets $PrivDropToUser syslog, so rsyslog runs as the syslog user, which matters for the file permissions in the next step.

# /etc/rsyslog.d/30-suricata-relay.conf (example values)
module(load="imudp")

template(name="eve_json" type="list") {
  property(name="msg" regex.expression="\\{.*" regex.type="ERE" regex.subMatch="0")
  constant(value="\n")
}

ruleset(name="remote") {
  if ($fromhost-ip == '192.0.2.1' and $programname == 'suricata' and $msg contains '{') then {
    action(type="omfile" file="/var/log/suricata-relay/suricata.json" template="eve_json" fileCreateMode="0640")
  }
  stop
}

input(type="imudp" port="514" ruleset="remote")

The expression \{.* takes the text from the first curly brace to the end of the message. The if condition passes only messages from the sensor address, from the suricata program and with a curly brace in the text. stop discards every message after it passes through the ruleset, so nothing from the network reaches the local syslog files. fileCreateMode sets the permissions of the file that rsyslog creates.

I checked the configuration on rsyslog 8.2312. rsyslogd -N1 finished validation without errors. A message from the suricata program sent with logger --udp landed in the file as a clean JSON object with 0640 permissions, and a message from another program landed nowhere. jq reads a line in the file, for example:

{"event_type":"alert","src_ip":"192.0.2.50","dest_ip":"203.0.113.7","proto":"TCP","alert":{"action":"allowed","gid":1,"signature_id":2008983,"rev":10,"signature":"ET USER_AGENTS Suspicious User Agent (BlackSun)","category":"A Network Trojan was detected","severity":1}}

The file grows without limit, so it needs rotation. On Ubuntu 24.04 the rsyslog package ships the script /usr/lib/rsyslog/rsyslog-rotate, which after rotation tells rsyslog to reopen the file. The create directive creates a new file owned by syslog with group wazuh. I checked the syntax with logrotate -d:

/var/log/suricata-relay/suricata.json {
    weekly
    rotate 4
    compress
    missingok
    notifempty
    create 0640 syslog wazuh
    sharedscripts
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
}

Agent: localfile json and error 1103

The agent on the relay reads the file with a localfile block, the same way as in the Wazuh documentation for a local eve.json. According to the documentation, the json format is meant for single-line JSON files, which is what the relay writes. The other localfile options are covered in the article on multiline logs.

<localfile>
  <log_format>json</log_format>
  <location>/var/log/suricata-relay/suricata.json</location>
</localfile>

The trap concerns a file that does not exist when the agent starts. In the test the agent logged:

ERROR: (1103): Could not open file '/var/log/suricata-relay/suricata.json' due to [(2)-(No such file or directory)]

The file appeared later, with the first alert, and the agent did not pick it up. Only an agent restart helped, after which the log showed Startup completed. Runtime-discovered files will be read from beginning. The documentation describes rescanning every logcollector.vcheck_files seconds only for paths with a wildcard.

I recommend creating an empty file before the agent loads the configuration. The Wazuh documentation gives the wazuh user read access to Suricata logs through the group, so the file gets owner syslog, so that rsyslog can write to it, and group wazuh. fileCreateMode works only when rsyslog creates the file, it does not change an existing one:

install -d -o syslog -g wazuh -m 0750 /var/log/suricata-relay
install -o syslog -g wazuh -m 0640 /dev/null /var/log/suricata-relay/suricata.json

The second way is a path with a wildcard, for example suricata*.json. I did not test this way, and rotation with compression creates files with other names, so the pattern has to match the logrotate configuration.

Wazuh 5: the suricata integration is disabled

According to the documentation, an integration in Wazuh 5 is a logical group of decoders, KVDB and rules for one log source. The integration category determines the data stream wazuh-events-v5-<category>. The documentation does not give the category of the suricata integration. In the test its events went to the security category stream. Indices and categories are covered in the article on Wazuh Common Schema.

The Wazuh 5.0-rc documentation says to enable the integration in the dashboard, and in the test on rc2 the integration was disabled. While it was disabled, logtest classified the raw eve alert as wazuh-core with no match. An event that no decoder matches goes to the wazuh-events-v5-unclassified stream only when indexing of unclassified events is enabled. Without that setting the alert reaches no stream, even though the previous three hops work.

Steps from the documentation:

  1. Ruleset management > Overview.
  2. Type suricata in the search field and select the suricata integration.
  3. Open the integration, click Actions and select Enable.
  4. Wait a few minutes before generating test traffic.

After enabling, logtest returned for the same alert:

FieldValue
integrationsuricata
event.kindalert
rule.idSuricata signature ID
rule.namesignature text
rule.categorySuricata signature category

Events landed in wazuh-events-v5-security, findings in wazuh-findings-v5-security, and the raw copy in wazuh-events-raw-v5. The role of findings is covered in the article on Sigma rules.

Test and verification

The Wazuh documentation generates an alert with the command curl -s http://1.1.1.1/, which triggers the signature ET HUNTING curl User-Agent to Dotted Quad. With the sensor on OPNsense, the request has to pass through an interface covered by the mirror. The classic test with testmynids.org stopped working: on the day of the test the domain returned a “for sale” page without the uid=0(root) line.

The second signature for the test is ET OPEN 2008983. Its text from the official ruleset:

alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"ET USER_AGENTS Suspicious User Agent (BlackSun)"; flow:established,to_server; http.user_agent; content:"BlackSun"; nocase; startswith; reference:url,www.bitdefender.com/VIRUS-1000328-en--Trojan.Pws.Wow.NCY.html; classtype:trojan-activity; sid:2008983; rev:10; metadata:created_at 2010_07_30, confidence High, signature_severity Major, updated_at 2024_04_13;)

The rule requires a User-Agent header starting with BlackSun in an established HTTP connection from $HOME_NET to $EXTERNAL_NET. It is an alert http rule, so the request goes over plain HTTP:

curl -A BlackSun http://example.com/

Order of checks, from the source to the finding:

StepWhereWhat to see
1OPNsense alert logalert with sid 2008983
2file on the relaynew JSON line without a syslog header
3agent logno error 1103
4logtestintegration suricata, not wazuh-core
5aggregation by indexstream wazuh-events-v5-security
6Findings in the dashboardfilter wazuh.integration.name: suricata

You run steps 2 and 3 on the relay. The last signature in the file and the alert count per signature ID:

tail -n 1 /var/log/suricata-relay/suricata.json | jq -r '.alert.signature'
jq -r '.alert.signature_id' /var/log/suricata-relay/suricata.json | LC_ALL=C sort | uniq -c | LC_ALL=C sort -rn

Step 5 is a query to the indexer that groups events from the last 15 minutes by index and by integration name. It shows which stream the alert went to, without guessing names:

GET wazuh-events-v5-*/_search
{
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        { "range": { "@timestamp": { "gte": "now-15m" } } }
      ]
    }
  },
  "aggs": {
    "by_index": {
      "terms": { "field": "_index" },
      "aggs": {
        "by_integration": { "terms": { "field": "wazuh.integration.name" } }
      }
    }
  }
}

In step 6 the documentation leads to Threat intelligence > Threat Hunting > Findings with the filter wazuh.integration.name: suricata. The finding title there has the form Suricata IDS alert triggered - uncategorized - ET HUNTING curl User-Agent to Dotted Quad. In the test, searching for the signature number as free text (query_string) found no events, while a term on wazuh.integration.name did, so I filter by integration name.

Rollback

I roll back the changes in reverse order.

  1. Integration: in Ruleset management, undo the enabling of the suricata integration. The 5.0-rc documentation describes only Enable, so check the action name in your version.
  2. Agent: remove the localfile block and restart the agent.
  3. Relay: remove the rsyslog configuration file and the logrotate entry, restart rsyslog, finally remove the alert file.
  4. OPNsense: disable “Enable eve syslog output” and remove the target in Logging / Targets. Through the API: syslog_eve to 0 in ids/settings/set and ids/service/reconfigure, the target through syslog/settings/del_destination/<uuid> and syslog/service/reconfigure. search_destinations returns the target ID.

Events stored earlier stay in the streams until the end of the retention described in the article on WCS. The rc2 test environment in Docker is covered in the article on rc2.

What the documentation does not specify

  • Whether syslog_eve sends records other than alerts. The interface and API have no such option.
  • Logcollector behavior for a plain path that does not exist when the agent starts.
  • The category of the suricata integration and the findings and raw copy streams: the names come from the test.
  • File rotation: the logrotate entry and the rsyslog-rotate script come from the Ubuntu package, not from the rsyslog documentation.

Sources

↑↓ select Enter open Esc close