WebSocket protocol – RFC 6455 5 ▪ Efficient two-way communication protocol ▪ WebSocket is stateful (HTTP is stateless) ▪ Two main parts: handshake and data transfer
WebSocket data transfer 12 \x00 – continuation frame \x01 – text frame \x02 – binary frame \x08 – close frame \x09 – ping \x0A – pong other values are reserved
WebSocket data transfer - masking 13 ▪ Masking key is 32-bit long passed inside frame ▪ Client must send masked data ▪ MASKED = MASK ^ DATA (^ - XOR) ▪ Mechanism protects against cache poisoning and smuggling attacks
WebSocket security for Web Browser 15 ▪ SOP doesn’t work for WebSocket in web browser ▪ Read from WebSocket cross-origin ▪ Write to WebSocket cross-origin ▪ Header Origin should be checked on handshake step (origin-based security model)
Authentication 23 ▪ WebSocket protocol doesn’t offer authentication ▪ Developers have to roll out their own AuthN ▪ It’s secure to check AuthN only during handshake ▪ Common secure implementations ▪ Session cookies ▪ Tokens
Broken authentication – Case 2 25 ▪ No authentication during handshake step ▪ Some ID / GUID required in API messages ▪ Guess ID ▪ Leak GUID (minor IDOR, …)
Insecure Direct Object Reference issues 27 ▪ Strong authentication during handshake step ▪ Some ID / GUID required in API messages ▪ Guess ID ▪ Leak GUID (minor IDOR, …)
Smuggling through WebSocket connection 33 Client Frontend Reverse proxy (vulnerable) Private REST API Public WebSocket API Backend /internal /socket.io/
Challenge – challenge.0ang3el.tk 37 ▪ URL ▪ https://challenge.0ang3el.tk/websocket.html ▪ You need to access flag on localhost:5000 ▪ Seems no one solved
Smuggling through WebSocket connection 43 Client Frontend Reverse proxy (Nginx or another) Private REST API Public WebSocket API & REST API Backend /internal /api/socket.io/ /api/health
Smuggling through WebSocket connection 45 Client Frontend Reverse proxy (Nginx or another) Backend /internal /api/socket.io/ /api/health Only Upgrade: websocket header is checked! POST /api/health?u= POST /api/health?u=
Smuggling through WebSocket connection 46 Client Frontend Reverse proxy (Nginx or another) Backend /internal /api/socket.io/ /api/health attacker.com GET HTTP/1.1 101 HTTP/1.1 101 HTTP/1.1 101 Only status code is checked for response! POST /api/health?u= POST /api/health?u=
Challenge2 – challenge2.0ang3el.tk 48 ▪ URL ▪ https://challenge2.0ang3el.tk/websocket.html ▪ You need to access flag on localhost:5000 ▪ Seems no one solved