Skip to content

Conversation

@LaurenceJJones
Copy link
Member

@LaurenceJJones LaurenceJJones commented Nov 5, 2025

Description

🎯 SMB 3-Tier Bruteforce Detection with Impossible Travel

This PR implements a comprehensive SMB security detection suite following the SSH pattern, providing gap-free coverage against all bruteforce attack speeds plus impossible travel detection.

✨ Key Features

3-Tier Bruteforce Detection (Gap-Free Coverage)

  1. crowdsecurity/smb-bf (Fast attacks - unchanged)

    • Leakspeed: 10s, Capacity: 5
    • Coverage: 0-10s intervals
    • Catches: 5 failures within ~50 seconds
  2. crowdsecurity/smb-slow-bf (Slower attacks - new)

    • Leakspeed: 60s, Capacity: 10
    • Coverage: 10-60s intervals
    • Catches: 10 failures over ~10 minutes
  3. crowdsecurity/smb-time-based-bf (Time-spaced attacks - new)

    • Type: Conditional with MedianInterval() helper
    • Median interval threshold: 2 minutes (optimized for better coverage)
    • Coverage: >120s intervals
    • Leakspeed: 2h, Capacity: -1 (unlimited)
    • Includes cancel_on for successful authentication (false positive reduction)
    • Filters both failed and successful auth events

Success Authentication & Impossible Travel

  • crowdsecurity/smb-success-logs parser (new)

    • Parses NT_STATUS_OK successful authentications
    • Uses generic log_type: auth_success for compatibility
    • Sets service: smb metadata
  • crowdsecurity/smb-impossible-travel collection (new)

    • Leverages generic impossible-travel scenarios
    • Detects compromised credentials used from geographically distant locations
    • Requires GeoIP enrichment

🔧 Parser Enhancements

  • Added service: smb metadata to crowdsecurity/smb-logs parser
  • Ensures all SMB scenarios can properly filter by service

🧪 Testing

6 comprehensive test suites:

  • smb-logs - Failed auth parser test
  • smb-bf - Fast bruteforce (updated with private IPs)
  • smb-slow-bf - Slow bruteforce (15s intervals, 16 events)
  • smb-time-based-bf - Time-based bruteforce (3-4min intervals)
  • smb-success-logs - Success auth parser test
  • smb-impossible-travel - Impossible travel scenario test with GeoIP

All tests use private IP ranges (192.168.1.x) where appropriate.

📊 Coverage Analysis

No detection gaps:

  • 0-10s: Fast attacks → smb-bf
  • 10-60s: Medium-speed attacks → smb-slow-bf
  • >120s: Time-spaced attacks → smb-time-based-bf

This ensures attackers cannot evade detection by adjusting their attack speed.

📦 Collections Updated

  • crowdsecurity/smb - Now includes all 3 bruteforce scenarios
  • crowdsecurity/smb-impossible-travel (new) - Success logs + impossible travel detection

🎓 Pattern Consistency

Follows the established SSH detection pattern:

  • Same 3-tier structure (fast/slow/time-based)
  • Same cancel_on approach for false positive reduction
  • Same generic impossible-travel integration
  • Consistent naming and documentation

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

- Add crowdsecurity/smb-slow-bf conditional scenario
- Uses MedianInterval() to detect 3+ failed auth attempts with >5m intervals
- Leakspeed 2h, catches slow attacks evading standard rate limiting
- Update SMB collection to include slow-bf scenario
- Add test suite with 6 events (2 IPs, >5min intervals)
- Rename smb-slow-bf to smb-time-based-bf (conditional with MedianInterval)
- Create new smb-slow-bf as leaky bucket (60s leakspeed, capacity 10)
- Now follows SSH pattern with 3 tiers:
  - smb-bf: fast attacks (5 failures in ~50s)
  - smb-slow-bf: slower attacks (10 failures in ~10min)
  - smb-time-based-bf: time-spaced attacks (3 failures with >5min median)
- Update SMB collection to include all 3 scenarios
- Update test logs to use private IP ranges (192.168.1.x)
- Create test suites for all 3 scenarios with proper assertions
- Remove unnecessary parser.assert files (ignore_parsers: true)
@LaurenceJJones LaurenceJJones changed the title smb: add slow bruteforce detection scenario smb: add more bruteforce detection scenario Nov 5, 2025
…sed-bf

- Add smb-success-logs parser for NT_STATUS_OK authentications
  - Uses generic log_type: auth_success for impossible-travel compatibility
  - Sets service: smb metadata
- Create smb-impossible-travel collection
  - Leverages generic impossible-travel scenarios
  - Detects compromised credentials used from multiple locations
- Update smb-logs parser to include service metadata
- Improve smb-time-based-bf scenario:
  - Reduce median interval from 5m to 2m for better coverage
  - Add cancel_on for successful authentication (false positive reduction)
  - Filter includes both failed and successful auth events
  - Better coverage between slow-bf (60s) and time-based (>2m)
- Update coverage analysis in documentation:
  - smb-bf: 0-10s intervals
  - smb-slow-bf: 10-60s intervals
  - smb-time-based-bf: >120s intervals
- Update test logs with 3.5-4 minute intervals
- Regenerate all test assertions
- Update parser.assert to include new service: smb metadata
- All SMB parser tests now validate service field
- Add smb-success-logs parser test
  - Tests NT_STATUS_OK successful authentication parsing
  - Validates log_type: auth_success, service: smb metadata
  - Tests multiple users and domains
- Add smb-impossible-travel scenario test
  - Tests generic impossible-travel scenario with SMB
  - Uses geographically distant IPs (AU and US)
  - Includes geoip-enrich for location data
  - Validates impossible travel detection for same user
- Both tests passing successfully
- Add crowdsecurity/smb-success-logs parser to main smb collection
- Ensures success parser is available for smb-time-based-bf cancel_on
- Update documentation to reflect both parsers
- Correct median interval in docs (2min not 5min)
- smb-impossible-travel collection remains separate with parser + scenarios
@LaurenceJJones LaurenceJJones marked this pull request as draft November 5, 2025 11:24
@codersaur
Copy link

codersaur commented Nov 18, 2025

@LaurenceJJones I was just about to raise an issue that crowdsecurity/smb-logs is limited to "ipv4", please can you update the patterns to support "ipv6" too.

Copy link

@codersaur codersaur left a comment

Choose a reason for hiding this comment

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

There is no need to limit to "ipv4", please support "ipv6" too.

@LaurenceJJones
Copy link
Member Author

Hey @codersaur know you must be passionate about ipv6, but commenting 4 times all with the same content is just annoying.

Do you have an example log line so I can ensure I can get the right fix for this.

@codersaur
Copy link

codersaur commented Nov 19, 2025

Hey @codersaur know you must be passionate about ipv6, but commenting 4 times all with the same content is just annoying.

Do you have an example log line so I can ensure I can get the right fix for this.

Sorry Laurence, I discovered I could add a comment to specific files so thought I was being helpful identifying the files. At least I got the right repo this time... 😅

Here's an example log line:
Auth: [SMB2,(null)] user [HOST]\[guest] at [Tue, 18 Nov 2025 22:37:21.070329 GMT] with [NTLMv2] status [NT_STATUS_NO_SUCH_USER] workstation [localhost] remote host [ipv6:fdfd:ffff:ffff:7:101c:49b2:e676:ab41:60630] mapped to [HOST]\[guest]. local host [ipv6:fdfd:ffff:ffff:5::4:445]

This will match the SMB_AUTH_FAIL pattern if you change "ipv4" to "ipv\d" in /patterns/smb

For SMB_BAD_PASSWORD:
Auth: [SMB2,(null)] user [HOST]\[codersaur] at [Wed, 19 Nov 2025 10:23:54.603389 GMT] with [NTLMv2] status [NT_STATUS_WRONG_PASSWORD] workstation [localhost] remote host [ipv6:fdfd:ffff:ffff:7:101c:49b2:e676:ab41:60763] mapped to [HOST]\[codersaur]. local host [ipv6:fdfd:ffff:ffff:5::4:445]

Similarly, the SMB_BAD_PASSWORD pattern seems to work if you change "ipv4" to "ipv\d" in parsers/s01-parse/crowdsecurity/smb-logs.yaml

I humbly suggest that IPv6 test cases are added across the board, perhaps also a linting rule to spot any hard-coded "ipv4" references...? If is 2025 after all, IPv6 shouldn't be the forgotten sister... especially for a product that puts "IPV6 compatible" in its headline.

@LaurenceJJones
Copy link
Member Author

I humbly suggest that IPv6 test cases are added across the board, perhaps also a linting rule to spot any hard-coded "ipv4" references...? If is 2025 after all, IPv6 shouldn't be the forgotten sister... especially for a product that puts "IPV6 compatible" in its headline.

Most do already support ipv6, it just some lesser used ones such as SMB (cause not many people exposed SMB over the internet) are just not used enough to surface issues.

There no need to add any linting rules when this is the only case when it occurs cause new parsers use %{IP} by default.

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.

2 participants