-
Notifications
You must be signed in to change notification settings - Fork 221
[do-not-merge] Waf Challenge Collection #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
buixor
wants to merge
38
commits into
master
Choose a base branch
from
test-waf-challenge-mode-scenarios
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c02ebbf
add wip scenarios for challenge mode
blotus f07f5b7
update appsec parser for challenge events
blotus 612b0e0
add basic appsec-config for challenge
blotus 7a2e15f
bundle files in a collection, exclude well-known paths, split parsers…
buixor 47e1b42
rename to make CI happy
buixor 6e0a72a
Update index
actions-user dc8dac3
rename to make CI happy
buixor 85db8a9
Update index
actions-user e1b6796
rely on existing methods instead
buixor 7a3a818
Update index
actions-user dcd5f05
reflect helper change
buixor 5fe9fdd
reflect helper change
buixor 54eb693
add the appsec-rules tracking data files
buixor 10943ab
Update index
actions-user 36b3baf
add appsec-rule to fetch bot desc json files
buixor 210838b
Update index
actions-user 0d5442b
Merge branch 'master' into test-waf-challenge-mode-scenarios
buixor 27eee02
fix the helpers names
buixor fd47f24
rename
buixor 18fa69b
avoiid this
buixor 00260c9
Update index
actions-user 545299e
add more bots (search, ai, monitoring) + split into various appsec-rules
buixor 503a268
Update index
actions-user 3f15d33
be more lenient
buixor 389aae4
Update index
actions-user 862da2f
exclude more commons paths from bot challenge
buixor 46bcfcd
cleanup comments
buixor a41deab
Update index
actions-user b9b4a91
datadog
buixor 60b320c
up
buixor 3bcc4d3
Update index
actions-user fef0309
up
buixor c5594ae
Update index
actions-user 8879d07
Merge branch 'master' into test-waf-challenge-mode-scenarios
buixor 27808d5
fix escape
buixor d0b7e3f
Update index
actions-user b70a0fb
update the branch to reflect the changes on IsKnownBot helper
buixor 034df7e
Update index
actions-user File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
appsec-configs/crowdsecurity/challenge-exclude-crawler-files.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| name: crowdsecurity/challenge-exclude-crawler-files | ||
| # Let well-known crawler files fly through without a challenge. SetLegitimateBot() is | ||
| # strictly per-request (never persisted to a cookie or across requests), so this cannot | ||
| # be abused to whitelist a session for other paths. | ||
| inband: | ||
| pre_eval: | ||
| - filter: >- | ||
| req.URL.Path in ['/robots.txt', '/ads.txt', '/app-ads.txt', '/sitemap.xml'] || | ||
| req.URL.Path startsWith '/.well-known/' | ||
| apply: | ||
| - SetLegitimateBot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| name: crowdsecurity/challenge-exclude-feeds | ||
| # Let syndication feed endpoints fly through without a challenge. SetLegitimateBot() is | ||
| # strictly per-request (never persisted to a cookie or across requests). | ||
| inband: | ||
| pre_eval: | ||
| - filter: >- | ||
| req.URL.Path in ['/feed', '/rss', '/atom.xml'] || | ||
| req.URL.Path startsWith '/feed/' || req.URL.Path startsWith '/rss/' | ||
| apply: | ||
| - SetLegitimateBot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| name: crowdsecurity/challenge-exclude-webhooks | ||
| # Let third-party webhook callbacks fly through without a challenge. SetLegitimateBot() is | ||
| # strictly per-request (never persisted to a cookie or across requests). | ||
| inband: | ||
| pre_eval: | ||
| - filter: "req.URL.Path in ['/webhooks/stripe', '/webhooks/github', '/webhooks/sendgrid']" | ||
| apply: | ||
| - SetLegitimateBot() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: crowdsecurity/simple-bot-challenge | ||
| inband: | ||
| post_eval: | ||
| # Skip the challenge for verified good bots (forward-confirmed rDNS) and for requests a | ||
| # well-known-path exclusion config flagged via SetLegitimateBot(). The flag is per-request only. | ||
| - filter: "!IsLegitimateBot(req.RemoteAddr, req.UserAgent(), req.URL.Path)" | ||
| apply: | ||
| - SendChallenge() | ||
| on_challenge_submit: | ||
| # Reject submissions whose fingerprint fast-detect flags a known bot. The resulting "rejected" | ||
| # event feeds crowdsecurity/appsec-bot-detected (alert only, no active ban). | ||
| - filter: "fingerprint.IsBot()" | ||
| apply: | ||
| - RejectSubmission("known bot (fast bot detection)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # AppSec Bot Challenge | ||
|
|
||
| This collection enables CrowdSec AppSec **challenge mode** for bot detection: visitors are served a | ||
| lightweight proof-of-work + browser-fingerprint challenge, and clients flagged as known bots by the | ||
| fast bot detection are rejected. | ||
|
|
||
| What it ships: | ||
|
|
||
| - `crowdsecurity/simple-bot-challenge`: challenges incoming requests, skips verified good bots | ||
| (forward-confirmed rDNS), and rejects challenge submissions whose fingerprint trips the fast bot | ||
| detection. | ||
| - Well-known-path exclusion configs (`challenge-exclude-crawler-files`, `-feeds`, `-webhooks`) that | ||
| let machine-facing endpoints (`/robots.txt`, `/.well-known/*`, feeds, webhooks) through without a | ||
| challenge. The exclusion is strictly per-request and is never persisted to a cookie or across | ||
| requests, so it cannot be abused to whitelist a session for other paths. | ||
| - A dedicated bot-detection parser tracking the fingerprint session id (`fsid`) and OS. | ||
| - Scenarios that alert on detected bots and on challenge abuse. | ||
| - A user-friendly alert context exposing `fsid`, OS, and the bot signals that fired. | ||
|
|
||
| ## Enabling bot challenge | ||
|
|
||
| Add the `crowdsecurity/simple-bot-challenge` appsec-config to your WAF acquisition, plus any of the | ||
| well-known-path exclusion configs you need: | ||
|
|
||
| ```yaml | ||
| appsec_configs: | ||
| - crowdsecurity/simple-bot-challenge | ||
| - crowdsecurity/challenge-exclude-crawler-files | ||
| - crowdsecurity/challenge-exclude-feeds | ||
| - crowdsecurity/challenge-exclude-webhooks | ||
| labels: | ||
| type: appsec | ||
| listen_addr: 127.0.0.1:7422 | ||
| source: appsec | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: crowdsecurity/appsec-bot-challenge | ||
| parsers: | ||
| - crowdsecurity/appsec-logs | ||
| - crowdsecurity/appsec-bot-detection-logs | ||
| appsec-configs: | ||
| - crowdsecurity/simple-bot-challenge | ||
| - crowdsecurity/challenge-exclude-crawler-files | ||
| - crowdsecurity/challenge-exclude-feeds | ||
| - crowdsecurity/challenge-exclude-webhooks | ||
| scenarios: | ||
| - crowdsecurity/appsec-bot-detected | ||
| - crowdsecurity/appsec-challenge-too-many-requests | ||
| - crowdsecurity/appsec-challenge-too-many-submissions | ||
| - crowdsecurity/appsec-challenge-request-with-no-submission | ||
| contexts: | ||
| - crowdsecurity/appsec_base | ||
| - crowdsecurity/appsec_bot_detection | ||
| description: "AppSec bot detection: challenge mode with fast-detect bot rejection and well-known-path exclusions" | ||
| labels: | ||
| label: "WAF - Bot Challenge" | ||
| author: crowdsecurity | ||
| tags: | ||
| - waf | ||
| - appsec | ||
| - http | ||
| - bot | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # User-friendly context for AppSec bot-detection / challenge events. | ||
| # Each detected_signals line emits a readable signal name only when its flag is set, | ||
| # so the console shows a compact list of what tripped the fast bot detection. | ||
| context: | ||
| fingerprint_id: | ||
| - evt.Meta.fsid | ||
| operating_system: | ||
| - evt.Meta.os | ||
| user_agent: | ||
| - evt.Meta.http_user_agent | ||
| bot_detected: | ||
| - evt.Meta.fingerprint_bot | ||
| challenge_event: | ||
| - evt.Meta.challenge_event | ||
| detected_signals: | ||
| - "evt.Unmarshaled.fingerprint.Bot.Webdriver ? 'webdriver' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.Selenium ? 'selenium' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.CDP ? 'chrome-devtools-protocol' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.Playwright ? 'playwright' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.BotUserAgent ? 'bot-user-agent' : ''" | ||
|
buixor marked this conversation as resolved.
Outdated
|
||
| - "evt.Unmarshaled.fingerprint.Bot.MissingChromeObject ? 'headless-chrome' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.PlatformMismatch ? 'platform-mismatch' : ''" | ||
| - "evt.Unmarshaled.fingerprint.Bot.GPUMismatch ? 'gpu-mismatch' : ''" | ||
|
buixor marked this conversation as resolved.
Outdated
|
||
42 changes: 42 additions & 0 deletions
42
parsers/s01-parse/crowdsecurity/appsec-bot-detection-logs.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| onsuccess: next_stage | ||
| format: 3.0 | ||
| #debug: true | ||
| filter: "evt.Parsed.program == 'appsec' && evt.Parsed.source == 'crowdsec-appsec-challenge'" | ||
| name: crowdsecurity/appsec-bot-detection-logs | ||
| description: "Parse AppSec bot-detection / challenge events" | ||
| statics: | ||
| - meta: service | ||
| value: appsec | ||
| - meta: log_type | ||
| value: appsec-challenge | ||
| - meta: source_ip | ||
| expression: "evt.Parsed.source_ip" | ||
| - meta: target_host | ||
| expression: "evt.Parsed.target_host" | ||
| - meta: request_uuid | ||
| expression: "evt.Parsed.req_uuid" | ||
| - meta: target_uri | ||
| expression: "evt.Parsed.target_uri" | ||
| - meta: challenge_event | ||
| expression: evt.Parsed.challenge_event | ||
| - meta: challenge_difficulty | ||
| expression: evt.Parsed.challenge_difficulty | ||
| - meta: challenge_fail_reason | ||
| expression: evt.Parsed.challenge_fail_reason | ||
| - meta: fsid | ||
| expression: evt.Parsed.fsid | ||
| - meta: fingerprint_bot | ||
| expression: evt.Parsed.fingerprint_bot | ||
| - meta: http_user_agent | ||
| expression: evt.Parsed.user_agent | ||
| # raw navigator.platform, kept for precise matching | ||
| - meta: platform | ||
| expression: evt.Parsed.platform | ||
| # user-friendly OS label derived from the raw platform string | ||
| - meta: os | ||
| expression: | | ||
| evt.Parsed.platform contains "Win" ? "Windows" : | ||
| (evt.Parsed.platform contains "Mac" ? "macOS" : | ||
| (evt.Parsed.platform contains "Linux" ? "Linux" : | ||
| (evt.Parsed.platform contains "iPhone" || evt.Parsed.platform contains "iPad" ? "iOS" : | ||
| (evt.Parsed.platform contains "Android" ? "Android" : evt.Parsed.platform)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| type: trigger | ||
| format: 3.0 | ||
| #debug: true | ||
| name: crowdsecurity/appsec-bot-detected | ||
| description: "A known bot was detected and rejected by the AppSec challenge (fast bot detection)" | ||
| filter: "evt.Meta.log_type == 'appsec-challenge' && evt.Meta.challenge_event == 'rejected'" | ||
| groupby: evt.Meta.source_ip | ||
| blackhole: 1m | ||
| labels: | ||
| service: http | ||
| confidence: 1 | ||
| spoofable: 0 | ||
| classification: | ||
| - attack.T1071 | ||
| label: "Bot detected by CrowdSec AppSec challenge" | ||
| behavior: "http:bot" | ||
| remediation: false |
20 changes: 20 additions & 0 deletions
20
scenarios/crowdsecurity/challenge-request-with-no-submission.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| type: counter | ||
| format: 3.0 | ||
| #debug: true | ||
| name: crowdsecurity/appsec-challenge-request-with-no-submission | ||
| description: "Client made too many request to challenge page" | ||
| filter: "evt.Meta.log_type == 'appsec-challenge' && (evt.Meta.challenge_event == 'requested' || evt.Meta.challenge_event == 'submitted')" | ||
| cancel_on: "evt.Meta.log_type == 'appsec-challenge' && evt.Meta.challenge_event == 'submitted'" | ||
| duration: 60s | ||
| capacity: -1 | ||
| cache_size: 1 | ||
| groupby: evt.Meta.source_ip | ||
| blackhole: 10s | ||
| labels: | ||
| service: http | ||
| confidence: 0 | ||
| spoofable: 0 | ||
| classification: | ||
| - attack.T1110 | ||
| label: "Blocked by CrowdSec AppSec" | ||
| behavior: "http:exploit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| type: leaky | ||
| format: 3.0 | ||
| #debug: true | ||
| name: crowdsecurity/appsec-challenge-too-many-requests | ||
| description: "Client made too many request to challenge page" | ||
| filter: "evt.Meta.log_type == 'appsec-challenge' && evt.Meta.challenge_event == 'requested'" | ||
| leakspeed: "60s" | ||
| capacity: 5 | ||
| groupby: evt.Meta.source_ip | ||
| blackhole: 1m | ||
| labels: | ||
| service: http | ||
| confidence: 0 | ||
| spoofable: 0 | ||
| classification: | ||
| - attack.T1110 | ||
| label: "Blocked by CrowdSec AppSec" | ||
| behavior: "http:exploit" | ||
| remediation: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| type: leaky | ||
| format: 3.0 | ||
| #debug: true | ||
| name: crowdsecurity/appsec-challenge-too-many-submissions | ||
| description: "Client made too many submissions for challenge" | ||
| filter: "evt.Meta.log_type == 'appsec-challenge' && evt.Meta.challenge_event == 'submitted'" | ||
| leakspeed: "60s" | ||
| capacity: 5 | ||
| groupby: evt.Meta.source_ip | ||
| blackhole: 1m | ||
| labels: | ||
| service: http | ||
| confidence: 0 | ||
| spoofable: 0 | ||
| classification: | ||
| - attack.T1110 | ||
| label: "Blocked by CrowdSec AppSec" | ||
| behavior: "http:exploit" | ||
| remediation: true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.