agentleFS
awarexoneawarexone/AXguard/websocket-security/SKILL.md

websocket-security

Skill18 starsChanged 3 months agoMITView on GitHub

Analyze WebSocket security posture — use when reviewing WS/WSS upgrade auth, origin checks, message authorization, or cross-site WebSocket hijacking risks (CWE-346 / CWE-352 / A01:2021).

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify Origin/Host allowlists — reject missing/unexpected Origin for cookie-auth sockets.

    line 67
  2. Distinctive:

    Prefer explicit tokens over cookie-only WS when cross-site risk is high.

    line 68
  3. Distinctive:

    No cookie auth and no sensitive commands

    line 84
  4. Very specific:

    Use wss, short-lived tokens, and avoid putting long-lived secrets in query strings (logs).

    line 91

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

WebSocket Security

Purpose

Guide defensive review of WebSocket endpoints: authentication at upgrade time, origin validation, per-message authorization, and abuse of long-lived channels.

When to Use / When Not to Use

Use when:

  • Apps use ws/wss, Socket.IO, Action Cable, Spring STOMP, or browser WebSocket to privileged backends.
  • Cookie sessions authenticate the upgrade (cross-site WebSocket hijacking risk).
  • Real-time features push sensitive events or accept commands over WS.

Do not use when:

  • Pure unidirectional server-sent events/HTTP without WS.
  • Public read-only broadcast with no sensitive data and no command channel (still note DoS).

Security Concepts

The HTTP upgrade is the auth gate. Browsers send cookies on cross-site WS; Origin must be validated server-side. Authorization is not “once at connect” for every later message if topics/commands vary.

Threat Model

Attacker goals:

  1. Cross-site hijack of victim WS sessions to read/act.
  2. Subscribe to other users’ channels (BOLA over topics).
  3. Inject malicious messages causing XSS in listeners or server-side command execution.
  4. Resource exhaustion via connection floods / huge messages.

Analysis Workflow

  1. Locate upgrade handlers and auth checks (token query vs header vs cookie).
  2. Verify Origin/Host allowlists — reject missing/unexpected Origin for cookie-auth sockets.
  3. Prefer explicit tokens over cookie-only WS when cross-site risk is high.
  4. Map message types/topics; require authZ per subscribe/publish/action.
  5. Validate and size-limit message payloads; avoid eval of message bodies.
  6. Enforce TLS (wss) in production; avoid sensitive data on ws://.
  7. Rate-limit connections and messages; idle timeouts.

Evidence Requirements

  • Upgrade handler location and auth mechanism
  • Missing Origin check or missing per-message authZ
  • Sensitive event/command capability
  • Impact (hijack / IDOR / injection / DoS)

False Positive Controls

  • Token in protocol that is not auto-sent cross-site + Origin still checked
  • No cookie auth and no sensitive commands
  • Same-site-only deployments with hardened Origin allowlist and tests

Remediation

  1. Authenticate upgrade; re-authorize sensitive messages.
  2. Allowlist Origins; fail closed.
  3. Use wss, short-lived tokens, and avoid putting long-lived secrets in query strings (logs).
  4. Apply standard input validation to message payloads.
  5. Connection/message quotas and max payload sizes.

Verification

Review upgrade+message auth → Fix Origin/authZ → Re-test authorized clients only → Confirm cross-site connect fails closed

Related Skills

  • session-security, authentication-analysis, authorization-analysis
  • api-security, security-triage, security-remediation

Framework Mapping

  • CWE-346 Origin Validation Error; CWE-352 CSRF
  • OWASP A01:2021, A07:2021
  • OWASP API2:2023, API5:2023

References

Research Provenance

Primary sources:

  • OWASP A01/A07:2021; CWE-346; CWE-352; OWASP API2/API5:2023 (accessed 2026-09-15)

Secondary / internal:

  • AXGuard rules/auth.json adjacency; /axguard-auth
  • AwareXone Agentic-Bug-Hunter WebSocket methodology (concepts only; not copied)

Datasets:

  • UVID HF dataset — category linkage concepts only (MIT license metadata review 2026-09-15)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.