PL EN
WB-36B8FACATLP:CLEARWazuh 4

Wazuh rule levels and alert thresholds: log_alert_level, email, overwrite

Wazuh rule levels 0-16, the log_alert_level and email_alert_level thresholds, the email limit, no_log and alert_by_email, and changing a level with overwrite.

A rule level expresses its severity, while separate thresholds in ossec.conf and options of the rule itself decide where the alert goes. This post covers levels 0-16, the two thresholds in the <alerts> section, the email settings that work with them, and a practical level change of a built-in rule.

The levels and thresholds described below apply to XML rules in Wazuh 4.x. In Wazuh 5 (5.0-rc), XML rules no longer generate alerts: detection is described by Sigma rules in Wazuh 5, and the result is a finding.

Rule levels

The documentation describes levels from 0 (lowest) to 16 (maximum). The same range 0 to 16 applies to the level attribute in a rule definition.

LevelTitleMeaning according to the documentation
0IgnoredNo action, used to avoid false positives. These rules are checked before all others, cover events with no security relevance, and do not appear on the security events dashboard.
1Low relevance informationEvents of very low relevance, context or a base for other rules, e.g. rule 5754. Level 1 is below the default log_alert_level (3), so it creates no alerts until you lower the threshold.
2System low priority notificationSystem and status messages with no security relevance, not visible on the security events dashboard.
3Successful/Authorized eventsSuccessful logins, firewall allow events, etc.
4System low priority errorErrors from misconfiguration or unused devices and applications, usually from default installations or software tests.
5User generated errorWrong passwords, denied actions. No security relevance on their own.
6Low relevance attackA worm or virus with no impact on the system, frequent IDS events and frequent errors.
7“Bad word” matchingWords such as “bad” or “error”. Usually unclassified, may have security relevance.
8First time seenThe first IDS event, the first user login, and also actions such as enabling a sniffer.
9Error from invalid sourceLogin as an unknown user or from an invalid source, admin (root) account errors. Relevance grows with repetition.
10Multiple user generated errorsMultiple wrong passwords or failed logins: an attack or forgotten credentials.
11Integrity checking warningBinary modification, presence of rootkits (Rootcheck). May indicate a successful attack; IDS events that will be ignored because of a large number of repetitions also land here.
12High importance eventSystem, kernel etc. errors or warnings, a possible attack on a specific application.
13Unusual error (high importance)Most often matches a common attack pattern.
14High importance security eventUsually triggered by correlation, indicates an attack.
15Severe attackNo risk of false positives, requires immediate attention.
16Maximum severityThe highest allowed level. No default rule uses it, it is reserved for custom rules.

Two thresholds in the alerts section

Both parameters are in <alerts> of /var/ossec/etc/ossec.conf and take values from 1 to 16.

ParameterDefault (documentation)Effect
log_alert_level3Minimum alert level written to alerts.log and/or alerts.json
email_alert_level7Minimum alert level that triggers an email notification

The ossec.conf installed with the manager sets email_alert_level to 12, so on an installed manager 12 applies instead of the default 7. Read the current threshold from the ossec.conf file on the manager.

<alerts>
  <log_alert_level>3</log_alert_level>
  <email_alert_level>12</email_alert_level>
</alerts>

The values in the examples in this post are synthetic, and addresses come from the example.com domain.

The email_alert_level threshold takes precedence over the detailed email configuration: setting 10 blocks messages for alerts below 10, even if detailed rules refer to lower levels. The exception is the rule option alert_by_email, which forces an email regardless of the global and detailed thresholds.

Email settings that work with the threshold

The level threshold is only one of the conditions. In the <global> section these also apply:

OptionDefaultMeaning
email_notificationnoEnables or disables email notifications (yes, no)
email_maxperhour12Maximum number of emails per hour (1 to 1000000). The excess ones are queued and sent together in one message at the end of the hour, regardless of whether mail grouping is enabled
email_log_sourcealerts.jsonThe alerts file the data is read from (alerts.log or alerts.json). The installed ossec.conf sets alerts.log

The recipient, sender and SMTP server are set by email_to, email_from and smtp_server. Example in <global>:

<global>
  <email_notification>yes</email_notification>
  <smtp_server>smtp.example.com</smtp_server>
  <email_from>[email protected]</email_from>
  <email_to>[email protected]</email_to>
  <email_maxperhour>12</email_maxperhour>
  <email_log_source>alerts.log</email_log_source>
</global>

A design recommendation (not a product option): choose the email_maxperhour limit and the email_alert_level threshold together. A low threshold with a low limit quickly moves most messages into the summary email at the end of the hour, so it is better to keep high-level alarms above the threshold, and to force a single critical rule below the threshold with the alert_by_email option. Example of a custom rule (ID from the custom range):

<rule id="100100" level="8">
  <if_sid>5710</if_sid>
  <match>admin</match>
  <description>Example: invalid login attempt for admin account</description>
  <options>alert_by_email</options>
</rule>

Notifications through Slack, PagerDuty or a webhook are a separate mechanism, described in the post on the integrator.

Rule options that affect alerting

Besides the level, a rule has its own attributes and options. Attributes of the <rule> element:

AttributeRangeEffect
level0 to 16The level used by alerts and responses
id1 to 999999Rule identifier
noalert0 (default) or 1With 1 the rule does not generate an alert, but the event is still analyzed by other rules
ignore1 to 999999 sThe time the rule is ignored after firing, against flooding
overwriteyes, noReplacing an existing rule with local changes

The <options> element takes one option per tag:

OptionEffect
alert_by_emailAlways send the alert by email
no_email_alertNever send the alert by email
no_logDo not write this alert
no_full_logOmit the full_log field in the alert
no_counterOmit the rule.firedtimes field in the JSON alert

Example from the documentation: a level 8 rule that matches a login to a non-existent account but does not write the alert.

<rule id="9800" level="8">
  <match>illegal user|invalid user</match>
  <description>sshd: Attempt to login using a non-existent user</description>
  <options>no_log</options>
</rule>

Rules that silence noise at level 0 and exceptions for sshd are described in the post on SSH alert suppression.

The built-in rule 5700 shows the difference between level 0 and noalert: it has level="0" and noalert="1", groups sshd messages, and the following rules (5710 and others) refer to it through if_sid.

<rule id="5700" level="0" noalert="1">
  <decoded_as>sshd</decoded_as>
  <description>SSHD messages grouped.</description>
</rule>

Correlation: frequency and timeframe

frequency (from 2 to 9999) sets how many times a rule has to match before an alert, and timeframe (from 1 to 99999 s) sets the counting window. The built-in sshd rule 5712 from ruleset/rules/0095-sshd_rules.xml in version 4.14.0:

<rule id="5712" level="10" frequency="8" timeframe="120" ignore="60">
  <if_matched_sid>5710</if_matched_sid>
  <same_source_ip />
  <description>sshd: brute force trying to get access to the system. Non existent user.</description>
  <mitre>
    <id>T1110</id>
  </mitre>
  <group>authentication_failures,gdpr_IV_35.7.d,gdpr_IV_32.2,hipaa_164.312.b,nist_800_53_SI.4,nist_800_53_AU.14,nist_800_53_AC.7,pci_dss_11.4,pci_dss_10.2.4,pci_dss_10.2.5,tsc_CC6.1,tsc_CC6.8,tsc_CC7.2,tsc_CC7.3,</group>
</rule>

Eight matches of rule 5710 from the same source address within 120 s give a level 10 alert, and for the next 60 s the rule is ignored. Level 10 is higher than log_alert_level (3), so the alert goes to alerts.json, but with email_alert_level equal to 12 it will not trigger an email. The details of grouping (same_*, different_*) are described in the post on event correlation.

Changing the level of a built-in rule with overwrite

Files in /var/ossec/ruleset/rules are overwritten during updates, so the change goes into /var/ossec/etc/rules/. For custom rules use IDs from 100000 to 120000. The original of rule 5710 from version 4.14.0 (level 5):

<rule id="5710" level="5">
  <if_sid>5700</if_sid>
  <match>illegal user|invalid user</match>
  <description>sshd: Attempt to login using a non-existent user</description>
  <mitre>
    <id>T1110.001</id>
    <id>T1021.004</id>
  </mitre>
  <group>authentication_failed,gdpr_IV_35.7.d,gdpr_IV_32.2,gpg13_7.1,hipaa_164.312.b,invalid_login,nist_800_53_AU.14,nist_800_53_AC.7,nist_800_53_AU.6,pci_dss_10.2.4,pci_dss_10.2.5,pci_dss_10.6.1,tsc_CC6.1,tsc_CC6.8,tsc_CC7.2,tsc_CC7.3,</group>
</rule>

An entry in /var/ossec/etc/rules/local_rules.xml that raises the level to 10 (a copy of the whole rule with overwrite="yes" and a changed level; the description, match and groups stay as in the original):

<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>
    <mitre>
      <id>T1110.001</id>
      <id>T1021.004</id>
    </mitre>
    <group>authentication_failed,gdpr_IV_35.7.d,gdpr_IV_32.2,gpg13_7.1,hipaa_164.312.b,invalid_login,nist_800_53_AU.14,nist_800_53_AC.7,nist_800_53_AU.6,pci_dss_10.2.4,pci_dss_10.2.5,pci_dss_10.6.1,tsc_CC6.1,tsc_CC6.8,tsc_CC7.2,tsc_CC7.3,</group>
  </rule>
</group>

The elements if_sid, if_group, if_level, if_matched_sid and if_matched_group are ignored in an overwriting rule: the values from the original are kept. The change therefore does not touch the link between the rule and its parent rule 5700.

A custom rule and the logtest result

Example from the documentation: a custom rule with ID 100010 and level 0 for the program example, in local_rules.xml.

<group name="custom_rules_example,">
  <rule id="100010" level="0">
    <program_name>example</program_name>
    <description>User logged</description>
  </rule>
</group>

For the event Dec 25 20:45:02 agent-01 example[12345]: User 'admin' logged from '192.0.2.10', phase 3 in wazuh-logtest shows id: '100010', level: '0', description: 'User logged', groups: '['custom_rules_example']', firedtimes: '1' and mail: 'False'. The documentation gives this result for an event with the example decoder; at level 0 the event does not become an alert.

Verification and restart

Saving the rule files is enough for a test, but live alerts are generated only after a manager restart. The course of the test itself is described in the post on wazuh-logtest.

# Test rule changes (saving the rule files is enough)
/var/ossec/bin/wazuh-logtest

# Apply changes to live alert generation
systemctl restart wazuh-manager

What the documentation does not specify

The documentation does not give the default values of frequency and timeframe, does not describe whether emails forced by alert_by_email or silenced by no_email_alert count toward the email_maxperhour limit, nor the exact meaning of the mail field in logtest relative to email_alert_level.

Sources

↑↓ select Enter open Esc close