hub icon indicating copy to clipboard operation
hub copied to clipboard

The crowdsecurity/naxsi collection does not parse NAXSI action logs correctly

Open shtefko opened this issue 1 month ago • 0 comments

Describe the bug

The crowdsecurity/naxsi collection does not parse NAXSI action logs in the NAXSI_FMT format emitted by my nginx/NAXSI installation on OpnSense (version 26.7.6, os-nginx 1.36_5, os-crowdsec 1.0.12).

The collection's crowdsecurity/naxsi-logs parser expects NAXSI_EXLOG:

grok:
  name: "NAXSI_EXLOG"
  apply_on: message

However, NAXSI is generating NAXSI_FMT records. CrowdSec acquires these error-log entries, but the NAXSI parser reports them as unparsed. Consequently, the crowdsecurity/naxsi-exploit-vpatch scenario cannot evaluate the rule IDs in these events.

To Reproduce

  1. Install the crowdsecurity/naxsi collection (version 0.2).
  2. Configure CrowdSec to acquire nginx logs using the nginx type.
  3. Generate a request that triggers a NAXSI rule.
  4. Inspect the nginx error log. An example from my installation is:
2026/10/09 11:05:56 [error] 22445#103046: *895 NAXSI_FMT: ip=95.178.148.157&server=cloud.example.com&uri=/&config=block&rid=484bf44606d45f99899463099cdc3658&cscore0=$policy06fa155002584a12aecf8220c9c88eb3&score0=8&zone0=ARGS&id0=1302&var_name0=naxsi_test, client: 95.178.148.157, server: cloud.example.com, request: "GET /?naxsi_test=%3Cscript%3E HTTP/2.0", host: "cloud.example.com"
  1. Run cscli metrics show parsers or cscli explain against the captured log.

The NAXSI parser receives the event but fails to parse it because it expects NAXSI_EXLOG, not the actual NAXSI_FMT structure. The virtual-patch scenario consequently receives no matching NAXSI event.

Expected behavior

The collection should support the NAXSI_FMT format emitted by my installation, extracting the client IP, request URI, enforcement mode, and rule IDs. It should correctly handle records containing multiple zoneN/idN pairs.

Alternatively, if extended logging is a prerequisite for the existing parser, the collection should clearly document that requirement and provide the necessary NAXSI configuration.

The NAXSI-specific virtual-patch scenario should evaluate only enforced-mode events (config=block), not learning-mode events (config=learning).

Screenshots

Not applicable. The issue is reproducible using log records and cscli explain output.

Additional context

  • CrowdSec is running on OPNsense with nginx and NAXSI.
  • The installed collection is crowdsecurity/naxsi version 0.2.
  • The actual NAXSI logs use config=block or config=learning, followed by fields such as rid, cscore0, score0, zone0, id0, and var_name0.
  • The installed parser instead matches the NAXSI_EXLOG format, whose fields include id, zone, var_name, and content.
  • The stock NAXSI_FMT grok pattern available in my installation also does not match the observed record structure: it expects fields such as learning, vers, total_processed, total_blocked, and block.
  • I confirmed the failure using cscli metrics show parsers and cscli explain. A locally implemented parser matching the observed NAXSI_FMT format successfully parsed the events.
  • The general HTTP scenarios, including crowdsecurity/http-xss-probing, are independent of this NAXSI-specific integration and should remain enabled.

shtefko avatar Oct 09 '26 10:10 shtefko