Active response¶
Why is active response not running?¶
Active response only runs after a matching alert is generated. If no rule fires, no script executes — for example, a SYN flood may not produce SSH authentication failure alerts unless you have rules for that traffic.
Checklist:
Execd is running — on the host where the script should run:
/var/ossec/bin/ossec-control statusossec-execdmust be listed as running.Rule and binding match — the alert must meet
level,rules_id, orrules_groupin your<active-response>block. Test with ossec-logtest.Location is correct —
localruns on the agent that generated the event;serverruns on the manager;defined-agentrequiresagent_id.Command is configured — a
<command>block must define theexecutable(script name underactive-response/bin) and link to the<active-response>via<command>name</command>.Script is executable — the file must exist in
/var/ossec/active-response/bin/with execute permission for theossecuser.Not disabled — check for
<disabled>yes</disabled>on that binding or<disable-active-response>yes</disable-active-response>in the agent<client>section. See Active Response.Restart after changes — restart OSSEC on affected hosts after editing
ossec.conf.
How do I test an active-response binding?¶
Use ossec-logtest with a sample log line that triggers your rule, then
confirm ossec.log on the execution host shows the active-response command
invoked. For firewall blocks, verify the block script logged success and the IP
appears in the expected deny list or table.
Where are example active-response configurations?¶
See UNIX: Active Response Configuration, ossec.conf: Active Response Options, and the bundled scripts reference at Bundled active-response scripts.
Why does my script see add and - instead of srcip/username?¶
Active-response scripts always receive a fixed argument list. <expect>
only chooses which decoded fields are filled (vs -); it does not put
srcip in $1.
Arg |
Value |
|---|---|
|
action ( |
|
username from the alert, or |
|
srcip from the alert, or |
|
alert id |
|
rule id |
|
agent / location |
|
filename, or |
So $1 will be add even when expect is srcip, username. Use $3
for the IP and $2 for the user. List srcip / user (or username)
in <expect> so those fields are populated from the decoder. Username is
taken from dstuser, or srcuser if dstuser is absent.