XSS via WebSockets
Code Review - Identifying the Vulnerability
Application Overview
Backend Analysis (server.py)
to_admin = queue.Queue()
to_user = queue.Queue()
@sock.route('/userws')
def userws(sock):
while True:
if not to_user.empty():
msg = to_user.get()
sock.send(msg)
msg = sock.receive(timeout=1)
if msg:
to_admin.put(msg)
@sock.route('/adminws')
def adminws(sock):
while True:
if not to_admin.empty():
msg = to_admin.get()
sock.send(msg)
msg = sock.receive(timeout=1)
if msg:
to_user.put(msg)Frontend Analysis (index.html)
Vulnerability
Local Testing
Setup
PoC: HTML Injection
Exploitation
Basic <script> Tag - FAILS
<script> Tag - FAILSEvent Handler Bypass
Question Walkthrough
Step 1: Analyze Source Code
Step 2: Craft Cookie Stealing Payload
Step 3: Send Payload
Step 4: Receive Cookie
Summary
Key Payloads
Payload
Purpose
Last updated