security/crowdsec: blocklist aliases are silently not created when another (unrelated) alias fails model validation

Aperta
#5,848 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend, security

Direzione di ricerca

Start with security/crowdsec/src/etc/inc/plugins.inc.d/crowdsec.inc and inspect add_alias_if_not_exist() and its Alias model save path. Reproduce with an invalid unrelated alias, then check how validation failures are exposed or logged. Done means CrowdSec aliases are created despite the unrelated invalid alias, or the failure clearly identifies the blocking alias.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Important notices

Describe the bug
When the firewall bouncer is enabled, add_alias_if_not_exist() in /usr/local/etc/inc/plugins.inc.d/crowdsec.inc adds the plugin's external aliases (crowdsec_blocklists, crowdsec6_blocklists) through the Alias model and calls $model->serializeToConfig().

On my system the config already contained an unrelated, invalid alias (type port, empty content — a leftover from an older configuration, not created by the CrowdSec plugin). Saving the Alias model then failed, the CrowdSec aliases were never created, and the bouncer kept failing with:

table crowdsec_blocklists doesn't exist

Nothing in the plugin or the GUI pointed to the real cause (the unrelated alias). After we deleted that alias and pressed Apply on the CrowdSec page, the aliases were created and the bouncer started populating the table immediately (≈2,300 entries from the community blocklist).

To Reproduce

  1. Have an alias that does not pass validation, e.g. type port with empty content (cannot be created from the GUI, but can exist after a config restore/migration).
  2. Enable the CrowdSec agent and firewall bouncer, press Apply.
  3. The aliases crowdsec_blocklists / crowdsec6_blocklists are not created; the bouncer logs table crowdsec_blocklists doesn't exist.
  4. Delete the invalid alias, Apply again → aliases created, bouncer works.

Expected behavior
Either the plugin's aliases are created regardless of unrelated invalid aliases, or the failure is reported clearly (syslog / GUI), e.g. "crowdsec: unable to create alias crowdsec_blocklists: alias model validation failed (alias 'X': ...)".

Suggested fix
Wrap the save in add_alias_if_not_exist() in a try/catch and log the validation messages, so the administrator sees which alias blocks the save. We are happy to submit a PR if this approach is acceptable.

Relevant log files

crowdsec-firewall-bouncer: table crowdsec_blocklists doesn't exist

Environment
OPNsense 26.7.x (amd64), os-crowdsec 1.0.12, crowdsec 1.8.1

Lingua principale
PHP
Stelle
1.2k
Fork
926
Merge medio
1g 10h
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opnsense/plugins

Tutte le issue di opnsense/plugins

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.