Active response in Wazuh 4.14: what firewall-drop trusts, white_list and the timeout key
Where active response gets srcip, how white_list evaluates it, what execd uses to recognize a repeat, and how to limit blocking to trusted address sources.
An automatic block is only as trustworthy as the address the decoder pulled out of the log. If that address comes from a part of the line the client controls, firewall-drop blocks whichever address the attacker picks, and white_list won’t always keep your own addresses safe. Everything below applies to Wazuh 4.14: documented behavior first and, where the documentation runs out, the wazuh/wazuh source at 4.14.11, marked “in the 4.14.11 code”. I read that code; I did not run it.
Where active response gets the address
The decoder fills srcip: its <order> element maps a capture group of its regular expression to that field. The documentation calls the field “Source IP address”, but it is still just text from the log line. With <accumulate /> the value can also come from an earlier line with the same id. Per the documentation, the decoder then fills only empty fields, and stored values expire 120 seconds after the last matching line.
Before analysisd fires a response, it checks two decoded fields. In the 4.14.11 code this happens inside the loop over the active-response blocks attached to the rule:
if (lf->dstuser && !OS_PRegex(lf->dstuser, "^[a-zA-Z._0-9@?-]*$")) {
mwarn(CRAFTED_USER, lf->dstuser);
do_ar = 0;
}
if (lf->srcip && !OS_PRegex(lf->srcip, "^[a-zA-Z.:_0-9-]*$")) {
mwarn(CRAFTED_IP, lf->srcip);
do_ar = 0;
}
The filter accepts letters, digits, ., :, _ and -. Any other character produces a warning and the response is skipped. Anything inside that set goes through, a host name included. The script is the second gate. The compiled default-firewall-drop reads the address with get_srcip_from_json, which, per a comment in the code, validates it. If srcip is missing or malformed, the script logs “Cannot read ‘srcip’ from data or invalid IP format” at debug level and blocks nothing. A valid address is passed to iptables or ip6tables as -s <address> -j DROP in the INPUT and FORWARD chains.
Both gates check what the address looks like, not where it came from. If a decoder captures it from a client-controlled part of the line (a header, a field the application passes through), the attacker decides which valid address gets blocked. Whether a stock decoder is exposed depends on its regex and the log format, so review both for every decoder a block relies on.
How white_list evaluates the address
white_list in the global section, set on the server or on a local install, is what stops you from blocking your own infrastructure. According to the documentation, Wazuh compares it with the decoded srcip, and an entry can be an IPv4 or IPv6 address, a network block or a host name, one value per <white_list> element. The 4.14.11 code reads these entries more narrowly:
white_list entry | Where it goes in the 4.14.11 code |
|---|---|
IPv4 or IPv4 with a mask (/24 or a dotted mask) | address list, checked with OS_IPFoundList |
| anything else, including IPv6 notation and a host name | list of OSMatch patterns, compiled at startup |
An entry that matches the IPv4 expression is validated with OS_IsValidIP; an invalid one is a configuration error. Every other entry becomes a pattern matched against the srcip text, not against an address in the network sense. So IPv6 entries have no subnet semantics, even though the documentation allows them. Host names are patterns too: analysisd matches them against the srcip text and does no DNS lookup on this path. A host name entry does not cover the address that name resolves to, so it is no use for protecting infrastructure.
That leaves the first row of the table as the only safe form: a single IPv4 address or an IPv4 network with a mask. The example uses documentation ranges:
<ossec_config>
<global>
<white_list>192.0.2.10</white_list>
<white_list>198.51.100.0/24</white_list>
</global>
</ossec_config>
Don’t put negations in white_list. The expression global-config.c uses to recognise an address entry accepts a leading !, but OS_IsValidIP advances past the ! before copying the address into the entry (validate_op.c, lines 493–501). The negation check in OS_IPFoundList (line 445) looks at the first character of the stored entry, where the ! no longer exists. Reading the code, !192.0.2.10 behaves like 192.0.2.10: instead of excluding the address, it protects it. I have not confirmed this on a running installation.
analysisd checks the list in the function that builds the response message, before the execution location is picked. It strips a ::ffff: prefix, compares the address with the IPv4 list and then with the pattern list, and on a match sends no response at all. This works the same for every location. An event without srcip skips white_list entirely, because the address is set to -.
That last case is what bites Windows events. The fix description in release candidate 4.14.12-rc1 (PR 41261) says EventChannel events don’t set srcip; the address is in win.eventdata.ipAddress or win.eventdata.destinationIp. In the 4.14.11 code the active response scripts (get_srcip_from_json in active_responses.c) take the address to block from those two fields first and fall back to srcip. So a whitelisted address arriving in a Windows event is blocked like any other. Per the same description, 4.14.12 checks both fields against white_list; until 4.14.12 ships as stable, every 4.14.11 installation has the gap.
Filters and execution location
Which rules trigger a block is decided by level, rules_group and rules_id, and none of them narrows the others. The documentation says the response runs when the rule matches any option you set, because these are “accumulative options, not restrictive”. A block with both level and rules_id covers every rule at or above that level plus the listed IDs.
| Option | Behavior according to the documentation |
|---|---|
level | minimum level, from 1 to 16 |
rules_id | list of identifiers separated by commas |
rules_group | groups separated by a pipe, a trailing comma after a group protects against partial matching |
location | local, server, defined-agent (with agent_id), all (without the manager) |
In the 4.14.11 code, server and local for manager events (agent 000) go to the local execd queue, and all loops over active agents. defined-agent takes agent_id from the configuration; local takes the agent ID from the event. The basics of timeout and repeated_offenders are in the posts on active response and on web attacks from proxy logs; what matters here is how they change the execd key.
According to the documentation, disabled in the manager’s ossec.conf turns active response off on the manager and on every agent. In the 4.14.11 code, analysisd drops a block with <disabled>yes</disabled> while loading the configuration (active-response.c, lines 125–155; debug log “active response command ’…’ is disabled”). The rule has no response left to fire, so no command reaches the agent, and the agent’s own disabled set to no changes nothing. The setting applies to one active-response block, not to the feature as a whole: another block without disabled still works.
The key execd uses to recognize a repeat
wazuh-execd sends the alert to the script and reads back one line with the alert keys. This whole section comes from the 4.14.11 code. The entry key (rkey) starts with the script file name, and the keys the script replies with are appended to it. default-firewall-drop replies with the srcip address alone, so the key is the script plus the address.
Here is what execd does with that key:
- With a zero
timeout, execd remembers nothing. - With a non-zero
timeoutandrepeated_offendersset, execd first bumps the offense counter for the key and picks a threshold from the list. Once the counter reaches the number of thresholds, it stays on the last one (execd.c, lines 161–166 and 447–449). - Then it searches the pending-revert list for an entry with the same key. If one exists, execd logs “Command already received, updating time of addition to now” at debug level, resets the time of addition and the block time (now with the
repeated_offendersthreshold), and tells the script to abort. The existing block lasts longer; no second block is added. - If there is no entry, it adds one with the revert command and tells the script to continue.
A periodic cleanup clears the repeated_offenders counters: it removes keys whose last block ended longer ago than the largest threshold (execd.c, lines 130–147). A counter disappears at the next cleanup run, not the moment the threshold passes.
Every event with the same srcip extends the current block and counts as another offense. An attacker who controls the logged address can keep a chosen address blocked and push it up the thresholds without doing anything else. Because the key includes the script name, two commands for the same address get separate entries. execd runs separately on each agent, so the entry list and counters are per agent.
How to limit the attacker’s influence on a block
A few rules follow from these mechanisms. The main one concerns where the address comes from: attach blocks to rules whose srcip comes from logs written by a service or device, not from client-supplied fields. Use rules_id with a list of your own rules rather than level alone, since level also pulls in rules you haven’t reviewed.
The block below limits blocking to one of your own rules (the ID 100200 is made up). It uses the firewall-drop command, which the default configuration files in the etc/ directory of the 4.14.11 repository define with the firewall-drop executable and timeout_allowed set to yes. The 4.14 documentation describes that script as “Adds an IP address to the iptables deny list” (script list). On Linux the 4.14.11 source installer (fw-check.sh) copies the compiled default-firewall-drop to firewall-drop; on FreeBSD, OpenBSD and macOS with pf enabled, the pf script takes its place.
<active-response>
<disabled>no</disabled>
<command>firewall-drop</command>
<location>local</location>
<rules_id>100200</rules_id>
<timeout>600</timeout>
</active-response>
Put your management addresses, gateways and monitoring servers in white_list as IPv4 addresses or IPv4 networks with a mask. Don’t rely on IPv6 entries or host names: the code treats them as text patterns. In 4.14.11 the list doesn’t protect addresses from Windows events, so test blocks based on Windows rules separately before you enable them.
Keep timeout so every block undoes itself, and use location local wherever blocking on the host that saw the event is enough. all pushes the block to every agent, so a wrong address hits the whole fleet.
Test the rule in wazuh-logtest with an event carrying an address from the 203.0.113.0/24 documentation range: the output shows the decoded srcip, the level and the rule ID. logtest can’t test white_list: in the 4.14.11 code logtest.c references neither white_list nor active response, and the function that runs a response (OS_Exec) is called only from analysisd.c. Test the list on a test agent instead: send two log lines, one with an address from the list and one outside it, and compare the response logs, which the post on active response describes. For actions that are expensive to undo, use an approver instead of automation, as in the approval gate.
Sources
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/active-response.html
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/global.html
- https://documentation.wazuh.com/4.14/user-manual/ruleset/ruleset-xml-syntax/decoders.html
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/analysisd/analysisd.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/analysisd/alerts/exec.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/os_execd/execd.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/config/global-config.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/shared/validate_op.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/active-response/active_responses.c
- https://github.com/wazuh/wazuh/pull/41261
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/active-response/firewalls/default-firewall-drop.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/config/active-response.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/analysisd/logtest.c
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/src/init/fw-check.sh
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.11/etc/ossec.conf
- https://documentation.wazuh.com/4.14/user-manual/capabilities/active-response/default-active-response-scripts.html