Skip to content

feat: Add Bifrost log parser and brute force scenario - #1958

Merged
sabban merged 2 commits into
crowdsecurity:masterfrom
sdwilsh:bifrost
Nov 13, 2026
Merged

sabban merged 2 commits into
crowdsecurity:masterfrom
sdwilsh:bifrost

Conversation

@sdwilsh

@sdwilsh sdwilsh commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Description

This adds a parser for Bifrost (maximhq/bifrost) JSON request logs, a scenario for repeated failed authentication (HTTP 401) per client IP, and a collection bundling both. The source IP is the first valid IP in http.forwarded_for, falling back to http.remote_addr.

Tested with cscli hubtest run bifrost-logs bifrost-bf: both pass. Test fixtures are synthetic lines modeled on real Bifrost logs from my own deployment.

Checklist

  • I have read the contributing guide
  • I have tested my changes locally
  • For new parsers or scenarios, tests have been added
  • I have run the hub linter and no issues were reported (see contributing guide)
  • Automated tests are passing
  • AI was used to generate any/all content of this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Untrusted forwarded addresses and upstream-provider 401 responses can cause bans against unrelated or legitimate clients.

2 open issues
What changed in this PR

Adds Bifrost support to the Hub through a JSON request-log parser, per-IP brute-force detection, and an installable collection.

Changes:

  • Extracts HTTP metadata and client addresses, classifying 401 responses as failed authentication.
  • Adds a brute-force scenario and collection with acquisition and proxy guidance.
  • Adds synthetic fixtures and generated assertions for parsing and scenario behavior.
File Description
scenarios/​sdwilsh/​bifrost-bf.yaml Defines per-IP failed-authentication detection.
scenarios/​sdwilsh/​bifrost-bf.md Documents thresholds and proxy requirements.
parsers/​s01-parse/​sdwilsh/​bifrost-logs.yaml Parses Bifrost JSON request metadata.
parsers/​s01-parse/​sdwilsh/​bifrost-logs.md Documents parsing and acquisition setup.
collections/​sdwilsh/​bifrost.yml Bundles the parser and scenario.
collections/​sdwilsh/​bifrost.md Provides collection setup guidance.
.tests/​bifrost-logs/​parser.assert Records expected parser output.
.tests/​bifrost-logs/​config.yaml Configures parser test dependencies.
.tests/​bifrost-logs/​bifrost-logs.log Covers address fallback and log filtering.
.tests/​bifrost-bf/​scenario.assert Verifies the expected six-event alert.
.tests/​bifrost-bf/​config.yaml Configures scenario testing.
.tests/​bifrost-bf/​bifrost-bf.log Exercises per-IP counting and status filtering.

Review effort: Balanced

This adds a parser for Bifrost (maximhq/bifrost) JSON request logs, a
scenario for repeated failed authentication per client IP, and a
collection bundling both.

A request counts as a failed authentication when it returns HTTP 401 within
10ms.  Bifrost rejects bad virtual keys before contacting a provider, while
a 401 passed through from a provider needs a network round trip.

The source IP is the connecting peer, unless the peer is a private,
loopback or CGNAT address (a reverse proxy).  Only then is
`http.forwarded_for` used, so a client reaching Bifrost directly cannot
choose the address that gets banned.

Tested with `cscli hubtest run bifrost-logs bifrost-bf`: both pass.  Test
fixtures are synthetic lines modeled on real Bifrost logs.
Bifrost logs the first X-Forwarded-For entry, so an appending proxy
lets the client choose the banned IP. Show the overwrite form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sabban
sabban merged commit f4bb4a2 into crowdsecurity:master Nov 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants