add xray-logs parser and xray-brute-force scenario new features to global repository#1837
Open
xulianh wants to merge 2 commits into
Open
add xray-logs parser and xray-brute-force scenario new features to global repository#1837xulianh wants to merge 2 commits into
xulianh wants to merge 2 commits into
Conversation
added 2 commits
July 1, 2026 00:21
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new CrowdSec Hub detection suite for X-ray proxy logs: a dedicated s01 parser (xulianh/xray-logs) plus a leaky-bucket scenario (xulianh/xray-brute-force), along with a hubtest pipeline covering parsing, date enrichment, and scenario triggering.
Changes:
- Add
xulianh/xray-logsparser to extractsource_ip,source_port, andaction, and to provideevt.StrTimefordateparse-enrich. - Add
xulianh/xray-brute-forceleaky-bucket scenario grouping onsource_ipand triggering onaction == rejected. - Add
.tests/xray-brute-force/hubtest suite (sample log, config, and frozen assertions).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
scenarios/xulianh/xray-brute-force.yaml |
New leaky-bucket scenario to detect repeated rejected events by source IP. |
scenarios/xulianh/xray-brute-force.md |
Scenario documentation for the X-ray brute-force detection. |
parsers/s01-parse/xulianh/xray-logs.yaml |
New parser for X-ray access logs; sets metadata and event time for enrichment. |
parsers/s01-parse/xulianh/xray-logs.md |
Parser documentation and acquisition guidance. |
.tests/xray-brute-force/config.yaml |
Hubtest configuration wiring non-syslog ingestion, parser, and date enrichment to the scenario. |
.tests/xray-brute-force/xray_sample.log |
Test log input used by hubtest. |
.tests/xray-brute-force/parser.assert |
Frozen hubtest assertions for s00/s01/s02 stages. |
.tests/xray-brute-force/scenario.assert |
Frozen hubtest assertions for scenario overflows. |
Comment on lines
+15
to
+16
| - target: evt.StrTime | ||
| expression: "evt.Parsed.year + '-' + evt.Parsed.month + '-' + evt.Parsed.day + 'T' + evt.Parsed.hour + ':' + evt.Parsed.minute + ':' + evt.Parsed.second + 'Z'" |
| blackhole: 1m | ||
| labels: | ||
| service: xray | ||
| type: brute-force |
Comment on lines
+1
to
+12
| --- | ||
|
|
||
| author: xulianh | ||
| classification: | ||
|
|
||
| * AppSec | ||
| * Proxy | ||
| tags: | ||
| * xray | ||
| * brute-force | ||
|
|
||
| --- |
|
|
||
| ## 📝 Description | ||
|
|
||
| This parser is designed to extract relevant security events from X-ray proxy service logs. It targets incoming log strings to identify connection outcomes and safely isolate structural metadata such as source IP addresses and destination ports. |
|
|
||
| ## 🔍 Extraction Logic | ||
|
|
||
| The component utilizes optimized Grok patterns to process the `message` field of raw incoming lines matching the `xray` program identifier. |
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["action"] == "accepted" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["day"] == "30" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["hour"] == "16" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["message"] == "2026/06/30 16:43:03.500000 from 192.0.2.10:62264 accepted tcp:1.1.1.1:443 [direct]" |
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["micro"] == "500000" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["minute"] == "43" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["month"] == "06" | ||
| results["s01-parse"]["xulianh/xray-logs"][5].Evt.Parsed["reason"] == "tcp:1.1.1.1:443 [direct]" |
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["action"] == "accepted" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["day"] == "30" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["hour"] == "16" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["message"] == "2026/06/30 16:43:03.500000 from 192.0.2.10:62264 accepted tcp:1.1.1.1:443 [direct]" |
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["micro"] == "500000" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["minute"] == "43" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["month"] == "06" | ||
| results["s02-enrich"]["crowdsecurity/dateparse-enrich"][5].Evt.Parsed["reason"] == "tcp:1.1.1.1:443 [direct]" |
Comment on lines
+24
to
+28
| filenames: | ||
|
|
||
| * /var/log/xray/access.log | ||
| labels: | ||
| type: xray |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This Pull Request introduces a complete detection suite for X-ray proxy services, consisting of a dedicated log parser and a brute-force correlation scenario.
The parser (
xulianh/xray-logs) extracts connection metadata—specifically isolating the source IP, ephemeral source port, and action states—from raw X-ray access logs. It incorporates precise chronological synchronization viadateparse-enrichto allow accurate historical log analysis and forensic replays.The scenario (
xulianh/xray-brute-force) implements a leaky bucket algorithm to monitor authentication failures or network scanning attempts targeting the proxy. It tracksrejectedconnection states per source IP address using a capacity of 5 events and a 20-second leak speed. Following security best practices, the detection logic is fully resilient against mixed traffic noise; concurrent legitimate connections (accepted) from the same source IP do not clear or reset the malicious failure counter, neutralizing basic evasion techniques.A comprehensive
hubtestsuite is provided to validate the entire pipeline. The test vector utilizes strictly anonymized log entries with documentation IP ranges, achieving a total of 613 successful assertions under isolated conditions.Checklist