# The WordPress event chain in Wazuh logs and rules

> Tie together access log, PHP and WordPress application events in Wazuh rules: the 207 code from /batch/v1, rest_route, user creation and correlation.

Published: 2026-10-20. Updated: 2026-11-12. Category: Analysis. Tags: Wazuh 4. MITRE ATT&CK: T1190, T1595.002, T1071.001. Wazuh rules: 31103, 31106, 31151, 31411. URL: https://wazuh.blog/en/blog/wordpress-event-chain/ Polish original: https://wazuh.blog/blog/wordpress-lancuch-zdarzen/

A single access log entry rarely describes a whole attack on WordPress, because the trace is spread across several sources: the web server log, the PHP log and the events of the application itself. For this reason correlation rules need an explicit decision on which event is a link, which key joins them and in what time window.

## What sources make up the chain

For a WordPress installation on a web server, three streams are usually collected. The access log shows the method, address, response code and source address. The PHP error log shows warnings and runtime errors. The application log, if a plugin or custom code creates one, describes domain events such as user creation or a role change.

In the agent configuration they are pointed to by `localfile`. The documentation lists the formats `apache` (for Apache access and error logs), `syslog` (for most text logs with one entry per line) and `json` (for single JSON lines), and in `location` it allows wildcards and `strftime` formats. The paths in the example are illustrative.

```xml
<ossec_config>
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/example-site/access.log</location>
  </localfile>
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/example-site/php-errors.log</location>
  </localfile>
  <localfile>
    <log_format>json</log_format>
    <location>/var/log/example-site/wp-events.json</location>
  </localfile>
</ossec_config>
```

Choosing `syslog` for the access log is a recommendation in line with the general guidance of the documentation, because the format name depends on how the server writes the line. The `web-accesslog*` decoder family recognizes nginx and apache lines preceded by a syslog header, as well as the plain NCSA format, and it requires the `web-log` type so that the web rules have something to match.

## What the access log shows

The decoder extracts `srcip`, `url` and `id` from the line. The `url` field holds the whole address with the query, and `id` holds the response code. The web rules from the file `0245-web_rules.xml` rely on these three fields.

| ID | Level | Meaning |
|---|---|---|
| 31100 | 0 | Groups access logs |
| 31101 | 5 | Response code starting with 4 |
| 31103 | 7 | SQL injection in address patterns (`union%20`, `select+` and similar) |
| 31164 | 6 | SQL injection in the `%27`, `select%2B` encoding |
| 31106 | 6 | Attack from 31103, 31104 or 31105 that returned a code starting with 200 |
| 31151 | 10 | Many 400 codes from one address, 14 in 90 seconds |

The parent in `if_matched_sid` must have a level of at least 1: the documentation says that level 0 rules are discarded immediately and cannot be used with `if_matched_sid`. Rules 31100 and 31108 are at level 0, so correlation built directly on them will not work. It has to be based on a rule of level 1 or higher.

## A request through /batch/v1 and the 207 code

The WordPress REST interface has the endpoint `/wp-json/batch/v1`, which runs many sub-requests in one. The documentation of the class `WP_REST_Server::serve_batch_request_v1` gives the details: each sub-request is an object with the fields `path`, `method` (POST by default), `body` and `headers`, and the route must explicitly allow batch mode through `allow_batch`, otherwise the error `rest_batch_not_allowed` with status 400 is returned. The method always ends with the response `WP_Http::MULTI_STATUS`, that is 207, and the sub-request results go into the `responses` array.

For detection this means:

- Code 207 is the normal result of a batch regardless of the sub-request results, so in the access log it does not tell success from failure. RFC 4918 defines 207 as the status for many independent operations.
- The access log shows only the outer address and the POST method. The sub-request paths are in the request body, which the access log does not contain.
- Rule 31106 requires an `id` starting with 200, so code 207 does not match it. This conclusion comes from reading the rules file, not from observing a running engine.

The `/batch/v1` pattern in `url` covers both address variants, because for installations without pretty permalinks the REST endpoint is available through the `?rest_route=` parameter. The WordPress documentation shows that the address `?rest_route=/` replaces the `/wp-json/` prefix, and the `Link` header in the response points to exactly that address.

## Creating a user through REST

An account is created through `POST /wp/v2/users`. `username`, `email` and `password` are required, and roles are a separate argument. Authentication is described by two pages: the `wp_rest` nonce passed in the `X-WP-Nonce` header (without the nonce the request is treated as not logged in) and application passwords with basic authentication. The request itself in the access log therefore takes the form of a POST to the users address or, with a batch, a POST to `/batch/v1`. Reliable confirmation that the account was created, and with what role, comes only from an application event.

## Rules for the access source

The rules below are a recommendation, not part of the ruleset. The first recognizes a batch ending with code 207, the second counts repeats from one address.

```xml
<group name="web,wordpress,">
  <rule id="100530" level="3">
    <if_sid>31100</if_sid>
    <url>/batch/v1</url>
    <id>^207$</id>
    <description>WordPress REST: batch request returned 207.</description>
    <options>no_log</options>
  </rule>

  <rule id="100531" level="10" frequency="4" timeframe="120">
    <if_matched_sid>100530</if_matched_sid>
    <same_srcip />
    <description>WordPress REST: repeated batch requests from one source.</description>
  </rule>
</group>
```

Level 3 in the first rule meets the requirement of level 1 or higher, and the `no_log` option, according to the documentation, prevents the helper event itself from being logged. The `frequency` (2 to 9999) and `timeframe` (1 to 99999) fields have the ranges from the syntax documentation. By default rules are counted for a single agent, and `same_srcip` requires the same decoded source address. The mechanism is described in [Event correlation in Wazuh](/en/blog/wazuh-event-correlation/).

## Rules for the application log

For a JSON log with application events whose keys have the `wp_` prefix (rationale in the post [FIM for WordPress](/en/blog/fim-wordpress-collisions/)), the scheme matches the `same_field` example in the documentation, where rule 100002 counts four events of rule 100001 with the same key value within 300 seconds.

```xml
<group name="wordpress,">
  <rule id="100540" level="5">
    <decoded_as>json</decoded_as>
    <field name="wp_event_type">^user_created$</field>
    <description>WordPress: user account created.</description>
  </rule>

  <rule id="100541" level="10" frequency="3" timeframe="300">
    <if_matched_sid>100540</if_matched_sid>
    <same_field>wp_actor</same_field>
    <description>WordPress: multiple accounts created by the same actor.</description>
  </rule>
</group>
```

A test event in one line:

```text
{"wp_event_type":"user_created","wp_actor":"example-admin","wp_target":"example-user-01","wp_role":"administrator"}
```

## A synthetic chain

The chain these rules are meant to catch has five links. The table below is a test scenario.

| Step | Source | Event | Rule |
|---|---|---|---|
| 1 | Access log | `POST /wp-json/batch/v1` from address 203.0.113.5, code 207 | 100530 |
| 2 | Access log | three more such requests within 120 seconds | 100531 |
| 3 | PHP log | PHP warning in the same window | 31410 |
| 4 | Application log | `wp_event_type` equal to `user_created`, administrator role | 100540 |
| 5 | Access log | request to the admin panel from the new account | no rule |

Rule 31410 has level 3 and the description `PHP Warning message.`, and 31411 has level 6 (`PHP web attack.`), and the identifier range 31401 to 31500 is assigned to PHP rules. Steps 1 to 4 have their own rules, and step 5 needs a rule written for a specific log format, which the documentation does not describe.

## Time windows and threshold

The correlation window is set separately for each link. Batches from one address usually arrive in series, so a short `timeframe` (120 seconds in the example) with a low `frequency` threshold catches a series of batches. Account creation is rare, so for rule 100541 a longer window (300 seconds, as in the documentation example) makes sense with a threshold of 3. This is a recommended choice, the documentation gives only the allowed ranges.

Two properties of `frequency` affect the design. First, events are counted for a single agent, so a chain spread over several web servers behind a load balancer will not add up in one rule (the `global_frequency` parameter works at the manager level, not the cluster). Second, `same_srcip` and `same_field` compare the value with the previous events, so a missing or undecoded key means no match, not a match of an empty value. The second conclusion is a recommendation to check in logtest, because the documentation does not settle it.

## Linking the links across sources

A correlation rule joins events of one kind in one stream. Joining the access log with the application log needs a common key. For `same_srcip` only the decoded `srcip` is useful, and a JSON key named `wp_actor_ip` is not one, so `same_srcip` will not see it. Two routes (recommendations):

- Send the client address in the application log under a key that the decoder maps to `srcip`, and check it in logtest before basing a rule on it.
- Join the events at the analysis stage, filtering the alerts of rules 100531 and 100541 by time and address. The difference between the alert stream and the full archive is described in [Archives vs alerts in Wazuh](/en/blog/wazuh-archives-vs-alerts/).

Verify the rules for the access and JSON logs with the fixture table described in the post [WordPress rules: tests](/en/blog/wordpress-rules-testing/), with a sequence of lines in one session for rules with `frequency`.

## Checklist

- Each stream has a `localfile` with the right `log_format` and a confirmed decoder in phase 2 of logtest.
- Parents in `if_matched_sid` have a level of at least 1.
- The keys that join events (`srcip`, `wp_actor`) are decoded, not merely present in the log.
- The `/batch/v1` pattern is checked in both address variants, `/wp-json/batch/v1` and `?rest_route=/batch/v1`.
- An alert from rule 31106 is not the only indicator of a successful attack, because a batch returns 207.
- Identifiers of custom rules from the range 100000 and up are unique across the whole ruleset.

## What the documentation does not specify

- The behavior of two sibling rules with the same parent, for example 100530 and 31108, when both match the same line.
- Combining `if_sid` and `if_matched_sid` in one rule to link two different sources.
- Mapping a JSON key to `srcip` in the `json` decoder.
- Matching the `/batch/v1` pattern when `rest_route` is written with percent encoding.
- Handling of a batch in the access log, beyond the fact that the response code is 207. The description comes from the WordPress class code.
- The format of the application log with `wp_event_type`: this is a proposal, WordPress does not create such a log.

## Sources

- https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/rules.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/localfile.html
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/rules/0245-web_rules.xml
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/decoders/0375-web-accesslog_decoders.xml
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/ruleset/rules/0265-php_rules.xml
- https://developer.wordpress.org/rest-api/key-concepts/
- https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
- https://developer.wordpress.org/rest-api/reference/users/
- https://developer.wordpress.org/rest-api/reference/application-passwords/
- https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/
- https://developer.wordpress.org/reference/classes/wp_rest_server/serve_batch_request_v1/
- https://developer.wordpress.org/reference/classes/wp_http/
- https://www.rfc-editor.org/rfc/rfc4918.html
