Skip to content

feat: Obfuscated exfiltration detection, WebSocket C2, FP reduction, GitLab CI (closes #1, #2, #3, #5)#78

Open
ezzy1630 wants to merge 1 commit into
counterspec:mainfrom
ezzy1630:feat/obfuscated-exfil-detection
Open

feat: Obfuscated exfiltration detection, WebSocket C2, FP reduction, GitLab CI (closes #1, #2, #3, #5)#78
ezzy1630 wants to merge 1 commit into
counterspec:mainfrom
ezzy1630:feat/obfuscated-exfil-detection

Conversation

@ezzy1630
Copy link
Copy Markdown

Bounty Issues Addressed

This PR addresses 4 bounty issues in a single submission:

#1 - Detect Obfuscated Credential Exfiltration (1,000 $ISNAD, tier:critical)

New obfuscated-exfil.ts detection module:

  • Base64-encoded exfiltration URLsatob()/Buffer.from() decoding with network calls
  • Hex-constructed API endpoints\\x68\\x74\\x74\\x70 style obfuscated URLs
  • CharCode URL constructionString.fromCharCode(104,116,116,112...) patterns
  • String reversal obfuscation.split("").reverse().join("") to hide URLs
  • Concatenated URL construction"https:" + "//evil.com" evade detection
  • Template literal URL assembly`https://${subdomain}.evil.com/${path}`
  • Environment variable harvestingprocess.env → obfuscated transmission
  • Decode-then-send — Decoding before fetch/axios/request
  • Decoded sample extraction — Actively decodes base64, hex, charcode, reversed strings to reveal hidden URLs

All 8 detection patterns + decoder with 11 test cases.

#3 - Scanner Rule for Malicious WebSocket Handlers (200 $ISNAD, tier:rule)

New websocket-c2.ts detection module:

  • WebSocket C2 connections — Hardcoded and dynamic URL detection
  • Message handler exfiltrationonmessage handlers accessing process.env/fs
  • Reverse shell patterns — WebSocket + child_process/execSync combos
  • Data exfiltration channels.send() with sensitive data
  • Binary payload transfersArrayBuffer/Uint8Array handling
  • Suspicious URL indicators — ngrok, Tor, raw IPs, Discord/Slack webhooks, high ports
  • Suspicious connection analysis with risk assessment
  • 10 test cases

#2 - Reduce False Positives on Legitimate HTTP Clients (500 $ISNAD, tier:improvement)

Context-aware detection patterns:

  • HTTP_CLIENT_PATTERNS — Allowlist for axios, node-fetch, got, superagent, needle, urllib3
  • LEGITIMATE_HTTP_CONTEXT — Test file detection (jest, mocha, vitest, cypress)
  • KNOWN_SAFE_ENDPOINTS — Allowlist for GitHub API, npm registry, PyPI, OpenAI, Anthropic APIs
  • Integrated into analyzer for smarter pattern matching

#5 - GitLab CI Integration Template (750 $ISNAD, tier:improvement)

.gitlab-ci/isnad-gitlab-ci.yml:

  • Full scan job — Scans entire project on default branch and MRs
  • Quick scan job — Scans only changed files in MRs for fast feedback
  • Flag submission job — Manual job to submit findings to ISNAD Oracle
  • SARIF output — Compatible with GitLab Security Dashboard
  • Configurable thresholdsISNAD_FAIL_ON_CRITICAL, ISNAD_FAIL_ON_HIGH, ISNAD_FAIL_ON_MEDIUM
  • Setup documentation — Complete README with configuration, variables, examples

Testing

All 21 tests passing:

  • 11 obfuscated exfiltration tests
  • 10 WebSocket C2 detection tests

Closes #1, closes #2, closes #3, closes #5

…ab CI template, and context-aware FP reduction (closes counterspec#1, counterspec#2, counterspec#3, counterspec#5)

Obfuscated Credential Exfiltration Detection (counterspec#1 - tier:critical, 1000 ):
- New obfuscated-exfil.ts module with 8 detection patterns
- Base64-encoded exfiltration URLs
- Hex/charcode-constructed API endpoints
- String reversal and concatenation obfuscation
- Environment variable harvesting with obfuscated transmission
- Template literal URL assembly
- Decode-then-send patterns
- Decoded sample extraction (base64, hex, charcode, reversed strings)
- 11 test cases with real-world malware encoding patterns

Malicious WebSocket Handler Detection (counterspec#3 - tier:rule, 200 ):
- New websocket-c2.ts module with 6 detection patterns
- WebSocket C2 connection detection (hardcoded and dynamic URLs)
- Message handler exfiltration (onmessage accessing env/files)
- Reverse shell pattern (WebSocket + child_process)
- Data exfiltration channel detection (sensitive data over ws.send)
- Binary payload transfer detection
- Suspicious URL indicators (ngrok, Tor, raw IP, Discord webhooks)
- 10 test cases

Reduce False Positives on Legitimate HTTP Clients (counterspec#2 - tier:improvement, 500 ):
- HTTP_CLIENT_PATTERNS for common legitimate libraries
- LEGITIMATE_HTTP_CONTEXT for test/framework files
- KNOWN_SAFE_ENDPOINTS allowlist
- Context-aware detection distinguishing legitimate from malicious usage

GitLab CI Integration Template (counterspec#5 - tier:improvement, 750 ):
- .gitlab-ci/isnad-gitlab-ci.yml with full, quick, and flag-submission jobs
- SARIF output for GitLab Security Dashboard integration
- Configurable severity thresholds and scan targets
- Documentation with setup, configuration, and usage examples

All 21 tests passing.

Closes counterspec#1, closes counterspec#2, closes counterspec#3, closes counterspec#5
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

@ezzy1630 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

1 participant