When custom Wazuh active response scripts are worth building
Build a custom active response script when the default scripts do not fit the containment action your SOC needs. Wazuh active response is the mechanism that runs a script on an agent in response to a triggering alert, so the question is whether one of the shipped actions already does what you want on the hosts you operate. Wazuh's default Linux and macOS scripts include disable-account, firewall-drop (iptables), firewalld-drop, host-deny, ip-customblock, pf, ipfw, npf, route-null, restart-wazuh and wazuh-slack. Check the default active response scripts documentation for the list that applies to your operating systems, since platform coverage differs from script to script.
Most gaps fall into three groups: a block that must reach a site-specific enforcement point, such as a load balancer or cloud security group, an action that touches an internal ticketing or approval system before it runs, and a containment step that the default scripts do not cover on a particular platform. The ip-customblock template is the usual starting point for the first group because it is designed to be modified, so you can keep the same trigger and command structure while changing what the script does. Before you write anything, confirm which enforcement point each action must reach, who owns it, and whether an agent-side script can reach it with the credentials and network path the endpoint has.
Do not build a custom script to cover a case that a rule tuning change, a group-level configuration or an existing integration already handles. Every custom script becomes a piece of code that runs with elevated privileges on production hosts, must be tested on each supported operating system, and needs an owner who maintains it through agent and Wazuh upgrades. Record the trigger, the intended effect, the rollback path and the owner before development begins, and treat that record as the input to the change control process described later in this page.
Which script approach fits which response
Wazuh ships a set of default active response scripts for Linux and macOS, including disable-account, firewall-drop, firewalld-drop, host-deny, pf, route-null, restart-wazuh and wazuh-slack. A default script that already performs the action you need is the lowest-effort choice because Wazuh maintains it, it is covered by the same documentation, and your team only has to configure the trigger and the parameters. Most teams should check this option first before writing any code.
- Maintenance: Wazuh owns the script logic, so your team maintains only the configuration that calls it.
- Upgrade survival: Default scripts are updated with the platform, so behavior changes arrive through release notes you already track.
- Testing effort: You test the trigger, the timeout and the scope of the action, not the script itself.
- Blast radius: The action is the one the vendor documents, which makes it easier to explain to change reviewers.
- Limit: Check whether the default action fits your host types, such as Windows endpoints, which use different scripts.
Before you commit, confirm in the default active response scripts documentation that the script covers your operating system and the exact action you need.
The ip-customblock script is the documented template for custom blocking logic. Your team edits its contents to change how an IP address is blocked, such as calling a different firewall or logging to an internal system, while keeping the Wazuh trigger and argument handling. This approach fits when the action is still a block of a source address but the mechanism differs from the defaults. It keeps the integration surface small because the script already receives the standard inputs.
- Maintenance: Your team owns the edited logic, so every change needs a version history and a named owner.
- Upgrade survival: Keep a copy of your changes in version control and check the upgrade notes, since a platform update can replace the file.
- Testing effort: Test the block and the unblock path on a lab agent, including the case where the same address triggers repeatedly.
- Blast radius: A flawed edit can block legitimate addresses across every agent that runs it, so scope the rule group carefully.
- Review: Record which rule IDs call the modified script and who approved the change.
Ask your Wazuh contact or review the active response documentation to confirm how the template handles arguments on your version before you change it.
A new script is the right choice when no default or template performs the action, for example when a response must update an internal ticketing system, rotate a credential or change an application setting. You own every line, including input validation, error handling, logging and cleanup. Because the script runs on production hosts, the design work and review effort are higher than for the other two routes, and the script should be the last option considered.
- Maintenance: Your team carries the full lifecycle, including dependencies, language runtime and security fixes.
- Upgrade survival: Custom scripts are outside the platform's update path, so test them after every Wazuh and operating system upgrade.
- Testing effort: Plan tests for normal input, malformed alert fields, repeated triggers and failure of the downstream system.
- Blast radius: Largest of the three, since a logic error can affect many hosts at once, so use staged rollout and tight rule scoping.
- Controls: Treat the script as production code with peer review, signing or integrity checks, and a documented rollback.
Before you start, ask whether a default script combined with a SOAR playbook or an integration could achieve the same result with less code on hosts.
How a rule match reaches a script on an agent
The flow starts when an agent forwards an event to the Wazuh server, where decoders and rules run. A rule match that is tied to an active response definition triggers the server to send the script and its command to the agent, which executes it. The timeout is the point where the agent reverses the action, so check that the timeout is set and that the reversal is tested before the response is enabled on production hosts. The dashed boundary marks where the server's decision ends and the endpoint's execution begins.
Rule match to script execution, with the server and endpoint trust boundary marked.
Configuration choices in an active response definition
This table compares the main settings in a Wazuh active response definition, including the command and location, rule triggers, timeout behavior and where the action runs. Read each row as a decision: the right choice depends on how reversible the action is and how much harm a false positive would cause. Confirm exact key names and syntax against the documentation for your Wazuh version before you deploy.
| Setting | What it controls | When it fits |
|---|---|---|
| Command and script location | The script name in the command block and where it is placed on the agent or server, such as the custom active response directory | Use a copy of ip-customblock as a starting point when you need a custom block action. Keep the script under change control so the deployed version is known. |
| Rule ID triggers | Runs the response only when a specific rule ID fires | Best for narrow, well-tested detections where the expected action is clear, such as a known brute-force rule. Avoid it for broad rules that fire on routine activity. |
| Rule level and group triggers | Runs the response for any alert at or above a level, or any rule in a named group | Useful for wide coverage, but a high-volume group can trigger blocking on legitimate traffic. Pair with a short timeout and a review of the first alerts. |
| Timeout and reversal | Whether the action is undone after a set period, or stays until someone removes it | Time-limited actions suit uncertain detections, because a mistake expires on its own. Permanent actions need a documented removal procedure and an owner. |
| Source host or server | Whether the script runs on the agent that produced the event or on the Wazuh server | Host-side actions affect the endpoint directly. Server-side actions can reach multiple endpoints but depend on the server having a path to the target. Confirm the location setting for your version. |
| Stateless or stateful script | Whether the script keeps state, such as a list of blocked addresses, between runs | Stateful scripts need clean removal logic and protection against duplicate entries. Stateless scripts are easier to test but cannot track what they changed. |
| Logging and output | Where the script records actions and whether its output is parsed by other rules | Log every action with the triggering rule ID and host. Logged output supports audit evidence and troubleshooting after an incident. |
Building and deploying a custom script step by step
This sequence takes a custom active response script from a drafted file to a tested, linked and verified automation on a Wazuh agent. Each step ends with a check so the team can confirm the script runs, is triggered by the intended rule and produces evidence before it touches more hosts.
Name the script and define its action
The engineer who owns the response writes down the single action the script performs, its inputs and its expected exit behavior, then chooses a file name that states that action. Start from the custom block template (ip-customblock) where it fits, and keep the change narrow so reviewers can read it in one sitting. The step is done when the script has a written purpose, a named owner and a draft that a second engineer has read and agreed to test.
Place the script in the active-response directory
Copy the script into the active-response scripts directory on the agent host, which is where Wazuh looks for scripts it runs on endpoints. Confirm the exact path for your installed agent version in the Wazuh documentation before copying, because a script outside that directory will not be executed. The step is done when a directory listing on the test agent shows the new file in the expected location with no other copies left behind.
Set ownership and restrictive permissions
Assign ownership to the account that the Wazuh agent runs as, and set permissions so only that account and administrators can modify the file. A script that the agent can rewrite is a privilege path, so reject any group or world write permission. Check the result with a long listing of the file and confirm the owner, group and mode match the standard your change policy sets. The step is done when the listing shows the intended owner and no write access for unprivileged users.
Test the script manually on a non-production agent
Run the script by hand on a non-production agent with a test address or test account, passing the arguments the Wazuh server would send, and observe what it changes. Confirm it does nothing when the input is malformed and that it writes to the log it is meant to write to. Keep a record of the exit code and the resulting firewall or account state. The step is done when the manual run produces the expected change, the expected reversal path works and the test host returns to a clean state.
Link the script to a rule ID on the server
On the Wazuh server, add an active-response block to the configuration that names the script and the rule ID or rule group that triggers it, and set the location to the agent or agent group that should run it. Choose a narrow trigger first, because a broad rule can run the script on many hosts at once. Validate the XML before restarting anything, since a malformed block can stop the manager from starting. The step is done when the configuration validates and the chosen rule is confirmed to exist in the rule set.
Restart or reload the affected services
Restart the Wazuh manager so it reads the new active-response block, and restart the agent on the test host if the script placement or permissions changed its configuration. Record the time of each restart so log entries can be matched to the change. Confirm both services report a running state and that no startup errors appear in their logs. The step is done when the services are healthy and the new configuration is loaded without errors.
Verify the alert and the action in logs
Trigger the linked rule on the test agent with a controlled event, then check the alert in the dashboard or the alert log and confirm the active-response entry shows the intended script, host and outcome. Verify the action on the host itself, such as the blocked address or locked account, and confirm the reversal works. Keep the test evidence with the change record. The step is done when the alert, the active-response log entry and the host state all match the design, and the team agrees the script is ready for a staged rollout.
Distributing scripts to agents without drift
A custom active response script only works on the agents where it exists, with the same content and permissions. The options below differ in who controls the copy, how changes reach each host and how quickly a drifted host gets noticed. Choose the method your change control process can actually verify.
Agent group configuration
Wazuh manages agent configuration centrally through agent groups, so a group can hold the rules and settings that apply to a set of endpoints. Script files are not carried by the group configuration itself, so you still need a delivery step for the script. Use groups to decide which agents receive active response bindings, and keep the binding in the same group as the script's host set. Check that every member of the group reports the expected configuration after a change, because agents that are offline or fail to pick up a change will keep the previous state.
Default scripts docsConfiguration management with Ansible or Puppet
Wazuh documents Ansible and Puppet as deployment options, and the same tools can place a script, set its owner and mode, and verify its checksum on each host. Playbooks or manifests make the desired state explicit and rerunnable. The main drift risk is a host that was missed, a role that was changed by hand, or a play that copies the script without restarting or reloading the agent when required. Ask who owns the repository, how changes are reviewed, and how a failed run is reported.
Deployment optionsManual copies
Copying a script by hand over SSH or a console is quick for a lab or a single host, but it has no record of who changed what and no guarantee that the next host matches. Manual copies tend to diverge through small edits such as a changed shell variable, a different path or a missing execute bit. They are acceptable only for testing, and production hosts should be moved to a managed method before the script triggers any automatic action.
Checksum and permission verification
After any distribution method, compare a checksum of each deployed script with the approved version and confirm owner, group and execute permissions. A script that differs by one line can run with different logic, or fail silently if it is not executable. Record the checksum in the change ticket so that auditors and responders can confirm which version ran on a given date. Repeat the check on a schedule, not only at rollout, because local edits and package upgrades can change files later.
Test on a canary group
Before a new script version reaches the whole fleet, deploy it to a small agent group that holds representative systems and no critical services. Trigger a controlled test event and confirm the script runs, logs its action and produces the expected result on each platform. Use the canary results to decide whether the rollout continues. Ask your team to confirm which hosts count as canaries and who approves the move to the full group.
Change control for automation that acts on production hosts
A script that blocks IP addresses or locks accounts changes production state, often without a person watching it run, so it needs the same review, testing, version control, approval and rollback path as any other production change. The risk is concrete: a rule that fires too broadly can cut off a shared gateway, a monitoring host or an administrator in seconds, and the block may persist until someone undoes it on every affected agent. Treat each active response as a change record with an owner, a reason, a test result and a documented way back. Keep the script source in version control so the reviewed version is the one deployed, and confirm with your team how the ip-customblock template and any custom script are copied to agents and whether a failed update leaves the previous version in place.
Approval should cover the link between a rule ID and a script, not just the script itself. A rule-to-script link decides which alerts cause an action, so the approver should be someone who understands both the detection and the blast radius, such as the detection engineering lead with a named owner from the infrastructure team for the affected hosts. Record the triggering rule IDs, the agent groups in scope, the timeout or permanent setting, and any exclusions for management addresses and service accounts. Stage rollout by agent group, starting with a non-production or low-impact group, observing the alerts and actions it produces, and widening scope only after the review window closes. Confirm in the Wazuh documentation how group-level configuration and active response settings are distributed and reverted for your installed version.
An audit trail has to show who changed the script, who approved the rule link, which agents received it and what actions ran. Use Wazuh's own alert and active response logs as the execution record, and keep the approval and version history in your change management system or repository so the two can be matched during an incident review. Test rollback before you need it: remove the rule link, redeploy the previous script version and confirm that blocked addresses or locked accounts can be released, including the manual steps for each host type. Review the audit trail on a schedule, since automation that has not fired for months can still fail silently when a package or agent group changes.
Security risks of scripts that run as root on endpoints
An active response script runs on the agent host, usually with the privileges of the Wazuh agent, and it acts on production systems without a human in the loop. The risks below share one root: anything that can change the script, its trigger or the data it reads can change what happens on the endpoint. Confirm the runtime privileges in your own environment before you assess each one.
Script injection through alert fields
Alert fields such as the source IP, user name, file path or log text come from logs that an attacker may partly control. If a script passes those values into a shell command without validation, a crafted username or log line can run extra commands on the endpoint. Review every script that reads alert data, treat those values as untrusted, and test with hostile input in a lab before you link the script to a rule.
Default scriptsOverly broad triggers causing outages
A rule that fires on common events can run a blocking or locking action against many hosts at once. An ip-customblock trigger on a noisy rule may block a load balancer, a monitoring probe or an administrator's own address. Before linking a rule, review its historical match volume and the entities it would affect, and decide which groups of agents the script may run on.
File tampering on agents
If a user with write access to the agent's active response directory can replace a script, the replacement runs with the agent's privileges the next time it is triggered. Check file ownership and permissions on every script, and confirm that the scripts are not writable by unprivileged accounts. Monitor the script directory with file integrity monitoring so that changes to the automation itself generate alerts.
Credential handling in scripts
Scripts that call an external API, such as a firewall or ticketing system, need a credential. Hardcoding a token in the script exposes it to anyone who can read the file, to backups and to configuration management repositories. Prefer a dedicated, narrowly scoped credential stored with restricted file permissions, rotate it on a schedule, and confirm that the script's logs do not print it.
Who can edit scripts and rule links
Editing a script and changing which rule IDs trigger it are two separate changes, and both alter production behavior. Restrict write access to the Wazuh server configuration and the scripts to named administrators, require review for changes, and keep an audit trail of who linked which script to which rule. Test each change on a non-production group before it reaches the wider fleet.
Questions buyers ask before building custom active response
What drives the cost of writing custom Wazuh active response scripts?
The main drivers are how much logic the script needs, how many operating systems and agent types it must run on, how much testing it needs before it touches production, and how much change control wraps it. A script that only calls one firewall command on one Linux distribution is a small job. A script that handles blocking, unblocking, logging and rollback across Linux, Windows and macOS hosts, with each platform tested on real agents, is a much larger one. Cost is mostly labor: the time of your engineers, a partner's team, or both. Ask any partner for a quote built from a written scope listing the platforms, the triggering rules and the test plan, since that scope is what sets the price.
Can our own team build custom active response scripts without a partner?
Yes, if your team already runs Wazuh and has someone comfortable with shell or PowerShell, the agent and server configuration, and your firewall or account tooling. The default scripts, including ip-customblock, which is a modifiable custom block script, give a working starting point. The harder parts are rarely the script itself. They are choosing rules that are safe to automate, testing without cutting off legitimate users, and setting up a review path for changes. If those skills or the time to do them are missing, a partner can cover that work under a written scope while your team keeps ownership of the final configuration.
What do we need to provide for a custom active response project?
Expect to provide named owners for the detection rules that will trigger responses, at least one change approver who can accept or reject automation on production hosts, and a set of test hosts that match your real builds. You will also need access to the Wazuh manager and agent configuration, the systems the script will act on (for example firewalls or identity tools), and written rules for who may be blocked or locked and for how long. Without those inputs, the scripts tend to be written against assumptions that do not match your environment.
How long does a custom active response project take?
Duration depends on scope rather than on a fixed number. The main variables are the count of response types, the count of target platforms, the number of triggering rules, and how much testing and approval your change process requires. No duration is set for this work in the material used to prepare this page, so ask any partner for a timeline tied to a written scope, and confirm how much of it depends on your approvers and test hosts being available. Tighter scopes with fewer platforms and a pre-existing test lab move faster.
What breaks when active response scripts go wrong?
The most common failures are scripts that block a legitimate host, a rule that fires far more often than expected, scripts that do not undo their action at timeout, and scripts that fail silently on one platform. A script that adds a firewall block without a matching removal can isolate a server for good. Testing should cover success, failure, timeout and rollback on each agent type, and the rule that triggers the script should be checked against normal traffic before it is enabled on production. Confirm the exact behavior of each script version with the Wazuh documentation for your release line.
How should we control changes to scripts that act on production hosts?
Treat each script and each rule link as a versioned change. Store scripts and the agent configuration that distributes them in version control, require a named approver before a change reaches production, test on non-production agents first, and keep a record of which rule IDs trigger which script. Limit who can edit the scripts on the manager and on agents, and review the list of automated actions on a regular schedule. This is a set of controls you can design and evidence, but it does not by itself satisfy any framework requirement or external audit.
What does a partner deliver for custom active response scripts?
Under a fixed written scope, a partner would typically deliver the custom scripts, the rule-to-script mappings, the distribution method to agents, test results across the agreed platforms, the change control procedure, and documentation your operations team can run. DeployOpen plans and implements self-hosted open-source platforms in your infrastructure, runs security testing, and prepares evidence for compliance assessments, but it does not issue audit reports or certifications. Ask for the deliverables list and the acceptance criteria in writing before work begins.
How DeployOpen scopes custom active response work
DeployOpen scopes custom active response work as a fixed engagement with a written scope before any script is written. The scope names the response catalog, meaning which rule IDs or rule groups trigger which responses, the script build for each custom action (starting from the ip-customblock template where a block is needed), the distribution method for placing scripts on agents, the test plan that proves each response behaves as intended, and the change control steps that govern promotion to production. Each item has a named owner on both sides and an acceptance condition, so the client can see what is delivered and what is left for their own team to approve.
The catalog and test plan are where most of the effort and most of the risk sit. DeployOpen works with your security team to decide which alerts may trigger an automated action at all, which actions are reversible, and which hosts or accounts must be excluded, such as management systems, load balancers and service accounts. The written scope should ask for a test matrix covering a staging group of agents, the trigger conditions, the expected action and the rollback. Confirm with your own change board which approvals a script change needs, because that approval path, not the script itself, usually sets the schedule. The exact distribution and execution behavior of your Wazuh version should be checked against the active response documentation before the scope is signed.
Ongoing work is offered as a retainer, separate from the fixed build. A retainer can cover retesting after Wazuh patch releases, review of new rules that might need a response, updates to exclusion lists, and evidence of testing for your change records. Ask for the retainer terms in writing, including what triggers a retest, who is paid for which work, and how the client's own team hands over ownership of the scripts. DeployOpen does not issue attestations or certifications for these controls. Independent auditors can review the change records and test results as technical evidence.

