What’s wrong with w/ WebSocket API?
Unveiling vulnerabilities in
WebSocket APIs
Mikhail Egorov / @0ang3el
#HACKTIVITY2019
# whoami
2
▪ Security researcher / full-time bug hunter
▪ https://bugcrowd.com/0ang3el
▪ https://hackerone.com/0ang3el
▪ Conference speaker
▪ https://www.slideshare.net/0ang3el
▪ https://speakerdeck.com/0ang3el
Previous work
3
▪ https://media.blackhat.com/bh-us-
12/Briefings/Shekyan/BH_US_12_Shekyan_Toukharian_Hacking_Websocket_Slides
.pdf
▪ https://www.nccgroup.trust/us/about-us/newsroom-and-
events/blog/2017/may/wssip-a-websocket-manipulation-proxy/
▪ https://chybeta.github.io/2018/04/07/spring-messaging-Remote-Code-Execution-
%E5%88%86%E6%9E%90-%E3%80%90CVE-2018-1270%E3%80%91/
▪ https://www.twistlock.com/labs-blog/demystifying-kubernetes-cve-2018-1002105-
dead-simple-exploit/
▪ https://github.com/andresriancho/websocket-fuzzer
▪ https://www.irongeek.com/i.php?page=videos/derbycon9/stable-35-old-tools-new-
tricks-hacking-websockets-michael-fowl-nick-defoe
4
WebSocket protocol essentials
WebSocket protocol – RFC 6455
5
▪ Efficient two-way communication protocol
▪ WebSocket is stateful (HTTP is stateless)
▪ Two main parts: handshake and data transfer
WebSocket protocol – RFC 6455
6
▪ Extensibility: subprotocols and extensions
▪ Subprotocols
▪ https://www.iana.org/assignments/websocket/websocket.xml#subpro
tocol-name
▪ Wamp
▪ Stomp
▪ Soap
▪ …
WebSocket protocol – RFC 6455
7
▪ Extensibility: subprotocols and extensions
▪ Extensions
▪ https://www.iana.org/assignments/websocket/websocket.xml#extens
ion-name
▪ permessage-deflate
▪ bbf-usp-protocol
WebSocket protocol – RFC 6455
8
▪ Origin-based security model (Browser clients)
▪ No authentication
▪ Client must do client-to-server masking
WebSocket protocol support
9
▪ Major web browsers
▪ Web servers / Proxies
▪ Apache httpd, Nginx, IIS, …
▪ HAProxy, Traefik, Varnish, Envoy, …
▪ Cloud providers
▪WebSocket API (api gateways)
▪WebSocket proxying (load balancers)
WebSocket handshake
10
Upgrade request
Base64(Random nonce)
Protocol version
Required HTTP version
WebSocket handshake
11
Required status code
BASE64(SHA1(Sec-WebSocket-Key || CONST ))
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
14
Cross-Site WebSocket Hijacking
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)
CSWSH
16
▪ Cookies are used to authenticate upgrade request
▪ Header Origin isn’t checked or checked poorly
CSWSH
17
▪ CORS tricks from @albinowax are applicable to
WebSocket
▪ https://portswigger.net/research/exploiting-cors-misconfigurations-
for-bitcoins-and-bounties
▪ Null origin
▪ Pre-domain wildcard
▪ Post-domain wildcard
▪ …
CSWSH – Null origin
18
▪ nullorigin.html
<iframe src="data:text/html,
<script>const socket = new
WebSocket('wss://example.com');
</script>"></iframe>
CSWSH
19
▪ Playground
▪ https://portswigger.net/web-security/websockets/cross-site-
websocket-hijacking
CSWSH – template for attack
5
Demo
5
22
Authentication / IDOR issues
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 1
24
▪ Some ID / GUID is required in Upgrade request
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
Broken authentication – Case 2
25
▪ No authentication during handshake step
▪ Some ID / GUID required in API messages
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
Broken authentication – Case 2
26
▪ Exposing GraphQL subscriptions w/o AuthN
▪ https://github.com/righettod/poc-graphql#subscriptions-
websocket-endpoint-default-enabling
▪ Path /subscriptions
Insecure Direct Object Reference issues
27
▪ Strong authentication during handshake step
▪ Some ID / GUID required in API messages
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
28
Smuggling through WebSocket
Reverse proxying WebSocket connection
29
Client
Frontend
Reverse proxy
Backend
/socket.io/
Public WebSocket API
Reverse proxying WebSocket connection
30
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
Backend
/socket.io/
Reverse proxying WebSocket connection
31
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
HTTP/1.1 101HTTP/1.1 101
Backend
/socket.io/
Reverse proxying WebSocket connection
32
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
HTTP/1.1 101HTTP/1.1 101
WebSocket connection
direct WebSocket connection
Client - Backend
Backend
/socket.io/
Smuggling through WebSocket connection
33
Client
Frontend
Reverse proxy
(vulnerable)
Private REST API
Public WebSocket API
Backend
/internal
/socket.io/
34
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
Version correctness isn’t checked!
Smuggling through WebSocket connection
35
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
HTTP/1.1 426HTTP/1.1 426
Response correctness isn’t checked!
Smuggling through WebSocket connection
36
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
HTTP/1.1 426HTTP/1.1 426
TLS connection
direct TLS connection
Client – Backend
not WebSocket!!!
Client can access
/internal
Smuggling through WebSocket connection
Challenge – challenge.0ang3el.tk
37
▪ URL
▪ https://challenge.0ang3el.tk/websocket.html
▪ You need to access flag on localhost:5000
▪ Seems no one solved
Challenge – challenge.0ang3el.tk
38
▪ Frontend
▪ Not disclosed WebSocket reverse proxy
▪ socket.io.js
▪ Proxies only WebSocket API - /socket.io/ path
▪ Backend
▪ Flask, Flask-SoketIO, Flask-Restful
▪ Listens on localhost:5000 only
challenge1.py
challenge1.py - DEMO
Vulnerable reverse proxies
41
▪ Vulnerable
▪ Varnish, Envoy proxy <= 1.8.0, other non-disclosed
▪ Not vulnerable
▪ Nginx, HAProxy, Traefik, others
Varnish response
42
▪ WebSocket proxying configuration
▪ https://varnish-cache.org/docs/6.3/users-guide/vcl-example-
websockets.html
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
44
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
example.com
GET
HTTP/1.1 200
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 101HTTP/1.1 101
Only status code is checked for response!
POST /api/health?u= POST /api/health?u=
Smuggling through WebSocket connection
47
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
HTTP/1.1 101HTTP/1.1 101
TLS connection
direct TLS connection
Client – Backend
not WebSocket!!!
Client can access
/internal
POST /api/health?u= POST /api/health?u=
Client-to-Server
masking isn’t checked
by proxy!!!
Challenge2 – challenge2.0ang3el.tk
48
▪ URL
▪ https://challenge2.0ang3el.tk/websocket.html
▪ You need to access flag on localhost:5000
▪ Seems no one solved
Challenge2 – challenge2.0ang3el.tk
49
▪ Frontend
▪ Nginx as WebSocket reverse proxy
▪ socket.io.js
▪ Proxies only /api/public path (socket.io and healthcheck)
▪ Backend
▪ Flask, Flask-SoketIO, Flask-Restful
▪ Listens on localhost:5000 only
Challenge2 – challenge2.0ang3el.tk
50
▪ Nginx config
Challenge2 – challenge2.0ang3el.tk
51
▪ REST API - healthcheck
Challenge2.py
5
Challenge2.py - Demo
5
Vulnerable reverse proxies
54
▪ Almost all proxies are affected
▪ But exploitation is limited
▪ External SSRF is required that returns status code
▪ …
55
Discovering WebSocket APIs
Discovering WebSocket API
56
▪ Monitor Upgrade requests
▪ Analyze JavaScript files
▪ Try to establish WebSocket connection to each
URL
▪ …
57
Conclusion
Ideas for further research
58
▪ Security of WebSocket subprotocols
▪ More smuggling techniques
▪ HTTP/2 and WebSocket
▪ …
Thank you!
@0ang3el

More Related Content

PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
PDF
HTTP Request Smuggling via higher HTTP versions
PPTX
Attacking thru HTTP Host header
PPTX
Reverse proxies & Inconsistency
PDF
Bug Bounty Hunter Methodology - Nullcon 2016
PDF
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
PDF
Offzone | Another waf bypass
PPTX
Understanding Cross-site Request Forgery
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
HTTP Request Smuggling via higher HTTP versions
Attacking thru HTTP Host header
Reverse proxies & Inconsistency
Bug Bounty Hunter Methodology - Nullcon 2016
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
Offzone | Another waf bypass
Understanding Cross-site Request Forgery

What's hot (20)

PDF
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
PDF
Neat tricks to bypass CSRF-protection
PPTX
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
PDF
Building Advanced XSS Vectors
PDF
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
PDF
XSS Magic tricks
PDF
Cross site scripting
PDF
Hunting for security bugs in AEM webapps
PPTX
XSS - Do you know EVERYTHING?
PDF
HTTP Security Headers
PDF
Secure Coding principles by example: Build Security In from the start - Carlo...
PPTX
Bug Bounty 101
PPTX
Mod security
PDF
Polyglot payloads in practice by avlidienbrunn at HackPra
PPTX
Cross Site Scripting: Prevention and Detection(XSS)
PDF
DNS hijacking using cloud providers – No verification needed
PDF
Bug bounty null_owasp_2k17
PDF
Hacking Adobe Experience Manager sites
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
Neat tricks to bypass CSRF-protection
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
Building Advanced XSS Vectors
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
XSS Magic tricks
Cross site scripting
Hunting for security bugs in AEM webapps
XSS - Do you know EVERYTHING?
HTTP Security Headers
Secure Coding principles by example: Build Security In from the start - Carlo...
Bug Bounty 101
Mod security
Polyglot payloads in practice by avlidienbrunn at HackPra
Cross Site Scripting: Prevention and Detection(XSS)
DNS hijacking using cloud providers – No verification needed
Bug bounty null_owasp_2k17
Hacking Adobe Experience Manager sites
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Ad

Similar to What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs. (20)

PPTX
Web sockets - Pentesting
ZIP
Websockets at tossug
PPTX
WebSockets in JEE 7
PPTX
ClientServer Websocket.pptx
PPTX
WebSockets-Revolutionizing-Real-Time-Communication.pptx
PPTX
vlavrynovych - WebSockets Presentation
PPTX
Intro to Web Sockets
PDF
Introduction to WebSockets
PDF
WebSockets - Today, in the Past, in Future and in Production.
PDF
Websockets
PDF
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
PPTX
Training Webinar: Enterprise application performance with server push technol...
PDF
Nuts and Bolts of WebSocket Devoxx 2014
PPTX
presentation in .net programming web sockets.pptx
PDF
Web Socket ASM support lior rotkovitch
PDF
WebSocket Server - Jul 2010
PPTX
Html5 websockets
PPT
PDF
WebSocket Push Fallback - Transcript.pdf
PPTX
Intro to WebSockets
Web sockets - Pentesting
Websockets at tossug
WebSockets in JEE 7
ClientServer Websocket.pptx
WebSockets-Revolutionizing-Real-Time-Communication.pptx
vlavrynovych - WebSockets Presentation
Intro to Web Sockets
Introduction to WebSockets
WebSockets - Today, in the Past, in Future and in Production.
Websockets
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
Training Webinar: Enterprise application performance with server push technol...
Nuts and Bolts of WebSocket Devoxx 2014
presentation in .net programming web sockets.pptx
Web Socket ASM support lior rotkovitch
WebSocket Server - Jul 2010
Html5 websockets
WebSocket Push Fallback - Transcript.pdf
Intro to WebSockets
Ad

More from Mikhail Egorov (9)

PDF
A Hacker's perspective on AEM applications security
PDF
Securing AEM webapps by hacking them
PDF
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
PPTX
CSRF-уязвимости все еще актуальны: как атакующие обходят CSRF-защиту в вашем ...
PDF
Unsafe JAX-RS: Breaking REST API
PDF
Entity provider selection confusion attacks in JAX-RS applications
PDF
New methods for exploiting ORM injections in Java applications
PDF
What should a hacker know about WebDav?
PDF
ORM2Pwn: Exploiting injections in Hibernate ORM
A Hacker's perspective on AEM applications security
Securing AEM webapps by hacking them
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
CSRF-уязвимости все еще актуальны: как атакующие обходят CSRF-защиту в вашем ...
Unsafe JAX-RS: Breaking REST API
Entity provider selection confusion attacks in JAX-RS applications
New methods for exploiting ORM injections in Java applications
What should a hacker know about WebDav?
ORM2Pwn: Exploiting injections in Hibernate ORM

Recently uploaded (20)

PPTX
Artificial_Intelligence_Basics use in our daily life
PDF
Buy Cash App Verified Accounts Instantly – Secure Crypto Deal.pdf
PPTX
最新版美国埃默里大学毕业证(Emory毕业证书)原版定制文凭学历认证
PDF
healthwealthtech4all-blogspot-com-2025-08-top-5-tech-innovations-that-will-ht...
PDF
Containerization lab dddddddddddddddmanual.pdf
PPTX
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
PDF
Top 8 Trusted Sources to Buy Verified Cash App Accounts.pdf
PPTX
Partner to Customer - Sales Presentation_V23.01.pptx
PDF
Alethe Consulting Corporate Profile and Solution Aproach
PDF
Alethe Consulting Corporate Profile and Solution Aproach
PPTX
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
PDF
Exploring The Internet Of Things(IOT).ppt
PPTX
COPD_Management_Exacerbation_Detailed_Placeholders.pptx
PDF
Public for study about wiring to confirm.
PPTX
Edit gdasgdkhagfhgfgfasdghhdgfhdgfj.pptx
PDF
Paper PDF The World Game (s) Great Redesign.pdf
PDF
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
PDF
Course Overview and Agenda cloud security
PPTX
Basic understanding of cloud computing one need
PPTX
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx
Artificial_Intelligence_Basics use in our daily life
Buy Cash App Verified Accounts Instantly – Secure Crypto Deal.pdf
最新版美国埃默里大学毕业证(Emory毕业证书)原版定制文凭学历认证
healthwealthtech4all-blogspot-com-2025-08-top-5-tech-innovations-that-will-ht...
Containerization lab dddddddddddddddmanual.pdf
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
Top 8 Trusted Sources to Buy Verified Cash App Accounts.pdf
Partner to Customer - Sales Presentation_V23.01.pptx
Alethe Consulting Corporate Profile and Solution Aproach
Alethe Consulting Corporate Profile and Solution Aproach
module 1-Part 1.pptxdddddddddddddddddddddddddddddddddddd
Exploring The Internet Of Things(IOT).ppt
COPD_Management_Exacerbation_Detailed_Placeholders.pptx
Public for study about wiring to confirm.
Edit gdasgdkhagfhgfgfasdghhdgfhdgfj.pptx
Paper PDF The World Game (s) Great Redesign.pdf
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
Course Overview and Agenda cloud security
Basic understanding of cloud computing one need
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx

What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.