PL EN
WB-123BBA20TLP:CLEARWazuh 4

Suppressing SSH alerts in Wazuh: level 0, if_sid and CDB lists

Wazuh sshd rules: level 0, if_sid, CDB lists and overwrite. How to cut noise without losing the 5712 and 5720 alerts, plus a wazuh-logtest regression set.

Suppressing a rule reduces noise, but a level 0 rule also removes information that correlation rules rely on. A broad filter on an account name or on the sshd program can switch off brute force detection that nobody meant to touch.

How the sshd rule chain fits together

In version 4.14 the sshd rules live in the file 0095-sshd_rules.xml (group syslog,sshd,). The base rule 5700 has level 0, the flag noalert="1" and the condition decoded_as equal to sshd. It does not alert on its own, but it is the parent of the rest. The most common child rules:

ID    Level   Description in the rule file
5710  5       Attempt to login using a non-existent user
5712  10      brute force trying to get access to the system. Non existent user
5715  3       authentication success
5716  5       authentication failed
5720  10      Multiple authentication failures
5760  5       authentication failed
5763  10      brute force ... Authentication failed
5709  0       Useless SSHD message without an user/ip and context

Rules 5712, 5719 and 5763 have frequency="8", timeframe="120" and ignore="60". Rule 5720 has frequency="8" without a timeframe attribute. Each of them uses if_matched_sid pointing to the base rule of the counted events: 5712 counts hits of 5710, 5720 counts 5716, 5763 counts 5760. The same_source_ip condition (a deprecated alias, equivalent to same_srcip) forces the eight events to come from one address.

The context from the table matters when you design exceptions: a high level alert does not come from a single event, but from a lower level event counted eight times. When you suppress the lower level event, you also suppress its counter.

Fields from the decoder

Exception rules rely on fields extracted by the decoders from the file 0310-ssh_decoders.xml. For failed and successful logins, the decoders ssh-failed and sshd-success write user, srcip and srcport, in that order. The decoder ssh-invfailed writes srcuser and srcip, not user.

Before you write a condition on an account, check in wazuh-logtest which field is actually produced for a given message. The user option in a rule compares the value with the user field, so it does not cover events where the account went to srcuser. The documentation does not describe how the user option behaves toward srcuser, so treat this as a warning to verify.

What level 0 does

The rule classification documentation defines level 0 as “Ignored”: no action, used to avoid false alarms. Rules of this level are scanned before all others, cover events with no security significance, and do not appear in the security events panel.

The second piece of information has bigger consequences. The rule syntax says it outright: level 0 rules are discarded immediately and will not be used with if_matched_sid. The level must be at least 1, and to keep the event out of the log you need to add the no_log option.

From these two sentences I draw my own conclusion, which the documentation does not state outright: a broad local level 0 rule that matches events on the 5710 or 5716 path can take away their share in the 5712 and 5720 counters. The effect is silent: the brute force alert for the sources covered by the exception disappears together with the events.

Level 0 rules also appear in the sshd file itself. Rule 5709 (“Useless SSHD message without an user/ip and context”) is narrow: it covers messages without a user and an address. That makes sense, because it carries no signal. A rule that also matches messages with an address and an account does carry it.

A narrow exception instead of a broad filter

A safer pattern has three traits: it names a specific parent rule in if_sid, it limits matching to a known source, and it puts that source on a list, not in the rule body.

A CDB list file has one key per line, with a colon at the end. For IP addresses, a subnet is written in dotted notation, and a full address as four octets:

192.0.2.10:
192.0.2.11:
198.51.100.:

The last line is an adaptation of the pattern from the documentation: according to it, three octets and a trailing dot mean a /24 subnet. Keep lists in /var/ossec/etc/lists, and register the path in the <ruleset> block of /var/ossec/etc/ossec.conf:

<ruleset>
  <list>etc/lists/example-scanners</list>
</ruleset>

The exception rule points to the list through <list field="srcip" lookup="address_match_key">:

<group name="sshd,">
  <rule id="100200" level="0">
    <if_sid>5716</if_sid>
    <list field="srcip" lookup="address_match_key">etc/lists/example-scanners</list>
    <description>sshd: failed login from a listed address</description>
  </rule>
</group>

The scope is narrow for three reasons: it covers only children of 5716, only one field, and only addresses that someone deliberately put on the list. After you change the list file, you must restart the manager service, because CDB lists are built when the analysis engine starts. The format details are covered in the post on CDB lists.

This exception still has level 0, so a listed source stops feeding the 5720 counter. For sources you entered on purpose, that is usually what you want. If you prefer that the counter does not lose them, the documentation gives an alternative: level at least 1 and the no_log option. The choice depends on whether events from the list should count toward brute force.

Two warnings about lists. A typo in an address on the list turns a narrow exception into no exception, and nobody notices until the alert returns to the panel. Conversely, a list that grows without review becomes a broad filter over time. The negate modifier in the srcip option and the value not_address_match_key let you build inverse rules, for example ones that alert on a login from outside a list of trusted addresses.

Overwrite or a child rule

There are two mechanisms for changing the behavior of a built-in rule. A child rule adds a new node under an existing ID. The attribute overwrite="yes" replaces the built-in rule with a local version. The custom rules documentation shows the second way on the example of 5710: a copy of the rule from /var/ossec/ruleset/rules/0095-sshd_rules.xml goes into a local file, the level rises from 5 to 10, and overwrite="yes" is added to the rule tag.

<group name="syslog,sshd,">
  <rule id="5710" level="10" overwrite="yes">
    <if_sid>5700</if_sid>
    <match>illegal user|invalid user</match>
    <description>sshd: Attempt to login using a non-existent user</description>
  </rule>
</group>

Limits from the documentation: with overwrite, the labels if_sid, if_group, if_level, if_matched_sid and if_matched_group are not taken into account, and the original value stays. Changes in /var/ossec/ruleset/rules are overwritten on update, so the copy goes into the local rules directory, with an ID from the range 100000 to 120000 for new rules.

A child rule suits suppression better, because it does not touch the built-in chain, and it reaches level 0 only for a defined subset. overwrite makes sense when you change the level or description and want the change to cover all further rules that depend on that ID. Suppressing through overwrite with level 0 moves all the effects described above onto rule 5710: the 5712 counter stops seeing it.

Levels and thresholds are covered in the post on rule levels and thresholds, and the rules for combining events into counters in the post on event correlation.

Frequency rules and suppression

For 5712 and 5720, check three things before you touch the base rules:

  • Which events count toward the threshold: 5712 counts hits of 5710, 5720 counts 5716, so an exception on 5716 changes the 5720 counter, but not 5712.
  • How long the window lasts: timeframe in 5712 is 120 seconds, and ignore="60" means that after firing, the rule stays silent for 60 seconds.
  • Whether the source is excluded from counting or only from alerting: level 0 does the first, level 1 with no_log allows the second.

Level 5 of rules 5710 and 5716 matches the class “User generated error”, with a comment in the documentation that on their own they have no security significance. Multiple failures, level 10, is according to the same classification a signal that may mean an attack or a forgotten password.

Regression set in wazuh-logtest

Every exception should have a set of events whose result is known before deployment. A minimal set in wazuh-logtest, with synthetic data:

Oct 15 21:07:00 agent-01 sshd[29205]: Invalid user example-user from 198.51.100.10 port 48928
Oct 15 21:07:05 agent-01 sshd[29206]: Failed password for example-admin from 192.0.2.20 port 50022 ssh2
Oct 15 21:07:10 agent-01 sshd[29207]: Accepted password for example-admin from 192.0.2.20 port 50022 ssh2
Oct 15 21:07:15 agent-01 sshd[29208]: Failed password for example-admin from 192.0.2.10 port 50023 ssh2

For each line, record the expected rule ID, level and the srcip and user fields. The first line matches the example from the documentation (rule 5710, level 5). The Accepted line matches the pattern ^Accepted of rule 5715. For the Failed password line, the documentation does not settle which of the matching rules fires, so record the expected result after the first run and keep it as a reference for comparisons. The fourth line uses an address from the example list: the expected effect is the exception rule, and only for it.

Scenarios to cover:

  • A series of eight failed logins from one address outside the list. Pattern from the documentation: pasting the same event eight times in one session gives rule 5712 at level 10 with frequency: '8'.
  • The same series from an address on the list. The expected result is no high level alert for that address.
  • A successful login after a series of failures, because the exception must not hide it.
  • An event with incomplete fields, to see whether the match leaks onto messages without an address.

wazuh-logtest keeps a session and a firedtimes counter, so frequency rules can be checked without production traffic. Sessions expire after 15 minutes by default, and the maximum number of sessions is 64. The test needs only the saved rule files, and a manager restart is needed only for generating alerts. The exception is a change to a CDB list file, which requires a restart. The rules for working with the tool are covered in the post on wazuh-logtest.

Order of work for a new exception

My own recommendation, not a documentation requirement: first reproduce the event in wazuh-logtest and record which rule catches it. Then decide whether the exception should cover one address, one subnet or one account, and pick the narrowest of these options. Only then write the rule, add it to the regression set and check that the 5712 and 5720 alerts still fire for sources outside the list. An exception without a review date becomes a permanent filter over time, so record the reason for each entry outside the list file, for example in the change ticket.

What the documentation does not specify

  • What the default timeframe is for a rule with frequency but without timeframe (applies to 5720).
  • Which of the rules 5716 and 5760 fires when both match one event (5760 has if_sid 5700 and 5716).
  • Whether the user option in a rule also reads the srcuser field (the documentation mentions only the user field).
  • Whether a level 0 rule takes precedence over a sibling rule under the same parent, beyond the statement that level 0 rules are scanned before all others.
  • The behavior of check_value in a CDB list for a non-matching value.

Sources

↑↓ select Enter open Esc close