OPNsense Forum

English Forums => 24.7, 24.10 Legacy Series => Topic started by: dstrctdagain321 on January 15, 2025, 08:25:55 PM

Title: Crowdsec quits with new update
Post by: dstrctdagain321 on January 15, 2025, 08:25:55 PM
Hi,

On my install, Crowdsec with 24.7.12 intermittently quits and restarts itself constantly. I am getting this error:

Script action failed with Command '/usr/local/bin/cscli alerts list -l 0 -o json' returned non-zero exit status 1. at Traceback (most recent call last): File "/usr/local/opnsense/service/modules/actions/script_output.py", line 78, in execute subprocess.check_call(script_command, env=self.config_environment, shell=True, File "/usr/local/lib/python3.11/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '/usr/local/bin/cscli alerts list -l 0 -o json' returned non-zero exit status 1.
I removed the package, rebooted, reinstalled with the same issue. Would anyone else be experiencing this or have advice? Thank you :)
Title: Re: Crowdsec quits with new update
Post by: newsense on January 15, 2025, 08:48:41 PM
You can try reverting, and open an issue with Crowdsec about this.

# opnsense-revert crowdsec
Title: Re: Crowdsec quits with new update
Post by: dstrctdagain321 on January 15, 2025, 09:19:18 PM
Thank you!

Unfortunately it looks like the old Crowdsec package is no longer available to revert, it simply reinstalls the new one.

I will reach out to Crowdsec and see what I can do.
Title: Re: Crowdsec quits with new update
Post by: Patrick M. Hausen on January 15, 2025, 09:31:19 PM
Must be something more particular to your setup.

Bouncer, scenarios, parsers, ... all perfectly up and running here.

I know that doesn't help much.

Have you tried invoking cscli manually? Then there's a Crowdsec Discord ...
Title: Re: Crowdsec quits with new update
Post by: dstrctdagain321 on January 15, 2025, 09:53:51 PM
I'm guessing the same. Looking through their Discord now to see what I can find. Also, knowing your Crowdsec is working fine tells us a lot.

Are you using Crowdsec to parse Suricata logs by chance?

When reloading Crowdsec in the shell, it performs sanity check and I get:

time="2025-01-15T12:44:49-08:00" level=fatal msg="crowdsec init: while loading scenarios: scenario loading failed: unable to load alert context: compilation of 'match.matched_zones != nil ? match.matched_zones : ''' context value failed: unknown name match (1:1)\n | match.matched_zones != nil ? match.matched_zones : ''\n | ^"
Title: Re: Crowdsec quits with new update
Post by: tracerrx on January 15, 2025, 10:15:40 PM
My crowdsec is also working just fine after the update.  Nothing unusual in the logs.
Title: Re: Crowdsec quits with new update
Post by: dstrctdagain321 on January 15, 2025, 10:42:47 PM
After digging into logs, I was able to narrow it down to the Appsec collection. Removed it, and no more issues!
Title: Re: Crowdsec quits with new update
Post by: dinguz on January 16, 2025, 09:58:59 AM
Same here, crowdsec didn't fully shutdown when stopping the service, requiring a kill -9 (this had been going on for some time). It wouldn't startup after that as well, spewing some rather cryptic messages (this started after upgrade to 24.7.12).
After removing the appsec collection the weird behaviour was gone.
Title: Re: Crowdsec quits with new update
Post by: lotsofclams on January 16, 2025, 06:28:52 PM
Quote from: dinguz on January 16, 2025, 09:58:59 AMSame here, crowdsec didn't fully shutdown when stopping the service, requiring a kill -9 (this had been going on for some time). It wouldn't startup after that as well, spewing some rather cryptic messages (this started after upgrade to 24.7.12).
After removing the appsec collection the weird behaviour was gone.

Thank you. This resolved my issue.

Error: level=fatal msg="crowdsec init: while loading scenarios: scenario loading failed: unable to load alert context: compilation of 'match.msg != nil ? match.msg : ''' context value failed: unknown name match (1:1)\n | match.msg != nil ? match.msg : ''\n | ^"
Title: Re: Crowdsec quits with new update
Post by: franco on January 16, 2025, 07:20:54 PM
The proper way to revert is to specify an OPNsense version ;)

# opnsense-revert -r 24.7.11 crowdsec
Title: Re: Crowdsec quits with new update
Post by: halasizs on January 19, 2025, 01:26:02 PM
The crowdsec is restarting again for me too.
During my installation of the 24.7.12 .
Appsec collection how can I take it down?
Where can I find it?
Thank you.
Title: Re: Crowdsec quits with new update
Post by: halasizs on January 19, 2025, 06:58:37 PM
By removing the collection, I managed to do it! :-)
Title: Re: Crowdsec quits with new update
Post by: mmetc on January 20, 2025, 04:52:59 PM
Hi, I'm the plugin maintainer and was not able to reproduce the behavior.

If you had issues with the service start/stop during the package upgrade or at any other time, it would help if you run "cscli support dump" and send the output to support@crowdsec.net. It includes log files and part of the configuration (passwords removed ofc).

A look at that could also explain the initial errors of "cscli ... list", due to the service not running.
Thanks!
Title: Re: Crowdsec quits with new update
Post by: dinguz on January 20, 2025, 06:36:53 PM
Quote from: mmetc on January 20, 2025, 04:52:59 PMIf you had issues with the service start/stop during the package upgrade or at any other time, it would help if you run "cscli support dump" and send the output to support@crowdsec.net. It includes log files and part of the configuration (passwords removed ofc).

Done, thanks in advance!
Title: Re: Crowdsec quits with new update
Post by: Eisai on January 22, 2025, 03:45:53 AM
Had the same problem here. The new version of Crowdsec seems to have problems with appsec function. Fix by logging in to the console then revert to the last version.
opnsense-revert -r 24.7.11 crowdsec
Then fix the tainted collections with the following commands:
cscli collections upgrade --force crowdsecurity/appsec-generic-rules
cscli collections upgrade --force crowdsecurity/appsec-virtual-patching
Title: Re: Crowdsec quits with new update
Post by: generousCheese on January 23, 2025, 09:30:29 AM
Quote from: dstrctdagain321 on January 15, 2025, 10:42:47 PMAfter digging into logs, I was able to narrow it down to the Appsec collection. Removed it, and no more issues!

Yeah had the same issue, it gave me this error:
root@OPNsense:~ # cscli collections remove crowdsecurity/appsec-generic-rules
FATA crowdsecurity/appsec-generic-rules is tainted, use '--force' to remove
root@OPNsense:~ # cscli collections remove crowdsecurity/appsec-generic-rules --force

Then running confirmed its all good!
root@OPNsense:~ # sudo service crowdsec reload
Performing sanity check on crowdsec configuration.
Configuration test OK
Reloading configuration

Thanks heaps!
Title: Re: Crowdsec quits with new update
Post by: jauger on January 23, 2025, 07:16:33 PM
Quote from: Eisai on January 22, 2025, 03:45:53 AMHad the same problem here. The new version of Crowdsec seems to have problems with appsec function. Fix by logging in to the console then revert to the last version.
opnsense-revert -r 24.7.11 crowdsec
Then fix the tainted collections with the following commands:
cscli collections upgrade --force crowdsecurity/appsec-generic-rules
cscli collections upgrade --force crowdsecurity/appsec-virtual-patching

Thanks! That worked for me