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

Đang mở
#5,848 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend, security

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
PHP
Star
1.2k
Fork
926
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
25

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opnsense/plugins

Tất cả issue của opnsense/plugins

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.