Skip to content
Back to skills

Khaos Websocket Testing

BSecurity

Methodology for detecting WebSocket vulnerabilities including auth bypass, subscription hijacking, and unauthenticated channels in authorized assessments

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentstestinggitapisecurity

Works with

  • api

Security analysis

B85/100
  • highContains patterns that look like hardcoded API keys

Pro shows the line behind each finding and how to fix it

Scanned December 5, 2026

npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-websocket-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Khaos Websocket Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Khaos Websocket Testing
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/henriqqw-khaos-websocket-testing-khaos-pentester-agent/badge)](https://www.skillsdirectory.com/skills/henriqqw-khaos-websocket-testing-khaos-pentester-agent)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: khaos-websocket-testing
description: Methodology for detecting WebSocket vulnerabilities including auth bypass, subscription hijacking, and unauthenticated channels in authorized assessments
metadata:
  khaos:
    tool_ids: [websocat, httpx, katana]
    wordlist_ids: []
    stages: [recon, vuln, validation]
    source_type: original
    source:
      repository: https://github.com/henriqqw/Khaos
      revision: internal
      path: internal/skillseed/catalog/khaos-websocket-testing/SKILL.md
      license: MIT
      reviewed_by: Khaos maintainers
      review_note: Skill escrita pela equipa Khaos para assessments autorizados.
---

# WebSocket Security Testing

## Objective

Identify WebSocket vulnerabilities: missing authentication on the upgrade handshake, broken authorization on subscription channels, injection via WS frames, and lack of origin validation.

## Discovery

```
# 1. Identify WS endpoints during crawl — katana emits ws:// and wss:// under xhr events
khaos_run_catalog_action("katana", assessment_id, endpoint)

# 2. Confirm WS endpoints with httpx header detection
khaos_run_catalog_action("httpx", assessment_id, endpoint)
# Look for: Upgrade: websocket, Connection: Upgrade, Sec-WebSocket-Accept

# 3. Check source for WS endpoint patterns
khaos_browser_inspect("ws:|wss:|WebSocket(|new WebSocket")
```

## Authentication Gate Testing

The WebSocket upgrade handshake (HTTP GET with `Upgrade: websocket`) must enforce the same authentication as the REST API.

```
# Test 1: Upgrade without auth cookie / token
khaos_run_catalog_action("websocat", assessment_id, "wss://target/ws/endpoint")
# Expected: HTTP 401/403 on upgrade. Vulnerable: HTTP 101 Switching Protocols

# Test 2: Upgrade with expired/invalid JWT
khaos_http_request(assessment_id, {
  method: "GET", url: "wss://target/ws/chat",
  headers: {"Authorization": "Bearer [REDACTED]"}
})
# Expected: 401. Vulnerable: 101 (alg:none bypass)

# Test 3: Cookie-based upgrade — replace session cookie with another user's
# Requires two auth profiles: owner + non-owner
```

## Subscription Hijacking / BOLA via WebSocket

After a successful authenticated connection, test whether subscription channels enforce ownership.

```
# Pattern: subscribe to another user's private channel
{
  "action": "subscribe",
  "channel": "private-user-{victim_id}"   // change ID to another user's
}
# Expected: error/silence. Vulnerable: messages from victim's channel arrive
```

## Origin Validation Bypass

```
# Test missing Origin check on upgrade:
khaos_http_request(assessment_id, {
  method: "GET", url: "wss://target/ws",
  headers: {
    "Upgrade": "websocket",
    "Connection": "Upgrade",
    "Origin": "https://evil.com",
    "Sec-WebSocket-Key": "[REDACTED]",
    "Sec-WebSocket-Version": "13"
  }
})
# Expected: 403. Vulnerable: 101 (CSRF over WS)
```

## Frame Injection / XSS via WS Messages

```
# Inject XSS payload as a WS message if output is reflected in DOM
echo '{"type":"message","data":"<img src=x onerror=alert(1)>"}' | \
  khaos_run_catalog_action("websocat", assessment_id, endpoint)
```

## Validation Requirements

- **3 independent reproductions** before marking as valid finding
- Authentication bypass: reproduce with fresh session each time (no cached state)
- BOLA: use distinct `owner` and `non-owner` profiles — finding must show owner's data reaching non-owner
- Record upgrade HTTP exchange (101 response + headers) as primary evidence

## Finding Classification

| Scenario | OWASP | Severity |
|---|---|---|
| Unauthenticated WS upgrade | A01 Broken Access Control | HIGH |
| BOLA via subscription channel | A01 Broken Access Control | HIGH |
| Missing Origin check (CSRF over WS) | A01/A05 | MEDIUM |
| Frame injection → stored XSS | A03 Injection | HIGH |
| Sensitive data in unencrypted ws:// | A02 Cryptographic Failures | MEDIUM |

## Notes

- `websocat --one-message --exit-on-eof` exits after one round-trip; pipe payloads via stdin
- Some WS endpoints require a valid HTTP upgrade first — use `khaos_http_request` to capture the `101` and extract the `Sec-WebSocket-Accept` for replay
- Always prefer `wss://` in scope; test `ws://` only when explicitly in scope

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.