FIM for WordPress: directories, alert fields and rule collisions
Syscheck configuration for a WordPress tree, FIM alert fields, rules 550, 553 and 554, and collisions with rule 86600 when JSON keys have generic names.
A WordPress tree contains code that should change only during updates, and directories the application can write to. A good FIM configuration separates these two classes, and rules added next to the built-in ones have to be checked for collisions, because a syntactically correct rule may never fire.
What to monitor in a WordPress tree
The WordPress documentation lists the main parts of an installation: wp-admin, wp-includes, wp-content (with themes, plugins and uploads) and the wp-config.php file. It also recommends permissions 644 or 640 for files, and 440 or 400 for wp-config.php. wp-content, wp-content/cache and sometimes wp-content/uploads may be writable, because some plugins require it.
From this split comes a proposed configuration (a recommendation, not a documentation requirement): cover core code and configuration with full monitoring, and limit writable directories with a filter. The paths in the example are synthetic.
<syscheck>
<!-- Core code: changes are expected only during updates -->
<directories realtime="yes" check_all="yes" tags="wp-core">/var/www/example.com/wp-admin</directories>
<directories realtime="yes" check_all="yes" tags="wp-core">/var/www/example.com/wp-includes</directories>
<!-- Single file, scheduled scan only -->
<directories check_all="yes" tags="wp-config">/var/www/example.com/wp-config.php</directories>
<!-- Writable tree: watch executable content only -->
<directories realtime="yes" restrict=".php$" tags="wp-uploads">/var/www/example.com/wp-content/uploads</directories>
<ignore type="sregex">/wp-content/cache/</ignore>
</syscheck>
The entry for wp-config.php is a file, not a directory. The documentation states that realtime works only with directories, and report_changes supports both directories and single files, so a single file is left with the periodic scan.
The directories attributes
Default values come from the syscheck reference.
| Attribute | Default | Meaning |
|---|---|---|
realtime | no | Continuous monitoring (inotify on Linux), directories only |
whodata | no | Information on who changed the file (Linux and Windows) |
report_changes | no | Report of content changes, limited to text files |
diff_size_limit | 50MB | Larger files do not report differences |
check_all | yes | Changes the value of all attributes with the check_ prefix |
restrict | none | Limits the check to files whose name contains the given string (sregex) |
tags | none | Adds tags to alerts for the given directory |
recursion_level | 256 | Maximum recursion depth, 0 to 320 |
follow_symbolic_link | no | Following a link given directly in the configuration |
When attributes modify the same value, the last one wins. The notation check_all="no" check_sha256="yes" enables SHA-256, and the reversed order disables it. A block without wildcards takes precedence over a block with * for the same path.
Cost of the options
report_changes copies every monitored file to a private location (/var/ossec/queue/diff/* on Linux), which increases disk use. For files with secrets, such as wp-config.php, the documentation provides the nodiff exception: the change alert is created, but the content does not go into the alert.
<syscheck>
<directories check_all="yes" report_changes="yes">/var/www/example.com/wp-content/themes</directories>
<nodiff>/var/www/example.com/wp-config.php</nodiff>
</syscheck>
On Linux, whodata uses the Audit subsystem, so it requires the auditd daemon to be installed. The default provider is audit, and the value ebpf falls back to audit when the health check fails.
Frequency, exclusions and limits
The periodic scan runs every 43200 seconds by default (frequency). The scan_on_start option is accepted but has no effect: the startup scan always creates the baseline. Files created after the initial scan come under monitoring only at the next periodic scan, and in real-time mode detection is paused for the duration of the scan.
ignore does not disable scanning: the indicated paths are still scanned, but the results are not reported. An entry with type="sregex" takes a simple pattern, for example .log$|.swp$. Two limits protect against flooding: max_eps (default 50 events per second) and auto_ignore with the defaults frequency="10" and timeframe="3600", which the manager reads from its own <syscheck> section and which does not work in the agent configuration.
FIM alert fields
The decoder extracts event fields, and the server translates them into alert fields. You write rules on the decoder names (left column), and in the index you search by the alert names.
| Decoder field | Alert field | Description |
|---|---|---|
file | syscheck.path | File path |
changed_fields | syscheck.changed_attributes | Changed attributes (array, e.g. permission) |
perm | syscheck.perm_after | Permissions after the change |
sha256 | syscheck.sha256_after | SHA-256 hash after the change |
size | syscheck.size_after | Size after the change |
mtime | syscheck.mtime_after | Change time |
changed_content | syscheck.diff | Changed content (with report_changes) |
tag | syscheck.tag | Event tag |
user_name | syscheck.audit.user.name | Acting user (whodata) |
process_name | syscheck.audit.process.name | Acting process (whodata) |
The alert from the documentation also contains syscheck.event (modified, in another example deleted) and syscheck.mode (realtime). The syscheck. prefix in the last four rows is an assumption based on where these fields sit in the sample alert; the documentation table gives only the part after the dot. A broader discussion of the fields is in the post FIM in Wazuh: syscheck configuration.
Built-in FIM rules
The 0015-ossec_rules.xml file from release 4.14.0 defines three basic file event rules.
| ID | Level | Decoder | Description |
|---|---|---|---|
| 550 | 7 | syscheck_integrity_changed | Integrity checksum changed. |
| 553 | 7 | syscheck_deleted | File deleted. |
| 554 | 5 | syscheck_new_entry | File added to the system. |
Next to them are 555 (level 7, agentless) and 560 (level 7, FIM real-time queue is full. Some real-time events may be lost.). Rule 560 is a signal that the real-time queue overflowed and some events may have been lost, so cover it with monitoring of the monitoring itself.
A new .php file in a writable directory therefore gets level 5 from rule 554, and a modification of an existing file gets level 7. A local rule can tighten this by inheriting from 554 through if_sid. The documentation describes if_sid as the equivalent of a child decoder, with the difference that a rule can have any number of children.
<group name="syscheck,">
<rule id="100510" level="10">
<if_sid>554</if_sid>
<field name="file" type="pcre2">/uploads/.+\.php$</field>
<description>FIM: PHP file added under uploads directory.</description>
</rule>
</group>
The file field is the name from the decoder, as in the documentation example (<field name="file">.sh$</field>). The attribute type="pcre2" is documented for field. The identifier 100510 falls in the custom rule range; the file load order is described in Wazuh: loading rules and decoders.
Collision with rule 86600
The built-in Suricata rules (range 86600 to 86699) contain a parent rule that matches every event decoded by json if it has the fields timestamp and event_type.
<rule id="86600" level="0">
<decoded_as>json</decoded_as>
<field name="timestamp">\.+</field>
<field name="event_type">\.+</field>
<description>Suricata messages.</description>
<options>no_full_log</options>
</rule>
The pattern \.+ in OS_Regex syntax means one or more arbitrary characters, because \. matches any character, and a bare dot matches a literal dot. The condition is therefore met for any non-empty value. The children of this rule (86601 to 86604) check the values alert, http, dns and tls, and 86601 has level 3 and the description Suricata: Alert - $(alert.signature).
The consequence for your own JSON events: an application log with the keys timestamp and event_type matches 86600 regardless of what was added in the WordPress pack. If your own parent rule has decoded_as equal to json and a condition on event_type, both rules compete for the same event. The documentation does not describe how the engine resolves such a tie (see below), so do not assume the outcome, measure it.
Why a generic JSON key is a risk
The json decoder has a prematch of the form ^{\s*", so it catches every entry that starts with a JSON object. Fields reach the rules under the names of the keys, nested ones with a dot (alert.signature_id). Key names are therefore a contract with every rule in the ruleset, not only with your own. Design rules:
- Give your own keys a pack prefix, for example
wp_event_typeinstead ofevent_type. - Do not use
timestampandevent_typetogether if you do not want Suricata events. - Before choosing a name, search for it in the ruleset (
rg 'name="event_type"' /var/ossec/ruleset/rules) and check which rules use it. - Consider a separate decoder with a
prematchon a marker of your own format, the way the built-injson-msgraphrecognizes"integration":"ms-graph"before the genericjson. The rules for writing decoders are described in Wazuh custom decoders.
Verification in wazuh-logtest
Paste the JSON event into /var/ossec/bin/wazuh-logtest as one line, because the documentation requires converting multi-line JSON to a single line. Synthetic example:
{"timestamp":"2026-10-20T10:00:00+0000","wp_event_type":"user_created","wp_user":"example-admin","src_ip":"192.0.2.10"}
In phase 2, check name: 'json' and the field names; in phase 3, check id, level and description. A test with the key event_type in place of wp_event_type will show whether you hit 86600. You cannot feed FIM events the same way: the documentation does not describe an input format for syscheck, so a FIM rule is checked by triggering a change on test files, as in the touch and chmod +x example in the custom rules documentation. Working with the tool is described in Testing rules and decoders with wazuh-logtest, and scenarios for the WordPress pack in WordPress rules: testing.
Pre-deployment checklist
- Code directories have
realtimeandcheck_all, writable directories haverestrictorignore. - Files with secrets have
nodiffifreport_changesis enabled. - Custom rule IDs fall in the range 100000 and above and do not repeat.
- JSON keys have a prefix, and their names were checked against existing rules.
- A test on the full ruleset shows the expected
rule.idandlevelfor positive events and no alert for ordinary updates. - Rule 560 goes to monitoring.
Changing the level of an existing rule through overwrite changes the detection semantics of all events of that rule, so it requires an analysis of the impact on alerts, not only a test of one event.
What the documentation does not specify
- The rule for deciding which of several matching sibling rules is returned in phase 3, and the role of the level in such a tie.
- The precedence of a custom decoder with
prematchover the built-injsondecoder. - The syscheck event input format for
wazuh-logtest. - The
syscheck.prefix for thetagandaudit.*fields in the mapping table (taken from the alert example). - A list of WordPress paths recommended for monitoring, and inotify limits for large trees.
Sources
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/syscheck.html
- https://documentation.wazuh.com/current/user-manual/capabilities/file-integrity/basic-settings.html
- https://documentation.wazuh.com/current/user-manual/capabilities/file-integrity/advanced-settings.html
- https://documentation.wazuh.com/current/user-manual/capabilities/file-integrity/creating-custom-fim-rules.html
- https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/rules.html
- https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/regex.html
- https://documentation.wazuh.com/current/user-manual/ruleset/decoders/json-decoder.html
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/rules/0015-ossec_rules.xml
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/rules/0475-suricata_rules.xml
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/decoders/0006-json_decoders.xml
- https://developer.wordpress.org/advanced-administration/server/file-permissions/
- https://developer.wordpress.org/advanced-administration/security/hardening/