If your phone keeps lighting up with this, you are in the right place:
Persistence location changed (systemd): /etc/systemd/system/snapd.mounts.target.wants/snap-lxd-33110.mount
File '/etc/systemd/system/snapd.mounts.target.wants/snap-lxd-33110.mount' deleted
Mode: realtime
Agent: (002) - web-01
Location: syscheck
Rule ID: 100200 (Level 12)
Nobody touched that server. snapd refreshed the lxd snap, and every refresh writes systemd unit files for the new revision and deletes the ones for a revision it no longer keeps. A file integrity monitoring (FIM) rule that watches /etc/systemd/system at level 12 sees each of those files as a possible persistence implant and pages you.
This guide is for people who run Wazuh and have started ignoring its alerts. You will end up with a repeatable way to find the noise and a fix for each kind, worked through on snap refreshes, Docker temp files and a flapping listening-ports check. It assumes root on the Wazuh manager and comfort editing files over SSH.
For every noisy item, the whole method is one question: does a person need to act on this?
- Yes: keep the alert.
- No, but you want the record: write a child rule on the manager that lowers the level, to 0 or to anything below your paging threshold.
- No, and the data is useless: stop it at the agent with
<ignore>, or fix the command that produces it.
Last verified: December 2026 against the documentation and source of Wazuh 4.14.11 (released November 25, 2026, the current release; a 4.14.12 release candidate is tagged). Wazuh 5.0, still in release candidates, replaces the 4.x wazuh-analysisd with a new engine, so check its migration guide before reusing these rules there. The deployment in this story ran an earlier 4.14 release. The shell script was syntax-checked with dash -n and bash -n and run under dash 0.5.12 and bash in POSIX mode against a stubbed ss. The read failure was reproduced on a test machine with Linux 6.18. The rule regex was tested with PCRE2 and the XML with xmllint.
What Happened
I run Wazuh on cloud servers and the critical on-premises ones, with custom rules on top of the stock ruleset. Two of those rules page a person: one fires on changes in the systemd unit directories, the other when a server’s listening ports change.
Both kept firing on events nobody had caused. The alert at the top of this page is the kind that started it: a routine snap refresh, reported as a high-level persistence alert. I ranked a day of alerts with jq, and almost everything that paged was snap refreshes. Each refresh of the lxd or core22 snap touched about 14 unit files, and every file was its own alert. The ranking also showed that snapd rewrites more than mount units: the snap.lxd.* service and socket units changed on every refresh too. I wrote a child rule for the snap churn and tested it on one agent with a fake mount unit and a fake service before trusting it.
The port alerts came from short-lived sockets that made the check’s output differ from one run to the next. While I was changing the check script, the new version printed this, four times:
/var/ossec/etc/listening-ports.sh: 7: [: Illegal number:
cat -A showed the script and the /proc file were both fine. The cause was dash’s read builtin, explained in Step 7. Reading the file with cat instead fixed it.
How It Works
Levels and thresholds. Every Wazuh rule has a level from 0 to 16. log_alert_level in the <alerts> block of /var/ossec/etc/ossec.conf (default 3) sets the minimum level written to alerts.json, which is what the dashboard shows. email_alert_level and the <level> option inside each <integration> block set the minimum level that notifies someone. The documented default for email_alert_level is 7 when the option is missing, but the ossec.conf the installer writes sets it to 12, so check yours. Level 0 means “ignored, no action taken”: the event produces no alert at all.
Child rules. Rules form a tree. A rule with <if_sid> is only evaluated after the rule ID it names has matched. <if_group> does the same for any rule in a named group. When a child matches, its level and description apply to the event in place of the parent’s. Inside the child, <field name="..."> tests a field the decoder extracted, and <match> tests the whole log text. By default <field> uses Wazuh’s simple OS_Regex syntax and <match> uses OS_Match (sregex). Both accept type="pcre2" for full PCRE2 regular expressions. Several <field> lines in one rule must all match.
Where your rules live. Custom rules go in /var/ossec/etc/rules/local_rules.xml (or your own file in that directory) with IDs from 100000 to 120000. Never edit /var/ossec/ruleset/rules/, because upgrades overwrite it. A custom decoder (/var/ossec/etc/decoders/local_decoder.xml) is only needed when no decoder extracts the field you want. FIM events and command output already have decoders, so this guide is all rules.
FIM on the agent. The syscheck block configures FIM. <directories realtime="yes"> watches directories (not single files) with inotify, so changes are reported within seconds instead of at the next scheduled scan. <ignore> takes a path, or with type="sregex" a pattern. Ignored paths are still scanned, but nothing is reported. sregex is plain string matching with only four special characters: ^, $, | and !. There are no wildcards or character classes, which is why precise suppression belongs in a PCRE2 child rule on the manager. With report_changes on, alerts carry file diffs to wherever your integrations send them, and <nodiff> keeps secrets such as private keys out of those diffs.
Command monitoring. A <localfile> block with <log_format>full_command</log_format> runs a command as root every <frequency> seconds (default 360) and sends the whole output as one event, prefixed with ossec: output: '<alias>':. Stock rule 530 (level 0) catches all command output. Stock rule 533 (level 7) matches the alias netstat listening ports and carries <check_diff />. That means it alerts only when the output differs from the previous output from the same agent, which the manager stores in /var/ossec/queue/diff/<agent>/<rule id>/last-entry. The first output is stored silently. So any line that changes between runs is an alert, and two commands with the same alias on one agent overwrite each other’s saved output and alert on every run.
<ignore> acts on the agent before anything is sent. Child rules act on the manager. The paging threshold acts last.
Prerequisites
- A Wazuh 4.14 manager and agents. Commands assume the default install path
/var/ossecand systemd. - Root on the manager, and
jqinstalled there (sudo apt install jqon Debian and Ubuntu). - Your paging threshold. Find it with
sudo grep -nE 'email_alert_level|<level>' /var/ossec/etc/ossec.conf. This guide assumes 12. - A custom FIM rule that watches
/etc/systemd/system, and that directory monitored in real time on the agents. Step 3 includes an example parent rule if you do not have one. - One test agent where you may create and delete files in
/etc/systemd/system. - For Step 8, an Ansible control node with your agents in an inventory group (this guide uses
wazuh_agents), andssfrom iproute2 on the agents.
Step 1: Rank the Noise with jq
Count before you change anything. alerts.json has one JSON object per line. The manager may still be writing the last line while you read, so parse each line with fromjson?, which skips a half-written line instead of stopping with parse error: Unfinished string at EOF.
Top rules:
sudo jq -Rr 'fromjson? | [.rule.id, .rule.level, .rule.description] | @tsv' \
/var/ossec/logs/alerts/alerts.json | sort | uniq -c | sort -rn | head -25
If a rule puts $(file) in its description, it shows up once per path. That is the next command’s job.
Top FIM paths per agent, with digits collapsed so that snap revisions and random suffixes group together:
sudo jq -Rr 'fromjson? | select(.syscheck) | "\(.agent.name)\t\(.syscheck.path | gsub("[0-9]+"; "N"))"' \
/var/ossec/logs/alerts/alerts.json | sort | uniq -c | sort -rn | head -25
The output looks like this (the counts here are illustrative):
5210 docker-01 /tmp/runc-processN
12 web-02 /tmp/apt.data.aBcDeF
9 docker-01 /tmp/tmp.QwErTyNNzX
Only what reaches your pager. Set min to your threshold:
sudo jq -Rr --argjson min 12 'fromjson? | select(.rule.level >= $min)
| "\(.rule.id)\t\(.agent.name)\t\((.syscheck.path // .rule.description) | gsub("[0-9]+"; "N"))"' \
/var/ossec/logs/alerts/alerts.json | sort | uniq -c | sort -rn | head -30
2 100200 web-01 /etc/systemd/system/snapd.mounts.target.wants/snap-lxd-N.mount
2 100200 web-01 /etc/systemd/system/snap.lxd.daemon.service
2 100210 app-01 Listening ports changed: possible backdoor listener
Collapse digits inside jq, on the path only. An earlier attempt piped the whole line through sed -E 's/[0-9]{3,}/N/g', which also turned every rule ID into N.
The manager rotates alerts.json daily into /var/ossec/logs/alerts/<year>/<Mon>/ossec-alerts-<DD>.json.gz. Feed several days through the same filters with zcat:
sudo zcat /var/ossec/logs/alerts/2026/Nov/ossec-alerts-*.json.gz \
| jq -Rr 'fromjson? | [.rule.id, .rule.level, .rule.description] | @tsv' \
| sort | uniq -c | sort -rn | head -25
These files hold only alerts. Events that matched no rule, or only a rule below log_alert_level (level 0 included), are kept only in /var/ossec/logs/archives/archives.json, and only if <logall_json>yes</logall_json> is set in ossec.conf (it is off by default).
Now apply the question from the top of the page to each line:
Each answer maps to one control, and each control lives in one place.
In a setup like the one in this guide, the list might come out like this:
| Item | Does a person need to act? | Control |
|---|---|---|
| snapd revision mount units, on every refresh | No, but you want to see them | Child rule, lower level |
/tmp/runc-process* on a Docker host |
No, and the data is useless | <ignore> on the agent |
| Short-lived UDP sockets in the port check | No, and the data is useless | Fix the command |
| Web 400s, PAM sessions, SSH logins (level 3 to 5) | No | Already below the threshold, leave them |
Step 2: Find the Parent Rule and a Free Rule ID
The child rule needs the parent’s ID. Take it from the alert, then find where that rule is defined:
sudo grep -rn -A6 'id="100200"' /var/ossec/etc/rules/
Then find the highest custom ID in use, and any duplicates:
sudo grep -rhoP 'id="\K1[01][0-9]{4}(?=")' /var/ossec/etc/rules/ | sort -n | tail -1
sudo grep -rhoP 'id="\K1[01][0-9]{4}(?=")' /var/ossec/etc/rules/ | sort -n | uniq -d
The second command should print nothing. Check this carefully, because a duplicate ID does not fail the configuration test. wazuh-analysisd logs warning (7612): Rule ID '<id>' is duplicated. Only the first occurrence will be considered. and silently drops the second rule.
Step 3: Write a Child Rule for snapd Mount Units
You need to know exactly what snapd writes. Each snap revision is mounted at /snap/<name>/<revision>, by a systemd mount unit in /etc/systemd/system. systemd requires a mount unit to be named after its mount point, with the path escaped, so /snap/lxd/33110 becomes snap-lxd-33110.mount. A hyphen inside a snap name is escaped as \x2d:
systemd-escape -p /snap/gnome-42-2204/176
snap-gnome\x2d42\x2d2204-176
snapd’s unit template enables each mount with WantedBy=snapd.mounts.target and WantedBy=multi-user.target, so you also get links in those two .wants directories. The naming rule works in your favour here. A file called snap-lxd-33110.mount can only control the mount point /snap/lxd/33110. It cannot mount anything over /usr/bin.
Open the file that holds the parent rule in vim (press i to insert, Esc then :wq to save and quit):
sudo vim /var/ossec/etc/rules/local_rules.xml
Add the child inside the same <group>, after the parent. The parent is shown here as an example. Keep your own if you already have one, and change 100201 to your free ID:
<group name="local,syscheck,persistence,">
<!-- Parent: any change to a systemd unit directory is worth a look. -->
<rule id="100200" level="12">
<if_sid>550,553,554</if_sid>
<field name="file" type="pcre2">^/etc/systemd/system/</field>
<description>Persistence location changed (systemd): $(file)</description>
<mitre>
<id>T1543.002</id>
</mitre>
</rule>
<!-- Child: snapd's own revision mount units. Recorded, not paged. -->
<rule id="100201" level="3">
<if_sid>100200</if_sid>
<field name="file" type="pcre2">^/etc/systemd/system/(?:(?:snapd\.mounts|multi-user)\.target\.wants/)?snap-(?:[a-z0-9_]|\\x2d)+-[0-9]+\.mount$</field>
<description>snapd revision mount unit changed (snap refresh): $(file)</description>
</rule>
</group>
What the pieces do:
<if_sid>550,553,554</if_sid>are the stock FIM rules for a changed, deleted and added file.fileis the decoded FIM field that appears assyscheck.pathin the alert.- The child matches only
snap-<name>-<revision>.mount, either directly in/etc/systemd/systemor in the two.wantsdirectories snapd uses.[a-z0-9_]covers snap names and parallel-install instance keys (lxd_test), and\\x2dmatches the literal text\x2d. The revision must be all digits. - Anything else still alerts at 12. That includes
snap-lxd-33110.service, a drop-in directory likesnap-lxd-33110.mount.d/, a link in any other.wantsdirectory, and locally installed snaps, whose revisions look likex1. - Level 3 keeps the event in
alerts.jsonand the dashboard while staying under the documented default email threshold of 7. Any level from yourlog_alert_levelto one below your paging threshold works. Choose level 0 only if you never want these in the dashboard. The FIM databases still track the file, but no alert is written.
The snap.<name>.* service, socket and timer units are harder. snapd rewrites them on every refresh because each carries Requires= and After= lines naming the current revision’s mount unit, and unlike mount units they run commands, so they are a real persistence target. If the server doesn’t use the snap, remove it, which removes the noise and the attack surface together:
snap list
sudo snap remove --purge lxd
--purge skips the data snapshot snapd otherwise keeps for 31 days. If you need the snap, add a second child scoped to that one snap’s units, for example ^/etc/systemd/system/(?:[a-z0-9-]+\.target\.wants/)?snap\.lxd\.[a-z0-9-]+(?:\.[a-z0-9-]+)?\.(?:service|socket|timer)$, keep it visible in the dashboard, and review it weekly (see What Not to Silence). sudo snap set system refresh.timer=sun,03:00-04:00 also confines refreshes to a window you choose.
Step 4: Validate the Rules and Restart the Manager
Test the configuration before restarting. A broken rule file stops wazuh-analysisd from starting, and that means no alerts at all:
sudo /var/ossec/bin/wazuh-analysisd -t && sudo systemctl restart wazuh-manager && echo OK
OK
Then confirm that no rule was skipped:
sudo grep -E '\(7612\)|\(7613\)' /var/ossec/logs/ossec.log | tail
The usual tool for testing rules is /var/ossec/bin/wazuh-logtest, which replaced ossec-logtest in Wazuh 4.1. Paste a log line and it shows the decoders and rules that match. It can’t test this rule. It submits every input as a log-file message, while FIM events arrive on their own queue and go through the FIM decoder. Use wazuh-logtest for rules on log lines (web server, sshd, application logs) and test FIM rules with real files, as in the next step.
Since 4.13 the server API can also reload the ruleset without a restart (in 4.14 the endpoint is PUT /manager/analysisd/reload). A restart is the simpler path when you are at a shell anyway.
Step 5: Test with Real Files on an Agent
On the test agent, create and delete one file the child should catch and one it must not:
sudo touch /etc/systemd/system/snap-lxd-1.mount /etc/systemd/system/zz-test.service
sleep 15
sudo rm /etc/systemd/system/snap-lxd-1.mount /etc/systemd/system/zz-test.service
You should be paged twice for zz-test.service, once for added and once for deleted, at rule 100200 level 12. You should get nothing for the .mount file. Then confirm on the manager that the mount was recorded rather than lost:
sudo jq -Rr 'fromjson? | select(.rule.id == "100201")
| "\(.rule.level)\t\(.agent.name)\t\(.syscheck.event)\t\(.syscheck.path)"' \
/var/ossec/logs/alerts/alerts.json | tail -5
3 web-01 added /etc/systemd/system/snap-lxd-1.mount
3 web-01 deleted /etc/systemd/system/snap-lxd-1.mount
rule.id is a string in the alert JSON, so quote it. rule.level is a number.
Step 6: Stop Collecting Useless FIM Data on the Agent
For every process it starts inside a running container, containerd’s runc wrapper writes the process spec to a temporary file named runc-process<random> (in $XDG_RUNTIME_DIR if it is set, otherwise the system temp directory, normally /tmp) and deletes it right after. docker exec does this, and so do Docker health checks, which run as exec processes. If you watch /tmp in real time (reasonable, since it is a common place to drop payloads), containers with health checks produce thousands of add and delete events a day. Nobody will ever act on one, and a level-0 child rule would still ship every event to the manager. Stop it at the agent.
Centralized configuration lives on the manager in /var/ossec/etc/shared/<group>/agent.conf and is pushed to every agent in that group. Edit a dot-file copy, because the manager does not distribute files whose names start with a dot, so agents never receive a half-written file:
sudo cp -p /var/ossec/etc/shared/default/agent.conf /var/ossec/etc/shared/default/.agent.conf.tmp
sudo vim /var/ossec/etc/shared/default/.agent.conf.tmp
Add the <ignore> inside the existing <syscheck> block:
<agent_config>
<syscheck>
<directories realtime="yes" check_all="yes">/tmp,/var/tmp,/dev/shm</directories>
<!-- containerd's runc wrapper writes a temp file here for every exec -->
<ignore type="sregex">^/tmp/runc-process</ignore>
</syscheck>
</agent_config>
Validate it, then move it into place:
sudo /var/ossec/bin/verify-agent-conf -f /var/ossec/etc/shared/default/.agent.conf.tmp
sudo mv /var/ossec/etc/shared/default/.agent.conf.tmp /var/ossec/etc/shared/default/agent.conf
verify-agent-conf: OK
Agents send the checksum of their merged configuration with every keepalive (every 20 seconds by default). When the checksum differs, the manager pushes the new file, and the agent reloads without a manual restart. Check which groups an agent belongs to with sudo /var/ossec/bin/agent_groups -s -i <AGENT_ID>. If the Docker host is not in default, put the line in its group’s agent.conf instead.
Step 7: Fix the Listening-Ports Check
The stock Linux check runs netstat -tulpn, which lists UDP sockets as well as TCP. A UDP socket that a client opens for a moment (an NTP query, a DNS or STUN lookup) shows up as listening if the check happens to run while it exists. The next run doesn’t see it, the output differs, and rule 533 fires. These sockets get their port from the kernel’s ephemeral range, /proc/sys/net/ipv4/ip_local_port_range (32768 to 60999 by default). That range is the filter.
This was my first version of the range check:
read -r lo hi < /proc/sys/net/ipv4/ip_local_port_range
It works in bash. Under /bin/sh, which is dash on Debian and Ubuntu, lo comes out as 3 and hi is empty. That is where the [: Illegal number: errors came from. strace shows why:
read(0, "3", 1) = 1
read(0, "", 1) = 0
dash’s read asks for one byte per read(2) call. Integer files under /proc/sys don’t behave like regular files: the kernel’s handler returns nothing for any read that doesn’t start at offset 0. The first one-byte read gets 3 and the second gets end-of-file. bash, under the same strace, asks for 4,096 bytes in one call and gets the whole line. cat also reads in blocks, so the fix is to read the file with cat.
Here is the full script. It prints protocol, address and process names without PIDs, so the output only changes when a listener really changes:
sudo vim /var/ossec/etc/listening-ports.sh
#!/bin/sh
# Stable list of listening sockets for Wazuh command monitoring:
# protocol, local address:port, owning process names (no PIDs).
# UDP sockets inside the kernel's ephemeral port range are skipped. They are
# short-lived client sockets and make the output change between runs.
# Read the range with cat, not the read builtin. dash's read asks for one byte
# per read(2) call, and integer files in /proc/sys return end-of-file to any
# read that does not start at offset 0, so read would get "3" and nothing else.
set -- $(cat /proc/sys/net/ipv4/ip_local_port_range)
lo=$1
hi=$2
case "$lo,$hi" in
,* | *, | *[!0-9,]*)
# Print to stdout on purpose: the output changes, so Wazuh alerts.
echo "listening-ports.sh: cannot read ip_local_port_range"
exit 1
;;
esac
ss -tulnpH | while read -r net state recvq sendq local peer proc; do
port=${local##*:}
if [ "$net" = udp ] && [ "$port" -ge "$lo" ] && [ "$port" -le "$hi" ]; then
continue
fi
names=$(printf '%s' "$proc" | grep -o '"[^"]*"' | tr -d '"' | sort -u | tr '\n' ',')
echo "$net $local ${names%,}"
done | sort -u
ss -tulnpH lists TCP and UDP (-t -u) listening sockets (-l) with numeric ports (-n), the owning processes (-p), and no header (-H). ${local##*:} takes everything after the last colon, which works for 0.0.0.0:22, [::]:22 and 127.0.0.53%lo:53 alike. The case guard makes a failure loud. If the range can’t be read, the output changes and you get an alert instead of a check that silently stopped working.
Lock it down, because logcollector runs it as root:
sudo chown root:wazuh /var/ossec/etc/listening-ports.sh
sudo chmod 0750 /var/ossec/etc/listening-ports.sh
sudo sh /var/ossec/etc/listening-ports.sh
tcp 0.0.0.0:22 sshd
tcp [::]:22 sshd
tcp *:443 nginx
udp 127.0.0.1:323 chronyd
udp 127.0.0.53%lo:53 systemd-resolve
You should see no errors, every TCP listener, and only fixed-port UDP services.
Know what you give up. A UDP listener bound inside the ephemeral range is no longer seen, backdoor or not. TCP listeners are always seen. A WireGuard interface on port 51820, the port in WireGuard’s own quick start, drops off the list too (kernel sockets like WireGuard’s show no process in ss). If you use this filter, give fixed UDP services ports below 32768. For WireGuard that is the ListenPort line in the interface config (the WireGuard article shows where it goes; its example port is inside the ephemeral range).
On the manager, register the check in ossec.conf (sudo vim /var/ossec/etc/ossec.conf) with the alias rule 533 expects:
<ossec_config>
<localfile>
<log_format>full_command</log_format>
<command>/bin/sh /var/ossec/etc/listening-ports.sh</command>
<alias>netstat listening ports</alias>
<frequency>360</frequency>
</localfile>
</ossec_config>
Keep the alias exactly netstat listening ports, because rule 533 matches on it. Replace the stock netstat -tulpn block with this one rather than adding it alongside. Two commands with the same alias overwrite each other’s saved output, and you get an alert every six minutes. To page on port changes, add a child of 533 at your paging level:
<group name="local,">
<rule id="100210" level="12">
<if_sid>533</if_sid>
<description>Listening ports changed: possible backdoor listener</description>
<mitre>
<id>T1571</id>
</mitre>
</rule>
</group>
Put the rule in local_rules.xml, then run the test-and-restart command from Step 4. The restart also makes logcollector load the new <localfile> block.
Step 8: Deploy the Script to Every Agent
Each agent runs its own copy of the check. I changed the script on the manager first, and the next alert came from an agent running its own, unchanged copy. Ansible puts the script and the <localfile> block on every agent. Save this playbook as listening-ports.yml, with the script from Step 7 at files/listening-ports.sh beside it. ossec.conf may contain more than one <ossec_config> block, so the managed block can sit at the end of the file:
- name: Deploy the Wazuh listening-ports check
hosts: wazuh_agents
become: true
tasks:
- name: Install the check script
ansible.builtin.copy:
src: files/listening-ports.sh
dest: /var/ossec/etc/listening-ports.sh
owner: root
group: wazuh
mode: "0750"
- name: Register the check with logcollector
ansible.builtin.blockinfile:
path: /var/ossec/etc/ossec.conf
marker: "<!-- {mark} ANSIBLE MANAGED: listening ports -->"
backup: true
block: |
<ossec_config>
<localfile>
<log_format>full_command</log_format>
<command>/bin/sh /var/ossec/etc/listening-ports.sh</command>
<alias>netstat listening ports</alias>
<frequency>360</frequency>
</localfile>
</ossec_config>
notify: Restart wazuh-agent
handlers:
- name: Restart wazuh-agent
ansible.builtin.systemd_service:
name: wazuh-agent
state: restarted
ansible-playbook -i <INVENTORY> listening-ports.yml
The marker must be an XML comment, because the default # BEGIN ANSIBLE MANAGED BLOCK is not valid in ossec.conf. Remove the stock netstat block from the agents too. The Ansible certificate article covers other traps of pushing files across a mixed fleet.
You could push the <localfile> through agent.conf instead, but agents ignore command and full_command sources from centralized configuration unless logcollector.remote_commands=1 is set in their /var/ossec/etc/local_internal_options.conf. With that on, anyone who can write to the manager’s shared directory can run commands as root on every agent in the group. I prefer Ansible.
Expect one last alert per agent: the first run of the new script differs from the stored output of the old one.
Verify
Count paging alerts per hour. Hours after the change should drop to the alerts you would actually act on:
sudo jq -Rr --argjson min 12 'fromjson? | select(.rule.level >= $min) | .timestamp[0:13]' \
/var/ossec/logs/alerts/alerts.json | uniq -c
Each line is a count followed by a date and hour, such as 2026-11-30T09. Run the same filter over the rotated files from Step 1 to compare with the days before.
The suppressed snap events are still there, at the lower level:
sudo jq -Rr 'fromjson? | select(.rule.id == "100201") | "\(.timestamp)\t\(.agent.name)\t\(.syscheck.path)"' \
/var/ossec/logs/alerts/alerts.json | tail
The runc ignore works once the newest runc event stops getting newer. Replace <AGENT_NAME> with the Docker host’s agent name, then run this now and again ten minutes later:
date -u +%FT%T
sudo jq -Rr 'fromjson? | select(.agent.name == "<AGENT_NAME>" and ((.syscheck.path // "") | startswith("/tmp/runc-process"))) | .timestamp' \
/var/ossec/logs/alerts/alerts.json | tail -1
When a port alert does fire, this shows exactly which lines changed on that agent:
a=$(sudo jq -Rc 'fromjson? | select(.location == "netstat listening ports" and .agent.name == "<AGENT_NAME>")' \
/var/ossec/logs/alerts/alerts.json | tail -1)
diff <(printf '%s\n' "$a" | jq -r .previous_output) <(printf '%s\n' "$a" | jq -r .full_log)
1d0
< Previous output:
15d13
< udp *:39012
What Not to Silence
Tuning is only safe if detection survives it. These should always reach a person, and none of the controls above touch them:
- Any other change under
/etc/systemd/system. New.serviceand.timerunits, drop-in directories, and links in any.wantsdirectory other than the two snapd uses. The child rule in Step 3 is deliberately narrow so these still page. - New listening TCP ports, and UDP services on fixed ports. The port filter skips only UDP inside the ephemeral range.
- Authentication failures in bulk. Stock rules 5712 and 5763 (sshd brute force) and 5551 (multiple PAM failures) are level 10. With a paging threshold of 12, as assumed in this guide, they never notify anyone. Promote them with child rules rather than lowering the threshold for everything.
- Account and privilege files.
/etc/passwd,/etc/shadow,/etc/sudoersand/etc/ld.so.preloadshould page on any change. - An agent going quiet. Rules 504 (agent disconnected) and 506 (agent stopped) are level 3. Stopping the agent is an obvious early move for an attacker, so watch for them on servers that never reboot unannounced.
Suppressed is not the same as unseen, so review it. Once a week, run the child-rule query from Verify and check that each snap mount event lines up with a refresh in snap changes on that agent. A suppressed mount unit with no matching refresh is worth a look. Agent-side ignores leave nothing to review, because the events never leave the agent, so review the ignore list itself whenever someone adds a line.
Troubleshooting
- The child rule never matches: the child must name the parent’s ID in
<if_sid>, and the regex must match the full path fromsyscheck.path. Test the pattern against a real path withprintf '%s\n' '<PATH>' | grep -P '<REGEX>'. Wazuh hands the XML text to PCRE2 unchanged, so the rule needs\\x2dto match the literal text\x2d. - The child rule loads but another rule disappeared: a duplicate ID. Look for
(7612)in/var/ossec/logs/ossec.logand run theuniq -dcheck from Step 2. [: Illegal number:from the port script: dash’sreadon a/proc/sysfile. Usecat(Step 7).- Port alerts keep coming from one agent after the fix: that agent still has the old script, or two
<localfile>blocks with thenetstat listening portsalias. Runsudo grep -n -B3 -A3 'netstat listening ports' /var/ossec/etc/ossec.confon the agent. <ignore>inagent.confhas no effect: the agent isn’t in that group (agent_groups -s -i <AGENT_ID>), or the file failedverify-agent-conf. Look forAgent is reloading due to shared configuration changesin the agent’s/var/ossec/logs/ossec.log.- A
full_commandblock inagent.confnever runs:logcollector.remote_commands=1is not set on the agent. See Step 8 for why I deploy it with Ansible instead.
Sources and further reading
- Wazuh 4.14.11 release notes: current release, November 25, 2026.
- Wazuh releases on GitHub: 4.14.11 marked latest, and the 5.0 release candidates that replace the 4.x
analysisd. - Wazuh: Rules classification: levels 0 to 16 and what level 0 means.
- Wazuh: Rules syntax:
if_sid,if_group,field,match,check_diff,$(field)in descriptions. - Wazuh: Regular expression syntax: sregex special characters and PCRE2.
- Wazuh: Custom rules: the 100000 to 120000 ID range,
local_rules.xml,overwrite. - Wazuh: alerts reference and integration reference:
log_alert_level,email_alert_level, integrationlevel. - Wazuh: global reference:
logall_jsonandarchives.json. - Wazuh: syscheck reference:
realtime,ignore,nodiff,report_changes. - Wazuh: Creating custom FIM rules: FIM field
filemaps tosyscheck.path. - Wazuh: localfile reference:
full_command,alias,frequency,logcollector.remote_commands. - Wazuh: Check if the output changed: the stock netstat check and rule 533.
- Wazuh: Centralized configuration: dot-file editing,
verify-agent-conf, how agents reload. - Wazuh: wazuh-logtest and wazuh-analysisd:
-tconfiguration test. - Wazuh source, v4.14.11:
ruleset/rules/0015-ossec_rules.xml(rules 530, 533, 550 to 554),src/analysisd/dodiff.c(where previous output is stored),src/analysisd/logtest.c(why FIM events can’t be replayed),src/analysisd/rules.c(warning 7612). - systemd.mount: mount units are named after their mount point.
- snapd source:
systemd/systemd.go(mount unit template andWantedBy),wrappers/internal/(service unitsRequires=the revision mount). - Snapcraft: Manage updates and Create data snapshots: four refreshes a day,
refresh.timer,snap changes,--purge. - go-runc: runc.go and moby: daemon/health.go: the
runc-processtemp file written for every exec, and health checks run as exec. - Linux: ip-sysctl documentation:
ip_local_port_rangeand its defaults. - Linux source: kernel/sysctl.c: reads of integer sysctls at a non-zero offset return nothing.
- Ubuntu wiki: DashAsBinSh:
/bin/shis dash. - ss(8):
-t -u -l -n -p -H. - WireGuard quick start:
listen-port 51820in the example. - Ansible blockinfile:
markerdefault and XML comment markers.