[Bot detection] Regenerate challenge only if served

Open
#4,692 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go, javascript
Domain
security

Research direction

Start by tracing the bot-detection challenge lifecycle: find where the per-epoch signing-key rotation and JavaScript re-obfuscation run, and where a challenge is served to a client. Check how the existing key_rotation_interval change in PR #4674 fits into that flow. Done means rotation and re-obfuscation are skipped when the current epoch's challenge has not been served, while still occurring after it has been served.

Written by the indexing model from the issue text.

Description

area/bot-detection kind/enhancement needs/triage
What would you like to be added?

Hey, I just activated the bot detection in my setup and saw the cpu spikes from the regeneration of the challenge. I found that https://github.com/crowdsecurity/crowdsec/pull/4674 is already addressing this and with the key_rotation_interval I could bring down CPU usage even more.

One more idea though: Skip the per-epoch signing-key rotation and JS re-obfuscation pass if the
current epoch's challenge has never been served to a client.

Why is this needed?

On an instance where the challenge is scoped to a few hosts (e.g. in homelabs), the rotation runs on a fixed schedule regardless of whether any client was ever challenged. On my system, each pass costs a full CPU core for several seconds, which dominates the process's total CPU usage on an otherwise quiet machine.

Dominant language
Go
Stars
15.1k
Forks
726
Avg merge
4d 23h
Merged PRs (30d)
27

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crowdsecurity/crowdsec

All issues in crowdsecurity/crowdsec

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.