websocket-security

仓库创建 2026年7月1日最近提交 23 天前SkillHot 收录 22 天前
▸ 精选理由

适合实时通信场景,能减少会话滥用与跨站攻击风险。

这个 Skill 做什么

为 WebSocket 提供握手校验、授权、消息限流与加密连接等安全策略。

为 WebSocket 加握手校验和鉴权、只允许 wss、对消息大小与速率做限流并实现重连退避。浏览器会跨域升级并带上 cookie,单靠 CORS 不够,所以服务端要做 Origin 白名单和握手认证。能有效防止跨站 WebSocket 劫持和资源耗尽。

▸ 展开 SKILL.md 英文原文

Secure WebSocket endpoints: Origin validation, auth on handshake, message size/rate limits, wss-only, reconnection backoff

开发编程WebSocket安全握手认证限流通用
2
Stars
0
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/ShieldNet-360/secure-vibe/main/skills/websocket-security/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/ShieldNet-360/secure-vibe/main/skills/websocket-security/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# WebSocket Security

## Rules (for AI agents)

### ALWAYS
- Validate the **`Origin` header** on the WebSocket upgrade handshake
  against an allowlist. CORS does **not** apply to WebSockets — the
  browser will happily upgrade cross-origin and let JavaScript on
  `attacker.com` open `wss://api.example.com/ws` with the user's
  cookies (Cross-Site WebSocket Hijacking).
- Require authentication **on the handshake** itself, not as the first
  message after connect. Either:
  1. Cookie-based auth on the HTTP upgrade (and CSRF-protect by
     verifying Origin), or
  2. A short-lived signed token (5–10 minute lifetime) in the
     `Sec-WebSocket-Protocol` subprotocol header, or
  3. A signed quer
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有