Skip to content

WAF Bot Detection : Support for challenge mode - #138

Merged
blotus merged 6 commits into
mainfrom
waf-challenge-mode
Jul 16, 2026
Merged

WAF Bot Detection : Support for challenge mode#138
blotus merged 6 commits into
mainfrom
waf-challenge-mode

Conversation

@buixor

@buixor buixor commented Mar 24, 2026

Copy link
Copy Markdown
Contributor
  • Support the challenge reponse to serve html/js challenge to the user

Copilot AI review requested due to automatic review settings June 10, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for CrowdSec AppSec “challenge” remediation by passing through AppSec-provided HTML/JS content, headers, and cookies to the client.

Changes:

  • Introduces a new plugins.crowdsec.challenge helper to apply AppSec challenge responses (status/headers/cookies/body).
  • Extends csmod.AppSecCheck / csmod.Allow flow to carry and serve challenge response payloads.
  • Updates remediation support list to include challenge (with fallback-to-ban behavior if response payload is missing).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
lib/plugins/crowdsec/challenge.lua New module to render AppSec challenge responses by applying headers/cookies/body and exiting with the provided status.
lib/crowdsec.lua Wires “challenge” into AppSec check + remediation handling, including passing AppSec response payload through to the new challenge module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/crowdsec.lua
Comment thread lib/crowdsec.lua
Comment on lines +664 to +668
local appsec_response = {
body = response.user_body_content,
headers = response.user_headers,
cookies = response.user_cookies,
}
Comment on lines +12 to +24
if headers ~= nil then
for name, values in pairs(headers) do
if type(values) == "table" then
if #values == 1 then
ngx.header[name] = values[1]
else
ngx.header[name] = values
end
else
ngx.header[name] = values
end
end
end
Comment on lines +26 to +32
if cookies ~= nil and #cookies > 0 then
if #cookies == 1 then
ngx.header["Set-Cookie"] = cookies[1]
else
ngx.header["Set-Cookie"] = cookies
end
end
Comment thread lib/crowdsec.lua
@blotus
blotus merged commit dc1ecde into main Jul 16, 2026
1 check passed
@blotus
blotus deleted the waf-challenge-mode branch July 16, 2026 08:05
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