Skip to content

feat(scanner): add WebSocket malicious pattern detection#14

Open
dagangtj wants to merge 1 commit intocounterspec:mainfrom
dagangtj:feat/websocket-detection
Open

feat(scanner): add WebSocket malicious pattern detection#14
dagangtj wants to merge 1 commit intocounterspec:mainfrom
dagangtj:feat/websocket-detection

Conversation

@dagangtj
Copy link

Summary

Implements scanner rules for detecting malicious WebSocket handlers.

Changes

Adds 5 new detection patterns for WebSocket-based attacks:

Pattern ID Severity Description
WS_SUSPICIOUS_ENDPOINT high WebSocket to suspicious/dynamic endpoints
WS_DATA_EXFIL high Data exfiltration over WebSocket
WS_REVERSE_SHELL critical Reverse shell patterns via WebSocket
WS_C2_PATTERN critical Command & control communication
WS_BIDIRECTIONAL_EXFIL high File/env read + WebSocket send

Test Cases (7 total)

  • ✅ Suspicious endpoint detection (ngrok, dynamic URLs)
  • ✅ Environment variable exfiltration
  • ✅ Base64 encoded data transmission
  • ✅ Exec/spawn in message handlers
  • ✅ Eval-based C2 patterns
  • ✅ File read + send patterns
  • ✅ Negative test for legitimate usage

Closes #3

Implements scanner rules for detecting malicious WebSocket handlers (counterspec#3):

- WS_SUSPICIOUS_ENDPOINT: WebSocket to suspicious/dynamic endpoints
- WS_DATA_EXFIL: Data exfiltration over WebSocket
- WS_REVERSE_SHELL: Reverse shell patterns via WebSocket
- WS_C2_PATTERN: Command & control communication
- WS_BIDIRECTIONAL_EXFIL: File/env read + WebSocket send

Includes 7 test cases covering:
- Suspicious endpoint detection (ngrok, dynamic URLs)
- Environment variable exfiltration
- Base64 encoded data transmission
- Exec/spawn in message handlers
- Eval-based C2 patterns
- File read + send patterns
- Negative test for legitimate usage

Closes counterspec#3
@vercel
Copy link

vercel bot commented Feb 26, 2026

@dagangtj is attempting to deploy a commit to the Rapi's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Scanner rule for malicious WebSocket handlers

1 participant