-
Notifications
You must be signed in to change notification settings - Fork 759
Rewrite opnsense-fw #5089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite opnsense-fw #5089
Conversation
kravietz
commented
Dec 15, 2025
- Address stateful active response issues os-wazuh-agent: Active response "add" and "abort" events at the same time #4738
- Use Wazuh recommended Python template for active response script
- Improve logging
- Tested in real life environment
* Address stateful active response issues #4738 * Use Wazuh recommended [Python template](https://documentation.wazuh.com/current/user-manual/capabilities/active-response/custom-active-response-scripts.html) for active response script * Improve logging * Tested in real life environment
|
@kravietz I can accept changes to my script, but not a rewrite I'm afraid. The existing script is not terribly difficult to read, so please stay within the lines of the existing one and update what is needed to fix the issue in question. |
|
@AdSchellevis Please do not take this personally, but the existing script has a very confusing control flow and error handling. I've tried to edit it initially, but kept running into problems caused by the above - mostly control flow issues, caused by non-exhaustive evaluation of states. The Wazuh supplied script on the other hand does the same thing in a very clean way, literally leaving a couple of placeholders to customise the action - which I did. Not sure why you're reluctant to replace it but from maintainability point of view it's 100% win. In other words, granted a few hours spent on trying to get the old code working I'm not ready to spend more time on it. The new one simply does the job. |
|
It's not personal. It's just high risk imposed on the project for little benefit. Cheers, |
|
But the current code is not working at all due to the abort logic error - so the risk has already materialised 🤷🏻 The new code is tested and working. If you want to fix the old code, the primary bug is in line 124: The That's the theory, because even with that change the script behaved weirdly when faced with |
|
I have comment this part, and now pfctl -t __wazuh_agent_drop -T show, show multiples IP and not only one: |
|
@paracetamol32 Thanks, what do you mean by "multiple IPs"? That several different IPs are added to the table, or the same IP added several times? I would expect that the table deduplicates added entries, but only the decoded I have done some more digging into the wazuh-agent code to understand why that From the code linked above it seems the sole purpose of But in case of Should we consider simply switching back to the much simpler stateless protocol, which simply involves:
When configured timeout expires, the Wazuh Agent simply calls the script again with |
|
I can say I ran into a similar issue when my firewall would detect the same rule used for more then 1 ip the "keys": [event['parameters']['alert']['rule']['id']] would be the same for each external device that breached the rule and therefore only the first 1 would be added by the flow of add -> continue. each breach of the rule after that would be a add -> abort. Therefore wazuh was not truly useful since each rule would only work 1 time until the first one expired and then it would work again 1 time. I resolved this by changing the line (line 103 I believe) to be 2 lines: edit: I put my better writeup in this issue (it more directly applies): #4738 |
|
close in favor of #5104 |